Event codes

If you're training a neural net using TexasHoldem.jl, then you may need a lossless game log. Here is an example of how you can enable the event code logging, which will result in collected event codes during game play.

import TexasHoldem as TH
struct MyBot <: TH.AbstractStrategy end

function TH.get_action(game::TH.Game, player::TH.Player{MyBot}, options::TH.Options)
    if options == TH.CheckRaiseFold
        rand() < 0.5 && return TH.RaiseTo(game, rand(TH.valid_total_bet_range(game)))
        return TH.Check()
        # return TH.Fold() # we can fold, but we can check for free
    elseif options == TH.CallRaiseFold
        rand() < 0.5 && return TH.Call(game)
        rand() < 0.5 && return TH.RaiseTo(game, rand(TH.valid_total_bet_range(game)))
        return TH.Fold()
    elseif options == TH.CallAllInFold
        rand() < 0.5 && return TH.Call(game)
        rand() < 0.5 && return TH.AllIn(game)
        return TH.Fold()
    else
        @assert options == TH.CallFold
        rand() < 0.5 && return TH.Call(game)
        return TH.Fold()
    end
end

import Logging
players = (TH.Player(TH.Human(), 1), TH.Player(MyBot(), 2));

## Critical part:
game = TH.Game(
	players;
	gui=TH.NoGUI(),
	logger=TH.InfoLogger(;
		msg_collector = TH.HumanReadableMessageCollector(Logging.Info; send_to_stdout=false, prepend_msg="GAME_LOG: "),
		event_code_collector = TH.EventCodeCollector(Logging.Info; send_to_stdout=true, prepend_msg="EVENT_CODE: ")
	)
)
TH.tournament!(game)

1. Primary Event Codes

This table defines the main events that structure the game log. A log is a Vector{Vector{Int}}.

Event CodeEvent NameFormat [CODE, ...]Description
-1Player Stack[-1, player_seat, stack_size]Sets the starting stack for a player.
-2Set Blinds[-2, button_seat, sb_amt, bb_amt]Defines the blinds and button for the hand.
-3Deal Hole Cards[-3, player_seat, card_1, card_2]Deals two private cards to a player.
-4Player Action[-4, player_seat, action_code, amount]A player takes a betting action.
-5Deal Flop[-5, card_1, card_2, card_3]Deals the three flop cards.
-6Deal Turn[-6, card_1]Deals the single turn card.
-7Deal River[-7, card_1]Deals the single river card.
-8Winnings[-8, player_seat, amount_won]A player wins an amount from the pot.

2. Action Codes (for Event -4)

This table defines the action_code used in the [-4, player_seat, action_code, amount] event.

Action CodeAction Nameamount in [-4, ...]
1Fold0
2Check0
3CallThe total amount called (e.g., 2).
4Raise ToThe total amount of the bet (e.g., 6).
5All-InThe total amount of the all-in bet.