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

Type hint, add debug statements #160

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/TexasHoldem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ A no-limit Texas Holdem simulator.
module TexasHoldem

using PlayingCards
using PlayingCards: Card
using PokerHandEvaluator
using Printf

Expand Down
5 changes: 5 additions & 0 deletions src/game.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@
@cdebug logger "initial_brs = $(initial_brs)"
@cdebug logger "bank_roll.(players_at_table(table)) = $(bank_roll.(players_at_table(table)))"

@cdebug logger begin
if !(initial_∑brs ≈ sum(x->bank_roll(x), players_at_table(table)))
@cinfo logger "initial_∑brs=$initial_∑brs, brs=$(bank_roll.(players_at_table(table)))"

Check warning on line 245 in src/game.jl

View check run for this annotation

Codecov / codecov/patch

src/game.jl#L244-L245

Added lines #L244 - L245 were not covered by tests
end
end
@assert initial_∑brs ≈ sum(x->bank_roll(x), players_at_table(table)) # eventual assertion
@assert sum(sp->amount(sp), table.transactions.side_pots) ≈ 0

Expand Down
5 changes: 3 additions & 2 deletions src/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function deal!(table::Table, blinds::Blinds)

not_playing(player) && continue

player.cards = pop!(table.deck, Val(2))
player.cards = pop!(table.deck, Val(2))::Tuple{Card, Card}

if is_small_blind(table, player) && bank_roll(player) ≤ blinds.small
contribute!(table, player, bank_roll(player), call_blinds)
Expand All @@ -480,7 +480,8 @@ function deal!(table::Table, blinds::Blinds)
end
end

table.cards = get_table_cards!(table.deck)
table.cards = get_table_cards!(table.deck)::Tuple{Card,Card,Card,Card,Card}
@cinfo logger "Table cards dealt (face-down)."
@cdebug logger "Post-blinds bank roll summary: $(bank_roll.(players))"
end

Loading