Community Puzzle: Chess moves on FEN position

Hi

I have all tests passing but the final validation fails. Can I get a hint regarding the problem?

Why validator fails?

that was my question.
take a look at this screen cap

It seems that it’s the one with a pawn that has been upgraded.

thanks, but I need something more specific. I’ve run custom tests and covered all possible promotions

Maybe not. :sunglasses:

Someone on chat pointed out to me that the stub code for this puzzle was only reading 4 characters per move, but the promotion move is 5 characters long. The 5th test has the promotion move as the last move in the sequence, but the 5th validator has other moves after the promotion move, so for languages that depend on the string length to be correct, the 5th validator may fail.

I have fixed the stub generator to correct this problem, but it might affect anyone who started this puzzle before this fix was put in place.

  • danBhentschel
1 Like

Hello,
My problem is similar. I’ve passed all tests, but the 3rd validator failed.

Thanks for your help and ideas.

The third test focuses on castling to the right, short castling, or castling on the kingside. The third validator focuses on castling to the left, long castling, or castling on the queenside. Make sure that you have handled this properly for both white and black.

If you still can’t get it, try making your own tests.

  • danBhentschel
2 Likes

Thank you player_one
I only focused on short castling.

I’m having trouble with the last validation test too. I have done several tests by myself and it looks to be working correctly so i have no idea why is it failing. Can’t we have some more info about what’s the validator doing? It’s hard to debug something if you have no idea what you are looking for (i mean, i can’t even know if its an error thrown by the compilator or is just that my code is not well designed since it only says that the validator failed).

I’m doing it in C++, if that helps.

Thanks in advance.

1 Like

The last test is about black promotes with pawn from field c2 by taking a white piece (rook) that is placed on field d1. The input has a fifth character that indicates that black wants to promote the pawn to a rook.

So:
Field c2 is empty resulting in 2pBQPP1 will be converted to 3BQPP1
Field d1 contains a rook resulting in 2KR3R will be converted to 2Kr3R

Hope this helps…

I was just making some tweakings to the code and it seems to be working fine now, which is weird since i haven’t made any important change… Anyway, thanks for your detailed answser :slight_smile:

I’m also struggling with just “Validation 5” failing. I tried making custom tests with more moves after it and they passed for me. :cry:

1 Like

Thanks, but this is the last test case, we needed some information about the last validator, since most of us passes the test cases but fails at the 5th validator.

I have tried custom test cases, still can’t get it work. Maybe the problem is with my algorithm? It is pretty straightforward, so i post it here:
0. i check if the “en passant”, or castling situations occur, if yes, i make changes according to them (this step is unrelated to pawn promotion)

  1. check if the input is 5 charaters long
  2. if it is, then the destination position’s value will be the 5th character, thus the promoted piece
  3. if it isn’t, the destination position’s value will be the source position’s value

So i assume if there is an 5th character, then pawn promotion happens, no matter what (since it is stated that “All the moves are legal and can be made following standard chess rules.”).

What could the problem be, is a mystery.

I dont see any problems in the logic you describe. I assume other pieces wont be the problem.

Some things that come to mind to check:

  • Do you have a test to promote without taking a piece (so move vertically to the first row)?
  • Do you have a test where white is promoting a pawn (other direction)?

If anyone wants to PM me their source code, I would be willing to try to debug the problem. I have looked at the 5th validator numerous times, and I can’t see anything obviously tricky about it.

  • danBhentschel

Okay, so one person has sent me code, and here is where Validator 5 tripped this person up…

Validator 5 moves the king diagonally at one point, and this particular user was using the distance the king travelled to trigger a castle. If distanceTravelled > 1 square, then must be a castle. That kind of thing.

Problem is, if you calculate the distance of a diagonal move, it is > 1, but is decidedly not a castle. Things went downhill from there.

Does this help anyone? Does anyone else want to send me code to look at?

  • danBhentschel
4 Likes

He used the wrong distance, the right one is ||.|| (sup distance), neither ||.||2 (euclidian distance) nor ||.||1 (Manhattan distance).

Someone else just hit this same problem, so I have modified Test 5 so that it now has another move after the pawn promotion, just so that it’s not a surprise in the Validator. Just an FYI.

  • danBhentschel