-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add capability to goto player option
- Loading branch information
1 parent
505a6f3
commit dae85b2
Showing
5 changed files
with
196 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
abstract type AbstractGamePoint end | ||
struct StartOfGame <: AbstractGamePoint end | ||
struct PlayerOption{P, R} <: AbstractGamePoint | ||
player::P | ||
round::R | ||
end | ||
|
||
struct StartFrom{GP} | ||
game_point::GP | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Test | ||
using PlayingCards | ||
using TexasHoldem | ||
import TexasHoldem | ||
const TH = TexasHoldem | ||
|
||
include("tester_bots.jl") | ||
|
||
##### RiverDreamer | ||
mutable struct RiverDreamer <: AbstractStrategy | ||
fixed::Bool | ||
end | ||
|
||
TH.player_option(game::Game, player::Player{RiverDreamer}, ::AGS, ::CheckRaiseFold) = Check() | ||
TH.player_option(game::Game, player::Player{RiverDreamer}, ::AGS, ::CallRaiseFold) = Call(game, player) | ||
TH.player_option(game::Game, player::Player{RiverDreamer}, ::AGS, ::CallAllInFold) = Call(game, player) | ||
TH.player_option(game::Game, player::Player{RiverDreamer}, ::AGS, ::CallFold) = Call(game, player) | ||
|
||
function TH.player_option(game::Game, player::Player{RiverDreamer}, round::River, option::CheckRaiseFold) | ||
if player.strategy.fixed | ||
Check() | ||
else | ||
player.strategy.fixed = true | ||
options = (Check(), Raise(10), Raise(40), Fold()) | ||
rewards = map(options) do option | ||
@info "Recreating game from $option" | ||
rgame = TH.recreate_game(game, player) | ||
sf = TH.StartFrom(TH.PlayerOption(player, round)) | ||
@info "Playing new game" | ||
play!(rgame, sf) | ||
@info "Finished new game" | ||
@info "Computing pidx after new game" | ||
pidx = findfirst(rgame.table.players) do p | ||
TH.seat_number(p) == TH.seat_number(player) | ||
end | ||
@info "Finished computing pidx after new game" | ||
@info "reward: $(rgame.table.players[pidx].game_profit)" | ||
rgame.table.players[pidx].game_profit | ||
end | ||
@show rewards | ||
return Check() | ||
end | ||
end | ||
function TH.player_option(game::Game, player::Player{RiverDreamer}, round::River, option::CallRaiseFold) | ||
@info "Recreating game from $option" | ||
rgame = TH.recreate_game(game, player) | ||
Call(game, player) | ||
end | ||
function TH.player_option(game::Game, player::Player{RiverDreamer}, round::River, option::CallAllInFold) | ||
@info "Recreating game from $option" | ||
rgame = TH.recreate_game(game, player) | ||
Call(game, player) | ||
end | ||
function TH.player_option(game::Game, player::Player{RiverDreamer}, round::River, option::CallFold) | ||
@info "Recreating game from $option" | ||
rgame = TH.recreate_game(game, player) | ||
Call(game, player) | ||
end | ||
|
||
@testset "Game: Play (Bot5050 vs RiverDreamer)" begin | ||
fuzz_bots = ntuple(i->Player(Bot5050(), i), 3) | ||
players = (fuzz_bots..., Player(RiverDreamer(false), length(fuzz_bots)+1)) | ||
play!(Game(players; logger=TH.DebugLogger())) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters