Beta
Validate FEN notation
Loading description...
Strings
Regular Expressions
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
(half)moves boundary cases are not tested.
For example:
I did not understand how en passants are checked on the tests, i tried various forms of verification but every time it failed on a diferent spot
all those FENs returns true
pN4k1/2KnN2N/4RrK1/1qR1kKk1/2Br2Q1/b5bK/pn4k1/1RB3R1 w QqK a6 15 28
2Q1bP2/1K2PN1B/6Bb/3rr3/4kB2/5np1/3K3n/2r1B3 b k a3 31 41
K2PnPn1/1npK4/1k6/Bb2BbnP/3B1bb1/8/Nbb1k3/r3N3 w qkQ f3 34 116
3nQk2/1B1B3b/4n3/RN2BN2/1b2qk2/1B1KbbQ1/1Nk5/qRb1B3 w QK d6 20 22
but how, there isnt even a pawn near the row indicated
Hi,
I especially didn't like the checks you ask about the en passant moves. To have a valid configuration, those conditions should be met:
All those checks are doable right now.
In a related fashion... why don't you validate that the number of pieces is at least possible?
EDIT: btw, you could add the input in the assertion message for the fixed tests (they are given with the
it
blocks in the random tests: that's more comfortable for the user)There could also be checks that:
Hi, thanks for the feedback. I'm aware of the simplicity of the en passant target validation that this kata requires. I've considered all the conditions you mentioned, and at first I wanted to include them in validation, but abandoned this idea, noticing how this would require much more complex random test generation. I thought that this kata is already quite fun as it is now. Or maybe I'm just too lazy :v On the side note, I don't feel that checking if the opposite color's pawn is able to capture the mentioned pawn is neccessary, for I see this notation only as an indication, that the pawn just moved two squares and is susceptible to the en passant capture, regardless of whether this capture is actually possible for the opposing color. But, aside from the en passant capturing, I think that adding at least the minimum board validation you mentioned would be a good idea, honestly I don't know why I didn't do that already. Will do.
The checks besides en passant rules are problematic because they are possible in chess variants, which use the same FEN notations to store games. Lichess has lots of popular variants.
Violated by horde chess, which has pawns on one's own back rank. Besides, the chess rules used to not forbid promoting to a pawn (or even opponent pieces), which would cause pawns to exist on the opponent's back rank.
Violated by anti-chess (there can be 0 kings for each side).
It depends on the variant.
Are these valid or not?
Good questions. Splitting empty squares into separate groups, while not practical, is still a valid notation. This standard, AFAIK, nowhere states that it is not valid, and this still can be clearly interpreted as a valid row on a board. So the answer is yes, this is valid, although the tests don't check this. But as this is an interesting observation, I will include this in fixed tests. For the second part - as per description, the second field in the notation represents:
Active color, either `w` or `b` for white and black accordingly.
So this field shall take only one of these characters, uppercase letters are not valid. Same thing applies to the en passant target, as traditionally, the algebraic notation identifies square's file as a lowercase letter from a to h.Added a mention of the possibility of representing empty squares the way you pointed out, as well as a test that checks against it.
Duplicate castling symbols test is missing from the fixed tests.
Good call, test added.