C# Класс GR.Gambling.Backgammon.Board

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
Recursion ( int player, List free_dice, Board board, List moves_made, List &plays, List &partial_plays, HashSet &board_hash ) : void

Описание методов

AddToPoint() публичный Метод

public AddToPoint ( int player, int point, int count ) : void
player int
point int
count int
Результат void

Board() публичный Метод

public Board ( ) : System
Результат System

Board() публичный Метод

Deep-copy constructor.
public Board ( Board board ) : System
board Board
Результат System

BoardRelativeTo() публичный Метод

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
Результат int[]

CapturedCount() публичный Метод

public CapturedCount ( int player ) : int
player int
Результат int

Clone() публичный Метод

Creates a deep-copy of this board.
public Clone ( ) : Board
Результат Board

DecreaseCaptured() публичный Метод

public DecreaseCaptured ( int player ) : void
player int
Результат void

DecreaseFinished() публичный Метод

public DecreaseFinished ( int player ) : void
player int
Результат void

Deserialize() публичный статический Метод

public static Deserialize ( string s ) : Board
s string
Результат Board

Empty() публичный Метод

public Empty ( ) : void
Результат void

EmptyPoint() публичный Метод

public EmptyPoint ( int player, int point ) : void
player int
point int
Результат void

Equals() публичный Метод

public Equals ( Board board ) : bool
board Board
Результат bool

FinishedCount() публичный Метод

public FinishedCount ( int player ) : int
player int
Результат int

ForcedMoves() публичный статический Метод

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
Результат List

HashString() публичный Метод

Provides a unique hash string for each different board position.
public HashString ( ) : string
Результат string

IncreaseCaptured() публичный Метод

public IncreaseCaptured ( int player ) : void
player int
Результат void

IncreaseCaptured() публичный Метод

public IncreaseCaptured ( int player, int count ) : void
player int
count int
Результат void

IncreaseFinished() публичный Метод

public IncreaseFinished ( int player ) : void
player int
Результат void

IncreaseFinished() публичный Метод

public IncreaseFinished ( int player, int count ) : void
player int
count int
Результат void

InitializeBoard() публичный Метод

public InitializeBoard ( BackgammonVariation variation ) : void
variation BackgammonVariation
Результат void

IsBearoff() публичный Метод

Returns true if player's all chequers are on his home board and is bearing off.
public IsBearoff ( int player ) : bool
player int
Результат bool

IsLegal() публичный Метод

public IsLegal ( ) : bool
Результат bool

IsLegalMove() публичный Метод

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.
Результат bool

IsPureRace() публичный Метод

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
Результат bool

IsStartingPosition() публичный Метод

public IsStartingPosition ( BackgammonVariation variation ) : bool
variation BackgammonVariation
Результат bool

LastChequer() публичный Метод

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
Результат int

LegalPlays() публичный Метод

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
Результат List

MakeMove() публичный Метод

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
Результат void

MakeMoves() публичный Метод

public MakeMoves ( int player, IEnumerable moves ) : void
player int
moves IEnumerable
Результат void

MakePlay() публичный Метод

public MakePlay ( int player, Play play ) : void
player int
play Play
Результат void

PipCount() публичный Метод

public PipCount ( int player ) : int
player int
Результат int

PointCount() публичный Метод

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
Результат int

RemoveFromPoint() публичный Метод

public RemoveFromPoint ( int player, int point, int count ) : void
player int
point int
count int
Результат void

ResignationValue() публичный Метод

Returns the current resign value for the player based on the last chequer's position.
public ResignationValue ( int player ) : ResignValue
player int
Результат ResignValue

Serialize() публичный статический Метод

public static Serialize ( Board board ) : string
board Board
Результат string

SetCaptured() публичный Метод

public SetCaptured ( int player, int count ) : void
player int
count int
Результат void

SetFinished() публичный Метод

public SetFinished ( int player, int count ) : void
player int
count int
Результат void

SetPoint() публичный Метод

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.
Результат void

ToString() публичный Метод

public ToString ( ) : string
Результат string

ToString() публичный Метод

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
Результат string

UndoMove() публичный Метод

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
Результат void

UndoPlay() публичный Метод

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.
Результат void