texasholdem icon indicating copy to clipboard operation
texasholdem copied to clipboard

The way raise is defined is troublesome

Open packetsss opened this issue 3 years ago • 16 comments

When I raise 5 chips, the amount should be this pot's raised value + 5, not just 5 chips. It's causing many errors and I printed out player info's and pots.raised image

You can see in the image, player's actions do not map correctly to pot-raised amounts (when player 3 raised 1298 chips, one value in the list below should update to 1298 as the raised amounts) and I have no idea where to locate this bug. Thanks for the help in advance!

packetsss avatar Mar 10 '22 04:03 packetsss

Yeah so that's actually by design. That is, RAISE 50 can be read as raise to 50. You can see that when player 3 raised 1298 chips, the total amount in the pots became 1298.

I do hear you though that it is way more intuitive to have the alternative. I'll add this in as a to do

SirRender00 avatar Mar 10 '22 05:03 SirRender00

A work around for now is that you can have a player raise the amount game.player_bet_amount(player_id) + game.chips_to_call(player_id) + raise_amount where raise_amount behaves as you describe.

SirRender00 avatar Mar 10 '22 05:03 SirRender00

Thank you for the reply! That's what I did using my agents, but as you can see in the screenshot above, pot.raised is not being calculated correctly and I have always been getting this:

image

packetsss avatar Mar 10 '22 05:03 packetsss

Looks to be a bug with split pots. Those have been notoriously troublesome... What version are you on?

SirRender00 avatar Mar 10 '22 05:03 SirRender00

The latest version

packetsss avatar Mar 10 '22 05:03 packetsss

It would be also be helpful if you can export the history of the hand with game.export_history and post that here. It will be useful to replicate what happened and add it to the test suite.

SirRender00 avatar Mar 10 '22 05:03 SirRender00

Looks like that when someone went all-in. It split the pot when it wasn't suppose to, probably has to do with the logic of when we split the pot here: https://github.com/SirRender00/texasholdem/blob/97e05f328413d8ead60a1d88c91d5ccf2ab559a9/texasholdem/game/game.py#L432-L437

SirRender00 avatar Mar 10 '22 05:03 SirRender00

Ok I can see about getting a fix on this. But getting that history file if you can will be most helpful in verifying it.

SirRender00 avatar Mar 10 '22 05:03 SirRender00

The Invalid move error is fixed after I changed to game.player_bet_amount(player_id) + game.chips_to_call(player_id) + raise_amount. But the pot is still behaving kinda weird:

I added this in the Pot class

    def __repr__(self):
        return {
            "amount": self.amount,
            "raised": self.raised,
            "player_amounts": self.player_amounts,
            "player_amounts_without_remove": self.player_amounts_without_remove,
        }.__str__()

and the output looks like:

pots: [
    {
        "amount": 3000,
        "raised": 0,
        "player_amounts": {5: 0, 0: 0, 2: 0, 3: 0, 4: 0},
        "player_amounts_without_remove": {
            0: 500,
            1: 500,
            2: 500,
            3: 500,
            4: 2622,
            5: 500,
        },
    },
    {
        "amount": 0,
        "raised": 0,
        "player_amounts": {4: 0, 0: 0, 2: 0, 3: 0},
        "player_amounts_without_remove": {4: 2122, 0: 0, 1: 0, 2: 0, 3: 0},
    },
    {
        "amount": 0,
        "raised": 0,
        "player_amounts": {4: 0, 2: 0, 3: 0},
        "player_amounts_without_remove": {4: 2122, 1: 2122, 2: 0, 3: 0},
    },
    {
        "amount": 0,
        "raised": 0,
        "player_amounts": {4: 0, 3: 0},
        "player_amounts_without_remove": {4: 2122, 1: 2122, 3: 0},
    },
    {
        "amount": 2122,
        "raised": 0,
        "player_amounts": {4: 0},
        "player_amounts_without_remove": {4: 1061, 1: 1061},
    },
]

I also added this player_amounts_without_remove that records player's bets in the entire game without resetting it. Seems like a lot of empty pots are added.

packetsss avatar Mar 10 '22 05:03 packetsss

Here are some of the history files you've requested... history.zip

packetsss avatar Mar 10 '22 05:03 packetsss

Sorry which of those files display abnormal behavior?

SirRender00 avatar Mar 10 '22 05:03 SirRender00

Sorry which of those files display abnormal behavior?

I don't think there're any more😂, just sometimes empty pots are added

packetsss avatar Mar 10 '22 05:03 packetsss

Got it haha... if you find a case... just attach it here. Hopefully there's nothing huge then that's blocking you. As a very yucky solution at each step you can run

def cleaner(game):
    pots_to_remove = []
    for i, pot in enumerate(game.pots, 0):
        if pot.get_total_amount() == 0:
            for player in game.players:
                if player.last_pot >= i:
                    player.last_pot -= 1
            pots_to_remove.append(i)

    game.pots = [pot for i, pot in enumerate(game.pots, 0) if i not in pots_to_remove]

SirRender00 avatar Mar 10 '22 05:03 SirRender00

~Once we find a case where there's empty pots we can work on this~ I'll split off a new issue actually and keep this as redefining the raise action https://github.com/SirRender00/texasholdem/issues/40 Once we find a case and a history file of this we can add it to the linked issue. The history file should have the empty pots in it since we do not delete pots at any point

SirRender00 avatar Mar 10 '22 05:03 SirRender00

Ok found a bunch actually, will continue this discussion in the other issue

SirRender00 avatar Mar 10 '22 06:03 SirRender00

  • [x] Rename value to total and deprecate it for 1.0
  • [ ] 1.0 Do the change and fix all the calls

SirRender00 avatar Mar 23 '22 04:03 SirRender00