Hello Guys,
I am writing a hobbyproject chess in Nim and ran into a little issue with the 'isChecked' proc.
Right now I'm writing tests, best case would be as many tests to program it in a TDD manner.
But I am testing the 'isChecked(king, board)' proc right now.
The test where the Rook is right south of the King works properly and the check is recognized.
But the next test, where the Rook is right west of the King does not work, the check is not recognized.
I am not sure how to fix that issue..
This is the test which is not working: https://github.com/Smarcy/nim_chess/blob/master/tests/test_move.nim#L611
This is the isChecked proc: (Right now only checking Rook-checks)
https://github.com/Smarcy/nim_chess/blob/master/src/nim_chess/model/board.nim#L76
You can reproduce the error with 'nimble test'. Also you can see what is happening if you add 'b.draw' anywhere in the test to see, where the Pieces are located currently.
I feel like the code has some problems recognizing checks when the checking Piece is on the edge of the board. Does anyone see the issue and how I may fix this?
Thanks in advance.
You don't consider the edges.
while X>0 and X<7:
#anything here only runs if X is 1,2,3,4,5, or 6