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
dimensionsintThe
Properties
BlackToMove
Represents whether black should be the next color which places a stone..
public bool BlackToMove { get; }
Property Value
Dimensions
The dimensions along a single axis of the game board;
public int Dimensions { get; }
Property Value
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
TotalWhitePieces
The number of white pieces on the board
public int TotalWhitePieces { get; }
Property Value
WhiteToMove
Represents whether white should be the next color which places a stone..
public bool WhiteToMove { get; }
Property Value
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
columnintThe column of the desired coordinate.
rowintThe row of the desired coordinate.
previousSpacesHashSet<(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
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
moveMoveThe 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
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
otherBoardAn object to compare with this object.
Returns
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
Returns
- bool
trueif 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
Returns
operator !=(Board, Board)
public static bool operator !=(Board left, Board right)