C# Class GR.Gambling.Backgammon.Tools.GnuBg

Show file Open project: alexhanh/Botting-Library Class Usage Examples

Public Methods

Method Description
BoardFromPositionID ( string position_id, string &error ) : Board
BoolListToInt ( IEnumerable bools ) : int
Command ( string s ) : string

Sends a command to the gnubg and returns gnubg's response.

DoubleHint ( GameState gamestate ) : DoubleHint
DoubleResponseHint ( GameState gamestate ) : DoubleResponseHint
Eval ( GameState gamestate ) : EvaluationInfo
Exit ( ) : void

Tries to close the gnubg process the "natural" way by using the exit command. If it doesn't exit in max 3000(ms), it kills the running process.

GnuBGIDToGameState ( string gnubg_id, string &error ) : GameState
GnuBg ( string path ) : System
Hint ( GameState gamestate ) : string
MatchID ( GameState gamestate ) : string

TODO: Solve the "I'm sorry, but SetMatchID cannot handle positions where a double has been offered" bullshit.

PlayHint ( GameState gamestate, int max_hints ) : List

Assumes dice have been rolled and game is still going.

PlayHint ( GameState gamestate ) : PlayHint
ResignResponseHint ( GameState gamestate ) : ResignResponseHint
SetGameState ( GameState gamestate ) : void

Doesn't use the match id for setting up the position.

Start ( ) : void
ToPositionID ( Board board, int player_on_roll ) : string

Private Methods

Method Description
GetDoubleHint ( GameState gamestate ) : DoubleHint
MatchID ( int die1, int die2, int turn, int resigned, int doubled, int move, int cube_owner, int crawford, int match_to, int score1, int score2, int cube, int gamestate ) : string
ParseDoubleAction ( string hint ) : DoubleAction
ParseDoubleResponse ( string hint ) : DoubleResponseHint
ParseMoveHint ( string move_string, int &count, int total_hints, int dice, GameState gamestate ) : Move
ParseMoveHints ( string hints, int dice, GameState gamestate ) : List
ParseResignResponse ( string hint ) : ResignResponseHint
Set0PlyEvaluation ( ) : void
Set0PlyEvaluation ( double noise ) : void
Set2PlyEvaluation ( ) : void
SetBoardSimple ( GameState gamestate ) : void

Gnubg treats positive counts as for the player on turn, and negative for the other. The first slot is the captured count for the player on turn, last slot is for the capture count of the other. Gnubg calculates the finished pieces for both players automatically. 26 integers are represented the following way: #Captured count for the player on roll# #Slot 1# ... #Slot 24# #Captured count for the other player# The slots start from the home board of the player on roll.

SetOptions ( ) : void

Method Details

BoardFromPositionID() public static method

public static BoardFromPositionID ( string position_id, string &error ) : Board
position_id string
error string
return GR.Gambling.Backgammon.Board

BoolListToInt() public static method

public static BoolListToInt ( IEnumerable bools ) : int
bools IEnumerable
return int

Command() public method

Sends a command to the gnubg and returns gnubg's response.
public Command ( string s ) : string
s string
return string

DoubleHint() public method

public DoubleHint ( GameState gamestate ) : DoubleHint
gamestate GR.Gambling.Backgammon.GameState
return DoubleHint

DoubleResponseHint() public method

public DoubleResponseHint ( GameState gamestate ) : DoubleResponseHint
gamestate GR.Gambling.Backgammon.GameState
return DoubleResponseHint

Eval() public method

public Eval ( GameState gamestate ) : EvaluationInfo
gamestate GR.Gambling.Backgammon.GameState
return EvaluationInfo

Exit() public method

Tries to close the gnubg process the "natural" way by using the exit command. If it doesn't exit in max 3000(ms), it kills the running process.
public Exit ( ) : void
return void

GnuBGIDToGameState() public static method

public static GnuBGIDToGameState ( string gnubg_id, string &error ) : GameState
gnubg_id string
error string
return GR.Gambling.Backgammon.GameState

GnuBg() public method

public GnuBg ( string path ) : System
path string
return System

Hint() public method

public Hint ( GameState gamestate ) : string
gamestate GR.Gambling.Backgammon.GameState
return string

MatchID() public static method

TODO: Solve the "I'm sorry, but SetMatchID cannot handle positions where a double has been offered" bullshit.
public static MatchID ( GameState gamestate ) : string
gamestate GR.Gambling.Backgammon.GameState
return string

PlayHint() public method

Assumes dice have been rolled and game is still going.
public PlayHint ( GameState gamestate, int max_hints ) : List
gamestate GR.Gambling.Backgammon.GameState
max_hints int
return List

PlayHint() public method

public PlayHint ( GameState gamestate ) : PlayHint
gamestate GR.Gambling.Backgammon.GameState
return PlayHint

ResignResponseHint() public method

public ResignResponseHint ( GameState gamestate ) : ResignResponseHint
gamestate GR.Gambling.Backgammon.GameState
return ResignResponseHint

SetGameState() public method

Doesn't use the match id for setting up the position.
public SetGameState ( GameState gamestate ) : void
gamestate GR.Gambling.Backgammon.GameState
return void

Start() public method

public Start ( ) : void
return void

ToPositionID() public static method

public static ToPositionID ( Board board, int player_on_roll ) : string
board GR.Gambling.Backgammon.Board
player_on_roll int
return string