(self, match)
| 406 | raise ValueError("Card Cannot Be Found") |
| 407 | |
| 408 | def think(self, match): |
| 409 | card = None |
| 410 | self.currentColor = match.currentColor |
| 411 | currentValue = match.currentValue |
| 412 | zeroChangeRule = match.zeroChange |
| 413 | twoPlayers = False |
| 414 | previousTurnID = match.getNextTurn(True) |
| 415 | nextTurnID = match.getNextTurn(False) |
| 416 | previousPlayer = match.getPlayer(previousTurnID) |
| 417 | #nextPlayer = match.getPlayer(nextTurnID) |
| 418 | if previousTurnID == nextTurnID: |
| 419 | twoPlayers = True |
| 420 | if self.canSkip == False and self.canReverse == True: |
| 421 | self.canSkip = True |
| 422 | self.canReverse = False |
| 423 | |
| 424 | self.getLegalCards(self.currentColor, currentValue, zeroChangeRule) |
| 425 | |
| 426 | ### DRAW CASE ### |
| 427 | |
| 428 | if len(self.legalCards) == 0 and len(self.wildCards) == 0: |
| 429 | return "d" |
| 430 | |
| 431 | else: |
| 432 | |
| 433 | ### NO LEGAL CARD, USE WILD CARD ### |
| 434 | |
| 435 | if len(self.legalCards) == 0: |
| 436 | |
| 437 | if zeroChangeRule and self.canZeroChange: |
| 438 | bestZeroColor = self.getBestColor(self.zeroCards) |
| 439 | card = self.getCardByColor(self.zeroCards, bestZeroColor) |
| 440 | |
| 441 | else: |
| 442 | |
| 443 | if self.canDrawFour: |
| 444 | card = self.getCardByValue(self.wildCards, "+4") |
| 445 | print(card) |
| 446 | |
| 447 | else: |
| 448 | card = random.choice(self.wildCards) |
| 449 | |
| 450 | else: |
| 451 | |
| 452 | ### HAS LEGAL CARD ### |
| 453 | |
| 454 | if twoPlayers and self.canSkip: #Always play a skip card in a two player game |
| 455 | #print("Shed Skip Strategy") |
| 456 | card = self.getCardByValue(self.legalCards,"R", "X") |
| 457 | |
| 458 | if self.canReverse and previousPlayer.didDraw(): |
| 459 | #print("Reverse Strategy") |
| 460 | reverseCards = self.getAllCardsByValue(self.legalCards, "R") |
| 461 | for reverseCard in reverseCards: |
| 462 | if reverseCard.getColor() == self.currentColor: |
| 463 | card = reverseCard |
| 464 | |
| 465 | if self.canValueChange: |
no test coverage detected