Chess Game  1.1.0
A full chess game for Unity
cgMoveGenerator Class Reference

We generate all possible moves(regardless of blocking) for all pieces once here. This technique saves a huge amount of computation for the Engine, as it only has to look up these moves and test their legality on a given board - instead of actually generating them each time a move is performed. More...

Public Member Functions

 cgMoveGenerator (byte width=8, byte height=8)
 Generate all possible moves for a board of the provided size. More...
 
List< int > EmulateBishopAt (int pos)
 Emulates all possible bishop movements from target index position. More...
 
List< int > EmulateKingAt (int indexPosition)
 Emulates all possible king movement from target index position More...
 
List< int > EmulateRookAt (int pos)
 Emulates all possible rook movements from target index position. More...
 
List< int > EmulateQueenAt (int pos)
 Emulates all possible queen movements from target index position. More...
 
List< int > EmulateKnightAt (int indexPosition)
 Emulates all possible knight movements from target index position. And the knight is a tricky motherF!?cker to generate moves for. More...
 
List< int > EmulatePawnAt (int indexPosition, bool white)
 Emulates all possible pawn movements from target index position. More...
 
List< int > FindRayMoves (List< int > directions, int indexPosition)
 Moves as far in each direction as possible without going outside the chess board. More...
 

Public Attributes

byte _maxCellIndex = 64
 

Detailed Description

We generate all possible moves(regardless of blocking) for all pieces once here. This technique saves a huge amount of computation for the Engine, as it only has to look up these moves and test their legality on a given board - instead of actually generating them each time a move is performed.

Constructor & Destructor Documentation

◆ cgMoveGenerator()

cgMoveGenerator.cgMoveGenerator ( byte  width = 8,
byte  height = 8 
)

Generate all possible moves for a board of the provided size.

Parameters
widthNumber of columns of board
heightNumber of rows of board

Member Function Documentation

◆ EmulateBishopAt()

List<int> cgMoveGenerator.EmulateBishopAt ( int  pos)

Emulates all possible bishop movements from target index position.

Parameters
posThe 0-64 index position
Returns
All possible moves.

◆ EmulateKingAt()

List<int> cgMoveGenerator.EmulateKingAt ( int  indexPosition)

Emulates all possible king movement from target index position

Parameters
indexPositionThe 0-64 index position
Returns

◆ EmulateKnightAt()

List<int> cgMoveGenerator.EmulateKnightAt ( int  indexPosition)

Emulates all possible knight movements from target index position. And the knight is a tricky motherF!?cker to generate moves for.

Parameters
posThe 0-64 index position
Returns
All possible moves.

◆ EmulatePawnAt()

List<int> cgMoveGenerator.EmulatePawnAt ( int  indexPosition,
bool  white 
)

Emulates all possible pawn movements from target index position.

Parameters
posThe 0-64 index position
Returns
All possible moves.

◆ EmulateQueenAt()

List<int> cgMoveGenerator.EmulateQueenAt ( int  pos)

Emulates all possible queen movements from target index position.

Parameters
posThe 0-64 index position
Returns
All possible moves.

◆ EmulateRookAt()

List<int> cgMoveGenerator.EmulateRookAt ( int  pos)

Emulates all possible rook movements from target index position.

Parameters
posThe 0-64 index position
Returns
All possible moves.

◆ FindRayMoves()

List<int> cgMoveGenerator.FindRayMoves ( List< int >  directions,
int  indexPosition 
)

Moves as far in each direction as possible without going outside the chess board.

Parameters
directionsDirections, as specified by how much it should add to the current position, i.e -9 = top left, -8 = top, -7 = top right, -1=left, 1 = right etc.
indexPositionStarting position
Returns
A List of all possible moves inside the 1x64 chess board

The documentation for this class was generated from the following file: