linkonsat/chess

Moving a piece places king into check.

Closed this issue · 0 comments

After further research, it appears to also be illegal to move a piece if the piece results in the king being in check. The easiest solution would be to move to check into a module, therefore, allowing all pieces to inherit this behavior or making a class move generator. Moving a check generator into the move generator seems like the most realistic method as this behavior needs to be shared among chess pieces. Therefore we would move the check-related moves into the current move module and make that a requirement for a piece to return a valid move. Without needing to change our current test iterations. One way is to create another instance of the board.

the clone command seems to step around this problem of a copied object referencing the other one. using that basis we can copy the board and update it and if the king is check return false from the move module.