Table of Contents

Struct Board

Namespace
WeiqiSharp.Core
Assembly
WeiqiSharp.Core.dll

Stores a snapshot of the game state.

public readonly struct Board : IEquatable<Board>
Implements
Inherited Members
Extension Methods

Constructors

Board(int)

Stores a snapshot of the game state.

public Board(int dimensions)

Parameters

dimensions int

The

Properties

BlackToMove

Represents whether black should be the next color which places a stone..

public bool BlackToMove { get; }

Property Value

bool

Dimensions

The dimensions along a single axis of the game board;

public int Dimensions { get; }

Property Value

int

Remarks

All boards represented by this library ar squares, and as such this can be used to exactly calculate teh size of the board.

TotalBlackPieces

The number of black pieces on the board.

public int TotalBlackPieces { get; }

Property Value

int

TotalWhitePieces

The number of white pieces on the board

public int TotalWhitePieces { get; }

Property Value

int

WhiteToMove

Represents whether white should be the next color which places a stone..

public bool WhiteToMove { get; }

Property Value

bool

Methods

CheckLiberties(int, int, in HashSet<(int x, int y)>)

Returns the total number of liberties available to teh stone at a specified coordinate.

public int CheckLiberties(int column, int row, in HashSet<(int x, int y)> previousSpaces)

Parameters

column int

The column of the desired coordinate.

row int

The row of the desired coordinate.

previousSpaces HashSet<(int x, int y)>

A HashSet<T> of coordinates that will eventually contain each of the spaces which were checked.

Returns

int

The total number of liberties in teh group which the requested space is a part of. If 0, an empty space was selected.

CheckState(int, int)

Checks the state of the board at a particular coordinate.

public SpaceState CheckState(int column, int row)

Parameters

column int

The column of the space.

row int

The row of the space.

Returns

SpaceState

The SpaceState that is present on the board at the requested coordinates

CheckState(Move)

Checks the state of the board using the coordinates of a move.

public SpaceState CheckState(Move move)

Parameters

move Move

The move whose coordinates will be checked.

Returns

SpaceState

The SpaceState that is present on the board at the requested move's coordinates

Copy()

Deep copy the board space by space.

public Board Copy()

Returns

Board

A deep copy of this Board.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(Board)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Board other)

Parameters

other Board

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

RenderBoard()

Renders the board in terms of SpaceState.

public SpaceState[,] RenderBoard()

Returns

SpaceState[,]

A two-dimensional array of SpaceState which represents the current state of the game's pieces.

TryMakeMove(Move, out Board)

Attempts to make a move on the board.

public bool TryMakeMove(Move move, out Board newBoardState)

Parameters

move Move

The move which should be tested.

newBoardState Board

The transformed board state.

Returns

bool

true if the move was a valid move.

Remarks

Performs tests to ensure that the move is legal, and returns a Board representing the new state.

This method is fully idempotent. Multiple calls to this method act on teh same board state, and do not cause any side effects.

Note that this method does not respect turn order, and as such can be used to create valid board states for testing purposes.

Exceptions

InvalidMoveException

This is if and only if the move is

Operators

operator ==(Board, Board)

public static bool operator ==(Board left, Board right)

Parameters

left Board
right Board

Returns

bool

operator !=(Board, Board)

public static bool operator !=(Board left, Board right)

Parameters

left Board
right Board

Returns

bool