Table of Contents

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

size int

The size of the game's Board in a single dimension.

analysis bool

Whether this is an analysis game, thus allowing undos.

Properties

Analysis

Whether the game is in analysis mode.

public bool Analysis { get; }

Property Value

bool

CurrentBoard

The current board.

public Board CurrentBoard { get; }

Property Value

Board

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

bool

WhoseTurn

The color whose stone will be placed with the next move.

public SpaceState WhoseTurn { get; }

Property Value

SpaceState

Methods

IsMoveValid(Move)

Checks whether a move is valid given the full state of the game.

public bool IsMoveValid(Move move)

Parameters

move Move

The full move which will be tested.

Returns

bool

true if the move is valid, false otherwise.

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

gtp string

A GTP string to test.

Returns

(bool success, int numStonesCaptured)

true if the move was legal, false otherwise, and the number of stones captured during the move.

Pass()

Pass for the current color.

public bool Pass()

Returns

bool

true if 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

true if there was a board state in the redo buffer, false otherwise, 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

move Move

The move to try to play on the board

Returns

(bool success, int numStonesCaptured)

true if the move was legal, false otherwise, 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

true if there was a board state in the undo buffer, false otherwise, or if not in analysis mode.