Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The way raise is defined is troublesome #39

Open
packetsss opened this issue Mar 10, 2022 · 16 comments
Open

The way raise is defined is troublesome #39

packetsss opened this issue Mar 10, 2022 · 16 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@packetsss
Copy link

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 packetsss changed the title The way you define raise is not intuitive The way raise is defined is troublesome Mar 10, 2022
@SirRender00
Copy link
Owner

SirRender00 commented Mar 10, 2022

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
Copy link
Owner

SirRender00 commented Mar 10, 2022

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 SirRender00 added the enhancement New feature or request label Mar 10, 2022
@SirRender00 SirRender00 added this to the v1.0.0 milestone Mar 10, 2022
@packetsss
Copy link
Author

packetsss commented Mar 10, 2022

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

@SirRender00 SirRender00 added the bug Something isn't working label Mar 10, 2022
@SirRender00
Copy link
Owner

SirRender00 commented Mar 10, 2022

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

@packetsss
Copy link
Author

The latest version

@SirRender00
Copy link
Owner

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
Copy link
Owner

SirRender00 commented Mar 10, 2022

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:

if PlayerState.ALL_IN in (self.players[i].state
for i in self._get_pot(last_pot).players_in_pot()):
raised_level = min(self._get_pot(last_pot).get_player_amount(i)
for i in self._get_pot(last_pot).players_in_pot()
if self.players[i].state == PlayerState.ALL_IN)
self._split_pot(last_pot, raised_level)

@SirRender00
Copy link
Owner

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.

@packetsss
Copy link
Author

packetsss commented Mar 10, 2022

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
Copy link
Author

packetsss commented Mar 10, 2022

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

@SirRender00
Copy link
Owner

Sorry which of those files display abnormal behavior?

@packetsss
Copy link
Author

Sorry which of those files display abnormal behavior?

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

@SirRender00
Copy link
Owner

SirRender00 commented Mar 10, 2022

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
Copy link
Owner

SirRender00 commented Mar 10, 2022

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 #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 SirRender00 removed the bug Something isn't working label Mar 10, 2022
@SirRender00
Copy link
Owner

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

@SirRender00
Copy link
Owner

SirRender00 commented Mar 23, 2022

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

@SirRender00 SirRender00 self-assigned this Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants