Attack Generator

Functions

void getAttacks(std::stack<int> *attacks, const int *board, const int piece)

Generates all legal moves on the board for the given piece

Determines which function to call based on the piece type, it may be more efficient to call the appropriate function directly.

Parameters:
  • attacks – Stacks to add attacks too

  • board – List of all pieces and their locations on the board

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getPawnAttacks(std::stack<int> *attacks, const int *board, const int piece)

Generates all legal moves on the board for the given pawn

See documentation for legalPawnMoves() for more information Pawn attacks don’t depend on the board but does depend on the color

Parameters:
  • attacks – Stacks to add attacks too

  • board – List of all pieces and their locations on the board

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getPawnAttacks(std::stack<int> *attacks, bool color, int piece)

Generates all legal moves on the board for the given pawn

See documentation for legalPawnMoves() for more information Pawn attacks don’t depend on the board but does depend on the color This version allows you to specify the color of the pawn

Parameters:
  • attacks – Stacks to add attacks too

  • color – Color of the pawn. True for White; false for Black

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getKnightAttacks(std::stack<int> *attacks, int piece)

Generates all legal moves on the board for the given knight

The knight only attacks the 8 possible squares and doesn’t require the board to be passed in.

Parameters:
  • attacks – Stacks to add attacks too

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getBishopAttacks(std::stack<int> *attacks, const int *board, int piece)

Generates all legal moves on the board for the given bishop

See documentation for legalBishopMoves() for more information

Parameters:
  • attacks – Stacks to add attacks too

  • board – List of all pieces and their locations on the board

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getRookAttacks(std::stack<int> *attacks, const int *board, int piece)

Generates all legal moves on the board for the given rook

See documentation for legalRookMoves() for more information

Parameters:
  • attacks – Stacks to add attacks too

  • board – List of all pieces and their locations on the board

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getQueenAttacks(std::stack<int> *attacks, const int *board, int piece)

Generates all legal moves on the board for the given queen

See documentation for legalQueenMoves() for more information

Parameters:
  • attacks – Stacks to add attacks too

  • board – List of all pieces and their locations on the board

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece

void getKingAttacks(std::stack<int> *attacks, int piece)

Generates all legal moves on the board for the given king

See documentation for legalKingMoves() for more information

Parameters:
  • attacks – Stacks to add attacks too

  • piece – The piece to generate legal moves for

Returns:

All possible legal moves for the given piece