C# Class GR.Gambling.Backgammon.Board

Afficher le fichier Open project: alexhanh/Botting-Library Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

public AddToPoint ( int player, int point, int count ) : void
player int
point int
count int
Résultat void

Board() public méthode

public Board ( ) : System
Résultat System

Board() public méthode

Deep-copy constructor.
public Board ( Board board ) : System
board Board
Résultat System

BoardRelativeTo() public méthode

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
Résultat int[]

CapturedCount() public méthode

public CapturedCount ( int player ) : int
player int
Résultat int

Clone() public méthode

Creates a deep-copy of this board.
public Clone ( ) : Board
Résultat Board

DecreaseCaptured() public méthode

public DecreaseCaptured ( int player ) : void
player int
Résultat void

DecreaseFinished() public méthode

public DecreaseFinished ( int player ) : void
player int
Résultat void

Deserialize() public static méthode

public static Deserialize ( string s ) : Board
s string
Résultat Board

Empty() public méthode

public Empty ( ) : void
Résultat void

EmptyPoint() public méthode

public EmptyPoint ( int player, int point ) : void
player int
point int
Résultat void

Equals() public méthode

public Equals ( Board board ) : bool
board Board
Résultat bool

FinishedCount() public méthode

public FinishedCount ( int player ) : int
player int
Résultat int

ForcedMoves() public static méthode

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
Résultat List

HashString() public méthode

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

IncreaseCaptured() public méthode

public IncreaseCaptured ( int player ) : void
player int
Résultat void

IncreaseCaptured() public méthode

public IncreaseCaptured ( int player, int count ) : void
player int
count int
Résultat void

IncreaseFinished() public méthode

public IncreaseFinished ( int player ) : void
player int
Résultat void

IncreaseFinished() public méthode

public IncreaseFinished ( int player, int count ) : void
player int
count int
Résultat void

InitializeBoard() public méthode

public InitializeBoard ( BackgammonVariation variation ) : void
variation BackgammonVariation
Résultat void

IsBearoff() public méthode

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

IsLegal() public méthode

public IsLegal ( ) : bool
Résultat bool

IsLegalMove() public méthode

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.
Résultat bool

IsPureRace() public méthode

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
Résultat bool

IsStartingPosition() public méthode

public IsStartingPosition ( BackgammonVariation variation ) : bool
variation BackgammonVariation
Résultat bool

LastChequer() public méthode

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
Résultat int

LegalPlays() public méthode

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
Résultat List

MakeMove() public méthode

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
Résultat void

MakeMoves() public méthode

public MakeMoves ( int player, IEnumerable moves ) : void
player int
moves IEnumerable
Résultat void

MakePlay() public méthode

public MakePlay ( int player, Play play ) : void
player int
play Play
Résultat void

PipCount() public méthode

public PipCount ( int player ) : int
player int
Résultat int

PointCount() public méthode

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
Résultat int

RemoveFromPoint() public méthode

public RemoveFromPoint ( int player, int point, int count ) : void
player int
point int
count int
Résultat void

ResignationValue() public méthode

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

Serialize() public static méthode

public static Serialize ( Board board ) : string
board Board
Résultat string

SetCaptured() public méthode

public SetCaptured ( int player, int count ) : void
player int
count int
Résultat void

SetFinished() public méthode

public SetFinished ( int player, int count ) : void
player int
count int
Résultat void

SetPoint() public méthode

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.
Résultat void

ToString() public méthode

public ToString ( ) : string
Résultat string

ToString() public méthode

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
Résultat string

UndoMove() public méthode

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
Résultat void

UndoPlay() public méthode

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.
Résultat void