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

universal poker half-pot abstraction: half-pot action is always considered legal even when it shouldn't be? #1042

Closed
VitamintK opened this issue Mar 21, 2023 · 5 comments
Labels
bug Something isn't working contribution welcome It's a nice feature! But we do not have the time to do it ourselves. Contribution welcomed!

Comments

@VitamintK
Copy link
Contributor

VitamintK commented Mar 21, 2023

>>>  game = pyspiel.load_game('universal_poker', {'bettingAbstraction': 'fchpa'})
>>> s = game.new_initial_state().child(3).child(7).child(2).child(2)
>>> print(s)
BettingAbstration: FCPHA
P0 Cards: 2s
P1 Cards: 3s
BoardCards 
Node type?: Player node for player 0
]
Round: 0
ACPC State: STATE:0:r300r900:2s|3s
Spent: [P0: 300  P1: 900  ]

Action Sequence: ddpp
>>> s.legal_actions()
[0, 1, 3, 4]
>>> s.child(4)
SpielError: open_spiel/open_spiel/games/universal_poker/acpc_cpp/acpc_game.cc:225 CHECK_TRUE(project_acpc_server::isValidAction(game_->MutableGame(), &acpcState_, false, &a))

In universal_poker.cc, the "half-pot bet" action (action 4) is always added, without checking to see if it's legal (and even in a terminal state). In contrast, the "pot bet" action (action 2) is added only when it is legal: this is determined by the possibleActions_ attribute, which is set in _CalculateActionsAndNodeType.

I guess the fix here would be to add the half-pot action to possibleActions_, and to set it in _CalculateActionsAndNodeType if using the FCPHA abstraction and the half-pot action should be legal.

@lanctot
Copy link
Collaborator

lanctot commented Mar 21, 2023

Thanks, just tagging @jhtschultz @jblespiau for a heads up.

@jhtschultz
Copy link
Member

Another good catch. That does sound like a sensible fix. If you get to implementing it before we do it would be a welcome contribution :)

@lanctot lanctot added the contribution welcome It's a nice feature! But we do not have the time to do it ourselves. Contribution welcomed! label Apr 18, 2023
@lanctot lanctot added the bug Something isn't working label Dec 26, 2023
@lanctot
Copy link
Collaborator

lanctot commented Dec 26, 2023

@VitamintK did you ever fix this ?

With the outstanding bugs in universal_poker.. I am wondering if we should consider removing the game unless we can fix these issues. It might be more prudent than leaving buggy games in the code base.

@lanctot
Copy link
Collaborator

lanctot commented Dec 26, 2023

Actually, I think I have a better solution for games in this category: #1163 (and #1162)

@lanctot
Copy link
Collaborator

lanctot commented Mar 14, 2024

Fixed by dee65f9

@lanctot lanctot closed this as completed Mar 14, 2024
Drazcmd referenced this issue Mar 14, 2024
…t for half-pot bets

Fixes: 1042.

Previously the code would just always considers half-pot bets valid when in kFCHPA mode. Now we do the same thing as with pot bets - first we check whether betting *anything* is allowed first by comparing against possibleActions_.

(Side note: the std::find-s in the tests are more for readability+clarity. Given we immediately do an exact match on the entire legal_actions vectors right below they're technically redundant.)

PiperOrigin-RevId: 615492268
Change-Id: I72da0b9f801b73c6aa32766ca7ec3358ca171d30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contribution welcome It's a nice feature! But we do not have the time to do it ourselves. Contribution welcomed!
Projects
None yet
Development

No branches or pull requests

3 participants