charleskawczynski / TexasHoldem.jl

A package for simulating multi-player no-limit texas holdem games
MIT License
7 stars 0 forks source link

Sometimes raises are not called #59

Closed charleskawczynski closed 3 years ago

charleskawczynski commented 3 years ago

As of #58, there is a relatively rare bug (1 in ~1000 games?) that is caught from the fuzz tests. Here is the log:

[ Info: ********************************
[ Info: ******************************** Playing Game!
[ Info: ********************************
[ Info: Initial bank roll summary: (200.0, 200.0, 200.0)
[ Info: Bot5050[2] paid the small blind and dealt cards: (J♠, K♠)
[ Info: Bot5050[3] paid the  big  blind and dealt cards: (5♢, 6♢)
[ Info: Bot5050[1] dealt (free) cards:                   (7♣, 7♡)
[ Info: Table cards dealt (face-down).
[ Info: Bot5050[1] called 2.0 (blind).
[ Info: Bot5050[2] called 1.0 (blind).
[ Info: Bot5050[3] checked!
[ Info: Flop:                                              (9♡, 3♢, 4♣)
[ Info: Bot5050[1] checked!
[ Info: Bot5050[2] checked!
[ Info: Bot5050[3] raised to 83.0.
[ Info: Bot5050[1] called 83.0.
[ Info: Bot5050[2] raised to 166.0.
[ Info: Bot5050[3] folded!
[ Info: Turn:                                              J♡
[ Info: Bot5050[1] checked!
[ Info: Bot5050[2] raised to 18.0.
[ Info: Bot5050[1] raised to 61.0.
[ Info: Bot5050[2] called 14.0 (now all-in).
[ Info: River:                                             4♠
Game: Play (3 Bot5050's): Error During Test at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/test/fuzz_play.jl:6
  Got exception outside of a @test
  AssertionError: amt_remaining ≈ 0
  Stacktrace:
   [1] contribute!(::Table, ::Player{Bot5050}, ::Float64, ::Bool) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/transactions.jl:137
   [2] raise_to_valid_raise_amount!(::Table, ::Player{Bot5050}, ::Float64) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/player_actions.jl:186
   [3] raise_to! at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/player_actions.jl:180 [inlined]
   [4] raise_to!(::Game, ::Player{Bot5050}, ::Float64) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/player_actions.jl:178
   [5] player_option!(::Game, ::Player{Bot5050}, ::River, ::CheckRaiseFold) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/player_options.jl:130
   [6] player_option!(::Game, ::Player{Bot5050}) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/player_options.jl:28
   [7] act_generic!(::Game, ::River) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/game.jl:106
   [8] act! at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/game.jl:112 [inlined]
   [9] play(::Game) at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/src/game.jl:149
   [10] top-level scope at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/test/fuzz_play.jl:8
   [11] top-level scope at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Test/src/Test.jl:1113
   [12] top-level scope at /Users/runner/work/TexasHoldem.jl/TexasHoldem.jl/test/fuzz_play.jl:7

It seems that the first issue here is that the Bot5050[2] raise to 166.0. is not called by Bot5050[1]. This demos something we can check for: if all BRs are equal to start, then any all-in should lead to everyone (still playing) being all in.

charleskawczynski commented 3 years ago

Not sure if this is only isolated to tournament! play, introduced in #67, but it seems that this bug has somehow returned:

[ Info: Human[1] called 4.0.
[ Info: River:                                             2♡
Human[1]'s turn to act:
 > Check
   Raise [$1.0, $1.0]
   Fold
[ Info: Human[1] checked!
[ Info: Bot5050[2] raised to 1.0 (all-in).
[ Info: Human[1] wins $195.0 ($98.0 profit) with TwoPair!
[ Info: Final bank roll summary: (200.0, 0.0)

There's probably a simple way to check for this in the transaction manager. It might be good to add a bot test, if easy/possible, to protect against this.

charleskawczynski commented 3 years ago

We should probably fix #72 / #73 first, since these affect flow control and game logic.

charleskawczynski commented 3 years ago

Hmm, raises don't always need to be called, and I'm not seeing this error anymore. Closing for now.

charleskawczynski commented 3 years ago

Okay, okay, there is still a bug. Good news though, I think I have a dev branch where I’m tracking down the problems.

charleskawczynski commented 3 years ago

I think this was closed by #85. We'll reopen if that's not the case.