From 15ee9fbbede28b73d74fe6bf918b7f25e4d1ed9b Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Mon, 28 Aug 2023 09:00:15 -0700 Subject: [PATCH 1/2] Make defining seat number optional --- src/player_type.jl | 2 +- src/players.jl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/player_type.jl b/src/player_type.jl index 285b022f..d0b577f0 100644 --- a/src/player_type.jl +++ b/src/player_type.jl @@ -70,7 +70,7 @@ function Base.show(io::IO, player::Player) print(io, "$(name(player)): $(player.cards)") end -function Player(strategy, seat_number, cards = nothing; bank_roll = 200) +function Player(strategy, seat_number = -1, cards = nothing; bank_roll = 200) action_required = true all_in = false round_bank_roll = bank_roll diff --git a/src/players.jl b/src/players.jl index 850dcd1e..9efaf1da 100644 --- a/src/players.jl +++ b/src/players.jl @@ -34,10 +34,17 @@ coincide. struct Players{PS<:Union{Tuple,AbstractArray}} players::PS function Players(players) + n = length(players) + if all(x->seat_number(x)==-1, players) + for i in 1:n + players[i].seat_number = i + end + end @assert allunique(map(x->seat_number(x), players)) spbsn = sortperm_by_seat_number(players) splayers = map(sp->players[sp], spbsn) @assert issorted(map(x->seat_number(x), splayers)) + @assert seat_number(splayers[n]) ≤ n return new{typeof(splayers)}(splayers) end end From 920acdfdf8c102ad7941614026f6e2fecb4ac0ee Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Mon, 28 Aug 2023 21:31:20 -0700 Subject: [PATCH 2/2] Bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 42a5febe..49a7578b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TexasHoldem" uuid = "6cef90fc-eb55-4a2a-97d0-7ecce2b738fe" authors = ["Charles Kawczynski "] -version = "0.4.1" +version = "0.4.2" [deps] Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"