You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of a large nested array of every possible move, each piece should have a method that generates all moves from a set of steps ((+-1, +-1) for bishops, for example). This will require if(is_pawn()) and if(is_king()) checks for special moves.
The text was updated successfully, but these errors were encountered:
No need for if(is_pawn()) or other checks. The step moves are just normal moves. Add an is_single_step() method to Move class to tell move creation iterator whether a move can be repeated (for long-range sliding moves like rook and bishop moves) or not (knight, king, pawn).
Each piece should have two sets of moves: sliding moves that get repeated until the edge of the board is reached, and other moves (pawn moves, king moves, knight moves, castling, etc). The sliding moves are one-square moves that generate all other by repeating, and other moves are just added to the move list if they are legal.
Experiment
Instead of a large nested array of every possible move, each piece should have a method that generates all moves from a set of steps ((+-1, +-1) for bishops, for example). This will require
if(is_pawn())
andif(is_king())
checks for special moves.The text was updated successfully, but these errors were encountered: