Class Game
- Namespace
- WeiqiSharp.Core
- Assembly
- WeiqiSharp.Core.dll
Represents a current game state, including a history of the board state.
public sealed class Game
- Inheritance
-
Game
- Inherited Members
Constructors
Game(int, bool)
Represents a current game state, including a history of the board state.
public Game(int size, bool analysis)
Parameters
sizeintThe size of the game's Board in a single dimension.
analysisboolWhether this is an analysis game, thus allowing undos.
Properties
Analysis
Whether the game is in analysis mode.
public bool Analysis { get; }
Property Value
CurrentBoard
The current board.
public Board CurrentBoard { get; }
Property Value
Remarks
This is a copy of the board, not the actual backing state of the game.
CurrentState
A simple representation of the board state.
public SpaceState[,] CurrentState { get; }
Property Value
- SpaceState[,]
GameOver
Whether the game is considered over.
public bool GameOver { get; }
Property Value
WhoseTurn
The color whose stone will be placed with the next move.
public SpaceState WhoseTurn { get; }
Property Value
Methods
IsMoveValid(Move)
Checks whether a move is valid given the full state of the game.
public bool IsMoveValid(Move move)
Parameters
moveMoveThe full move which will be tested.
Returns
- bool
trueif the move is valid,falseotherwise.
Remarks
This accounts for ko and for suicide rules.
MakeMoveWithGtp(string)
Attempts to make a move using a GTP string.
public (bool success, int numStonesCaptured) MakeMoveWithGtp(string gtp)
Parameters
gtpstringA GTP string to test.
Returns
- (bool success, int numStonesCaptured)
trueif the move was legal,falseotherwise, and the number of stones captured during the move.
Pass()
Pass for the current color.
public bool Pass()
Returns
- bool
trueif the move was successful (will always be true if the game is not over).
RedoMove()
Moves forward one board state from the redo buffer. Will not work if not in Analysis mode.
public bool RedoMove()
Returns
- bool
trueif there was a board state in the redo buffer,falseotherwise, or if not in analysis mode.
TryMakeMove(Move)
Tried to make a move in the game. The piece will be chosen based on the game state.
This can be used to gauge the strength of a move.
Clears the redo buffer
public (bool success, int numStonesCaptured) TryMakeMove(Move move)
Parameters
moveMoveThe move to try to play on the board
Returns
- (bool success, int numStonesCaptured)
trueif the move was legal,falseotherwise, and the number of stones captured during the move.
UndoMove()
Moves backwards one board state. Will not work if not in Analysis mode.
public bool UndoMove()
Returns
- bool
trueif there was a board state in the undo buffer,falseotherwise, or if not in analysis mode.