Skip to content

Commit

Permalink
Avoid materializing, more concrete types
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Jul 17, 2023
1 parent 3bd0040 commit d9c12f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/game.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function end_of_actions(table::Table, player)
case_3 = all_playing_all_in(table)
case_4 = all_all_in_except_bank_roll_leader(table)
case_5 = all_all_in_or_checked(table) # TODO: likely replaceable with case_6
case_6 = !any(action_required.(players))
case_6 = !any(x->action_required(x), players)
case_7 = all_oppononents_all_in(table, player) && paid_current_raise_amount(table, player)
@cdebug logger " cases = $((case_1, case_2, case_3, case_4, case_5, case_6, case_7))"

Expand Down
7 changes: 4 additions & 3 deletions src/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ buttons(b::Buttons) = (
b.first_to_act,
)

mutable struct Table{P<:Players, L, TM}
mutable struct Table{P<:Players, L, TM, B <: Blinds}
deck::PlayingCards.Deck
players::P
cards::Union{Nothing,Tuple{<:Card,<:Card,<:Card,<:Card,<:Card}}
blinds::Blinds
blinds::B
pot::Float64
state::AbstractGameState
buttons::Buttons
Expand Down Expand Up @@ -117,7 +117,8 @@ function Table(players::Players;
@cdebug logger "n_max_actions = $n_max_actions"
L = typeof(logger)
TM = typeof(transactions)
return Table{P, L, TM}(deck,
B = typeof(blinds)
return Table{P, L, TM, B}(deck,
players,
cards,
blinds,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end
function distribute_winnings!(players, tm::TransactionManager, table_cards, logger=StandardLogger())
@cdebug logger "Distributing winnings..."
@cdebug logger "Pot amounts = $(amount.(tm.side_pots))"
if count(still_playing.(players)) == 1
if count(x->still_playing(x), players) == 1
return distribute_winnings_1_player_left!(players, tm, table_cards, logger)
end
hand_evals_sorted = map(enumerate(tm.sorted_players)) do (ssn, player)
Expand Down

0 comments on commit d9c12f4

Please sign in to comment.