| 537 | |
| 538 | class ShowdownNode(ActionNode): |
| 539 | def __init__(self, parent, committed, players, player, bet_history,betting_round=None,**kwargs): |
| 540 | super().__init__(parent, committed, players, player, bet_history,betting_round=betting_round, ** kwargs) |
| 541 | self.last_action = kwargs['last_action'] |
| 542 | if parent: |
| 543 | self.parent.add_child(self,self.last_action) |
| 544 | |
| 545 | self.payoffs = {} |
| 546 | # payoff's key is player id represent what happens if player i wins |
| 547 | # it's value is payoffs for all players if player i wins |
| 548 | |
| 549 | for i in players: |
| 550 | # everybody throw in money |
| 551 | self.payoffs[i] = [-i for i in self.committed] |
| 552 | # winner get all money |
| 553 | self.payoffs[i][i] += self.pot |
| 554 | |
| 555 | # 仅考虑两个玩家的情况 |
| 556 | self.payoffs['tie'] = [-i + (self.pot / 2) for i in self.committed] |
| 557 | self.showdown = True |
| 558 | |
| 559 | def add_child(self, child,action): |
| 560 | # Showdown Node shouldn't have any child |