PyPokerEngine icon indicating copy to clipboard operation
PyPokerEngine copied to clipboard

min_raise and max_raise = -1 when raise is still possible

Open schreven opened this issue 5 years ago • 5 comments

When the players remaining stack is too low for the minimal raise (defined by the call amount + the last raise performed on the street), -1 is given by valid_actions, though if the player has more than the call amount, he should be able to raise to that value (to go all-in) To fix this, I changed the function legal_actions in engine/action_checker.py to:

def legal_actions(self, players, player_pos, sb_amount):
    min_raise = self.__min_raise_amount(players, sb_amount)
    max_raise = players[player_pos].stack + players[player_pos].paid_sum()
    if max_raise < min_raise:
      min_raise = max_raise = -1
        if self.agree_amount(players)>=max_raise:
            min_raise = max_raise = -1
        else:
            min_raise = max_raise = players[player_pos].stack + players[player_pos].paid_sum()
    return [
        { "action" : "fold" , "amount" : 0 },
        { "action" : "call" , "amount" : self.agree_amount(players) },
        { "action" : "raise", "amount" : { "min": min_raise, "max": max_raise } }
]

Now if the player has a stack smaller than the call amount, -1 is still returned and the player can just call, but when the player's stack is larger than the call amount, his all-in amount is returned.

schreven avatar Jun 11 '19 15:06 schreven

@schreven according to prev issues I assume you have the latest updates, could you please share your branch?

alexyalunin avatar Jun 15 '19 15:06 alexyalunin

Glad to see someone else is active with this repository. Here is the fork. I added a readme describing the changes I made. A few notes: I've not been thorough on the first commit titles. There are some added options that I use for my project, they are not active by default. The only change that may affect you is if you use blind structures, they are updated differently now. Will put that as an option in the future. An issue I have not fixed is that the winner is determined by 7 cards, though it should be only 5. I've tried to be precise but if you see an issue, let me know!

schreven avatar Jun 16 '19 08:06 schreven

@schreven I encountered the same issue and fixed it similar to what you did. Hope that can be merged in the official repo soon.

allenfrostline avatar Jul 16 '19 15:07 allenfrostline

I'm glad to see that this project is not dead. Good work.

110503 avatar Jan 18 '20 03:01 110503

Thanks! It's just a shame that the repository owner is not active anymore. If more people still use this project, it can be worthwhile to maintain a fork

schreven avatar Jan 20 '20 18:01 schreven