Hey,
Nice & fun puzzle, I passed all validation tests cases but fail with test 4 when submitting. It is a nightmare debugging without the actual set up. I probably changed a “+” for a “-” somewhere that fail in this very scenario. Mind sharing by private message the board State for test case 4 ?
Thanks
I have the same pb with you? Any idea for solving it? May be we should optimize the code ?
I output the board layout and checked square patterns to Stderr. It really helped in debugging.
The validator for Test Case 4/Anderssen mate is with the same setup as the test, but happens on the lower right part of the board, and the teams are switched. A potential problem could be a wrong move direction for the pawns, white pawns are moving upwards, while black pawns are moving downwards.
Thank you, I solved my pb, it was a mistake on pawn movement.
My test 4 was also failing after the test passed, but I figured it out. My pawns were actually moving horizontally instead of vertically. Which would be correct in 50% of the cases because they capture diagonally. hehe
Well i don’t know if it helps but i found the issue. In my case i have a board class with two arrays of chess pieces (others classes) one for the whites and one for the blacks.
I was adding the black pawn to the white stack. Which pass all tests but not after sublitting
Hello !
I am having problems, with the 14th validator, all tests and validator are goods but not this one.
I have check that the king has the right to take adjacent pieces.
Can someone help me ?
Double check the behavior of the Rooks, in the validator for the test case 14 the position of the attacking rook is different.
Oh thanks , it was that ! I had forgotten than when the rook detect the opposer’s king he have to look one step behind him because the king can move after
it’s called lichess
Hello, I don’t understand how the board of Test 15 : Close call is supposed to be not terminal. It looks like the white king is completely surrounded by the 2 rooks and the 2 knights?
Hey ! It’s because the black king is attacked by the white knight, so the black player have to move his king instead of taking the white king.
I solve the problem but I think that you could improve the explanation by clearly saying that a king can take an opponent piece
Oh, I see now, thank you!
Test 02 Mate with Rooks is illegal. This possition will never occure in real chess. Try to immagine one move before this possition, impossible.
. . K. . . . r
. . . . . . . r
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . k
Yeap, you’re right, I’ll take it into account.
Test cases and validators for:
Mate with Rooks
Escape by overtaking
Close one
are updated to be realistic chess game states.
Yo. I solved this puzzle some time ago thinking it was weird that there are 9x9 Go puzzles and nothing for chess. Maybe this is a good first step. Thanks for your work.
On a side note I am an avid chess player (and I also play on lichess sometimes). I wrote multiple chess engines before (they are not so bright unfortunately). One of my puzzle ideas for an easy puzzle on codingame is a Forsyth-Edwards Notation parser. It’s much simpler than a position validator, but as a first contribution (I am novice here), it might be okay.
I would do both cases: ENCODE (you are given a board and you give the fen string). But also DECODE (you are given the fen string and you output the board). I am not sure if a puzzle like this would be good. Tell me what you think.
Another chess idea is a move generator. Move generation is not a trivial task in chess (enpassant, castle, checks complicate matters). But the thing is with so much code available from chess engines, I don’t really see the point of doing so. Doing a multiplayer chess game also looks wrong, too much code available to solve this problem with zero effort.
If you need help with anything, you can message me. I am a big chess programming enthousiast. This is my repo: https://logiqub.com/repo/chessqub
The engine is just a toy but you can play against it, although it is far from mature.
Hey there!
Very nice puzzle, I really enjoyed it
I’m having issues with validator 14, which you gave clues for, but apparently the test has changed since
My process is 1) get a list of all possible king squares, including the current one, empty squares, and squares containing an opposite piece, which can be taken ; 2) test each possible king square one by one, starting with the current position, see if at least one opposite piece is checking the king ; 3) stop if there is at least one position in which the king is safe. And then, if white king is mated, don’t check black king.
Without knowing the validator, I cannot figure out what is wrong with my code Could you assist, please?
Cheers!