The Piece classes should just hold the move paths, without any knowledge of whether a given move path is valid in its current position and board. Those rules logics should be moved into the Game class instead.
I am thinking the possible moves are encoded as a list of relative coordinates, where a value of 1 equates to moving forward and -1 equates to moving backward. A simple example of the Soldier class would be [ (0,0), (1,0) ] to move the piece forward one cell.
These lists of move paths are then processed by the Game (and Board) class to remove invalid paths, e.g. when it's blocked by a friendly piece.
The
Piece
classes should just hold the move paths, without any knowledge of whether a given move path is valid in its current position and board. Those rules logics should be moved into theGame
class instead.I am thinking the possible moves are encoded as a list of relative coordinates, where a value of 1 equates to moving forward and -1 equates to moving backward. A simple example of the
Soldier
class would be[ (0,0), (1,0) ]
to move the piece forward one cell.These lists of move paths are then processed by the
Game
(andBoard
) class to remove invalid paths, e.g. when it's blocked by a friendly piece.