chessCAMO
Functions
anonymous_namespace{chess.cpp} Namespace Reference

This anonymous namespace contains the local functions related to chessCAMO which are mainly used as helper functions to determine critical information regarding a given move choice. More...

Functions

bool destNotInPinPath (int src, int dest, int pin)
 Determines if a destination square is in the pinning path as sometimes you can simply move the pinned piece closer to the pinning piece. More...
 
bool sameCol (int src, int dest)
 Determines if the source and destination squares are in the same column. More...
 
bool sameRow (int src, int dest)
 Determines if the source and destination squares are in the same row. More...
 
bool sameDiag (int src, int dest)
 Determines if the source and destination squares are in the same diagonal. More...
 
int squareOfPieceInPath (int src, int dest, const Chess &chess)
 Used to determine the coordinate of a pinned piece. More...
 
int incrementChoice (int src, int dest)
 Used to determine the increment to use when moving a piece from 'src' to 'dest'. More...
 
int findKingPos (int src, const Chess &chess, bool enemy)
 Used to determine the coordinate of a pinned piece. More...
 
string getPath (int num_moves)
 Gets the path to the object_states folder. More...
 

Detailed Description

This anonymous namespace contains the local functions related to chessCAMO which are mainly used as helper functions to determine critical information regarding a given move choice.

Function Documentation

◆ destNotInPinPath()

bool anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::destNotInPinPath ( int  src,
int  dest,
int  pin 
)

Determines if a destination square is in the pinning path as sometimes you can simply move the pinned piece closer to the pinning piece.

Parameters
[in]srcThe source square of pinned piece
[in]destThe destination square of pinned piece
[in]pinSource square of pinning piece
Returns
Allows the move (returns false) if piece can move closer to pinning piece, else move is invalid (returns true)

◆ sameCol()

bool anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::sameCol ( int  src,
int  dest 
)

Determines if the source and destination squares are in the same column.

Parameters
[in]srcThe source square of piece
[in]destThe destination square of piece
Returns
True if the source and destination are in the same column, else False.

◆ sameRow()

bool anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::sameRow ( int  src,
int  dest 
)

Determines if the source and destination squares are in the same row.

Parameters
[in]srcThe source square of piece
[in]destThe destination square of piece
Returns
True if the source and destination are in the same row, else False.

◆ sameDiag()

bool anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::sameDiag ( int  src,
int  dest 
)

Determines if the source and destination squares are in the same diagonal.

Parameters
[in]srcThe source square of piece
[in]destThe destination square of piece
Returns
True if the source and destination are in the same diagonal, else False.

◆ squareOfPieceInPath()

int anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::squareOfPieceInPath ( int  src,
int  dest,
const Chess chess 
)

Used to determine the coordinate of a pinned piece.

Parameters
[in]srcThe source square of pinning piece
[in]destThe destination square of pinning piece
chessThe chess object is created
Returns
If only 1 piece is in the path from 'src' to 'dest', return its coordinates else, return -1 to indicate that there is either no piece or multiple pieces in the path.

◆ incrementChoice()

int anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::incrementChoice ( int  src,
int  dest 
)

Used to determine the increment to use when moving a piece from 'src' to 'dest'.

Parameters
[in]srcThe source square of piece
[in]destThe destination square of piece
Returns
Returns either 1 if moving in same row, 7 if moving in diagonal to the right, 8 if moving in same column, 9 if moving in diagonal to the left. If move does not correspond to one of the pieces, returns 0.

◆ findKingPos()

int anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::findKingPos ( int  src,
const Chess chess,
bool  enemy 
)

Used to determine the coordinate of a pinned piece.

Parameters
[in]srcThe source square of pinning piece
chessThe chess object is created
[in]enemyTrue if king color differs from piece color, else false
Returns
Returns the coordinate position of the king, based on the current board representation and color determined by 'enemy'.

◆ getPath()

string anonymous_namespace chess anonymous_namespace{chess.cpp}::cpp::getPath ( int  num_moves)

Gets the path to the object_states folder.

Parameters
[in]num_movesThe number of moves made on the board
Returns
The path to the object_states folder.
Note
The return value depends on target of the global makefile