C# Class GR.Gambling.Backgammon.Board

Exibir arquivo Open project: alexhanh/Botting-Library Class Usage Examples

Public Methods

Method Description
AddToPoint ( int player, int point, int count ) : void
Board ( ) : System
Board ( Board board ) : System

Deep-copy constructor.

BoardRelativeTo ( int player ) : int[]

Returns the board relative to the player, so that the slots 0-5 match the player's home board. Negative counts indicate opponents checkers.

CapturedCount ( int player ) : int
Clone ( ) : Board

Creates a deep-copy of this board.

DecreaseCaptured ( int player ) : void
DecreaseFinished ( int player ) : void
Deserialize ( string s ) : Board
Empty ( ) : void
EmptyPoint ( int player, int point ) : void
Equals ( Board board ) : bool
FinishedCount ( int player ) : int
ForcedMoves ( List legal_move_sequences ) : List

A move is a forced move if it must be made before other moves and every move hint share the same forced move.

HashString ( ) : string

Provides a unique hash string for each different board position.

IncreaseCaptured ( int player ) : void
IncreaseCaptured ( int player, int count ) : void
IncreaseFinished ( int player ) : void
IncreaseFinished ( int player, int count ) : void
InitializeBoard ( BackgammonVariation variation ) : void
IsBearoff ( int player ) : bool

Returns true if player's all chequers are on his home board and is bearing off.

IsLegal ( ) : bool
IsLegalMove ( int player, Move move, int die ) : bool

Returns if the given move for the given player is a valid move.

IsPureRace ( ) : bool

Returns true if both player's checkers have "passed" each others so that it's impossible to hit or block anymore. Source: http://www.bkgm.com/gloss/lookup.cgi?pure+race

IsStartingPosition ( BackgammonVariation variation ) : bool
LastChequer ( int player ) : int

Returns the point of the last chequer of the player from the player's perspective. Returns 24 for captured and -1 if all checkers have been bearoffed.

LegalPlays ( int player, int dice ) : List

This returns all the possible legal moves for the player with given dice. It sorts the dice from highest to lowest, so it produces same results regardless of the dice order. It also finds correctly moves according to following rules: "For any roll, if a player can move both dice, that player is compelled to do so. If it is possible to move either die, but not both, the higher number must be played. Further, if one die is unable to be moved, but such a move is made possible by the moving of the other die, that move is compulsory." Source: http://en.wikipedia.org/wiki/Backgammon

MakeMove ( int player, Move move ) : void

Applys a given move to this board. This method assumes the move is valid.

MakeMoves ( int player, IEnumerable moves ) : void
MakePlay ( int player, Play play ) : void
PipCount ( int player ) : int
PointCount ( int player, int point ) : int

Returns the count of this player's perspective. Count is negative if opponent has checkers on the given slot.

RemoveFromPoint ( int player, int point, int count ) : void
ResignationValue ( int player ) : ResignValue

Returns the current resign value for the player based on the last chequer's position.

Serialize ( Board board ) : string
SetCaptured ( int player, int count ) : void
SetFinished ( int player, int count ) : void
SetPoint ( int player, int point, int count ) : void

Sets the given slot to count from player's perspective.

ToString ( ) : string
ToString ( int player ) : string

Gnubg style rendering of the board from the perspective of player. X is always the player's checkers, O opponent's.

UndoMove ( int player, Move move ) : void

Reverses a given move that was made. Notice that if you are reversing a made move sequence, you need to do it in reverse order, that is, undo the last made move first, then the second last, and so on.

UndoPlay ( int player, Play play ) : void

Private Methods

Method Description
Recursion ( int player, List free_dice, Board board, List moves_made, List &plays, List &partial_plays, HashSet &board_hash ) : void

Method Details

AddToPoint() public method

public AddToPoint ( int player, int point, int count ) : void
player int
point int
count int
return void

Board() public method

public Board ( ) : System
return System

Board() public method

Deep-copy constructor.
public Board ( Board board ) : System
board Board
return System

BoardRelativeTo() public method

Returns the board relative to the player, so that the slots 0-5 match the player's home board. Negative counts indicate opponents checkers.
public BoardRelativeTo ( int player ) : int[]
player int
return int[]

CapturedCount() public method

public CapturedCount ( int player ) : int
player int
return int

Clone() public method

Creates a deep-copy of this board.
public Clone ( ) : Board
return Board

DecreaseCaptured() public method

public DecreaseCaptured ( int player ) : void
player int
return void

DecreaseFinished() public method

public DecreaseFinished ( int player ) : void
player int
return void

Deserialize() public static method

public static Deserialize ( string s ) : Board
s string
return Board

Empty() public method

public Empty ( ) : void
return void

EmptyPoint() public method

public EmptyPoint ( int player, int point ) : void
player int
point int
return void

Equals() public method

public Equals ( Board board ) : bool
board Board
return bool

FinishedCount() public method

public FinishedCount ( int player ) : int
player int
return int

ForcedMoves() public static method

A move is a forced move if it must be made before other moves and every move hint share the same forced move.
public static ForcedMoves ( List legal_move_sequences ) : List
legal_move_sequences List
return List

HashString() public method

Provides a unique hash string for each different board position.
public HashString ( ) : string
return string

IncreaseCaptured() public method

public IncreaseCaptured ( int player ) : void
player int
return void

IncreaseCaptured() public method

public IncreaseCaptured ( int player, int count ) : void
player int
count int
return void

IncreaseFinished() public method

public IncreaseFinished ( int player ) : void
player int
return void

IncreaseFinished() public method

public IncreaseFinished ( int player, int count ) : void
player int
count int
return void

InitializeBoard() public method

public InitializeBoard ( BackgammonVariation variation ) : void
variation BackgammonVariation
return void

IsBearoff() public method

Returns true if player's all chequers are on his home board and is bearing off.
public IsBearoff ( int player ) : bool
player int
return bool

IsLegal() public method

public IsLegal ( ) : bool
return bool

IsLegalMove() public method

Returns if the given move for the given player is a valid move.
public IsLegalMove ( int player, Move move, int die ) : bool
player int The player for whom the move is made.
move Move The move to be made, slot indices must be relative to the player making the move.
die int The die with which the move is made.
return bool

IsPureRace() public method

Returns true if both player's checkers have "passed" each others so that it's impossible to hit or block anymore. Source: http://www.bkgm.com/gloss/lookup.cgi?pure+race
public IsPureRace ( ) : bool
return bool

IsStartingPosition() public method

public IsStartingPosition ( BackgammonVariation variation ) : bool
variation BackgammonVariation
return bool

LastChequer() public method

Returns the point of the last chequer of the player from the player's perspective. Returns 24 for captured and -1 if all checkers have been bearoffed.
public LastChequer ( int player ) : int
player int
return int

LegalPlays() public method

This returns all the possible legal moves for the player with given dice. It sorts the dice from highest to lowest, so it produces same results regardless of the dice order. It also finds correctly moves according to following rules: "For any roll, if a player can move both dice, that player is compelled to do so. If it is possible to move either die, but not both, the higher number must be played. Further, if one die is unable to be moved, but such a move is made possible by the moving of the other die, that move is compulsory." Source: http://en.wikipedia.org/wiki/Backgammon
public LegalPlays ( int player, int dice ) : List
player int
dice int
return List

MakeMove() public method

Applys a given move to this board. This method assumes the move is valid.
public MakeMove ( int player, Move move ) : void
player int
move Move
return void

MakeMoves() public method

public MakeMoves ( int player, IEnumerable moves ) : void
player int
moves IEnumerable
return void

MakePlay() public method

public MakePlay ( int player, Play play ) : void
player int
play Play
return void

PipCount() public method

public PipCount ( int player ) : int
player int
return int

PointCount() public method

Returns the count of this player's perspective. Count is negative if opponent has checkers on the given slot.
public PointCount ( int player, int point ) : int
player int Relative player from whos perspective the query is made.
point int
return int

RemoveFromPoint() public method

public RemoveFromPoint ( int player, int point, int count ) : void
player int
point int
count int
return void

ResignationValue() public method

Returns the current resign value for the player based on the last chequer's position.
public ResignationValue ( int player ) : ResignValue
player int
return ResignValue

Serialize() public static method

public static Serialize ( Board board ) : string
board Board
return string

SetCaptured() public method

public SetCaptured ( int player, int count ) : void
player int
count int
return void

SetFinished() public method

public SetFinished ( int player, int count ) : void
player int
count int
return void

SetPoint() public method

Sets the given slot to count from player's perspective.
public SetPoint ( int player, int point, int count ) : void
player int The player from whose perspective the slot is mapped.
point int
count int Positive count is for the player, negative for the opponent. Zero count empties the slot for both players.
return void

ToString() public method

public ToString ( ) : string
return string

ToString() public method

Gnubg style rendering of the board from the perspective of player. X is always the player's checkers, O opponent's.
public ToString ( int player ) : string
player int
return string

UndoMove() public method

Reverses a given move that was made. Notice that if you are reversing a made move sequence, you need to do it in reverse order, that is, undo the last made move first, then the second last, and so on.
public UndoMove ( int player, Move move ) : void
player int
move Move
return void

UndoPlay() public method

public UndoPlay ( int player, Play play ) : void
player int
play Play The play in which moves are in the order they were applied to the board and not reversed.
return void