Is 79 maximal?

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Is 79 maximal?

Post by zullil »

A legal position:

[d]r1b1k2r/1n1n1q1p/1p1p1p1b/p1p1p1p1/P1P1P1P1/1P1P1P1P/Q1N1N1B1/R1B1K2R w KQkq a6
User avatar
reflectionofpower
Posts: 1663
Joined: Fri Mar 01, 2013 5:28 pm
Location: USA

Re: Is 79 maximal?

Post by reflectionofpower »

zullil wrote:A legal position:

[d]r1b1k2r/1n1n1q1p/1p1p1p1b/p1p1p1p1/P1P1P1P1/1P1P1P1P/Q1N1N1B1/R1B1K2R w KQkq a6
It pastes in Deep Fritz no problem so why would it not be legal. If it was not it wouldn't fit.
"Without change, something sleeps inside us, and seldom awakens. The sleeper must awaken." (Dune - 1984)

Lonnie
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: Is 79 maximal?

Post by kbhearn »

I assume you're talking about character length of a FEN string. in your example you're missing the move counter/half move counter and a6 should technically not be listed as EP square as there's no pawn to capture to there but as that's a relatively common error i imagine you should allow it nonetheless.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Is 79 maximal?

Post by zullil »

kbhearn wrote:I assume you're talking about character length of a FEN string.
Correct!
kbhearn wrote: In your example you're missing the move counter/half move counter
Yes, I am omitting the final two fields from consideration.
kbhearn wrote: and a6 should technically not be listed as EP square as there's no pawn to capture to there but as that's a relatively common error i imagine you should allow it nonetheless.
You might be wrong here. At least according to
16.1.3.4: En passant target square

An en passant target square is given if and only if the last move was a pawn advance of two squares. Therefore, an en passant target square field may have a square name even if there is no pawn of the opposing side that may immediately execute the en passant capture.
http://kirill-kryukov.com/chess/doc/fen.html
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: Is 79 maximal?

Post by Adam Hair »

Yes. If a7a5 was the last move, then listing a6 in the en passant field is not an error according to the FEN standard.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Is 79 maximal?

Post by zullil »

Adam Hair wrote:Yes. If a7a5 was the last move
For example

[pgn]
[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "White"]
[Black "Black"]
[Result "*"]
[ECO "A00"]

1. g4 g5 2. e4 e5 3. c4 c5 4. a4 Bh6 5. h3 f6 6. f3 d6 7. d3 b6 8. b3 Ne7 9. Bg2 Nec6 10. Ne2 Na5 11. Na3 Nb7 12. Qd2 Nd7 13. Qb2 Qe7 14. Qa2 Qf7 15. Nc2 a5 *
[/pgn]
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: Is 79 maximal?

Post by Adam Hair »

It seems maximal to me. This string uses the maximum number of characters for each row while using the 4 possible characters for the castle field and includes the en passant field.
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Is 79 maximal?

Post by lucasart »

When you're programming a chess engine, or a chess GUI, it's better to be conservative:
* assume people can enter positions that cannot be reached from starting position, or from any chess960 starting position.
* only assumption you can make is that the position is legal, in the sense that it's not already mate or draw by chess rules, and other obvious things like 1 king per
side, etc.

Also, the size of a fen is the least of problems, because you'll never need to store lots of fen in memory.

Based on conservative assumptions:
* 8*8+8 for main part
* 2 for color
* 5 for casting rights
* 3 for en passant
* 4 for full move counter (max 999 moves or 1998 plies)
* 3 for half move clock (cannot be 100 or it has to be mate)
* 1 for the null terminator
That's 90 bytes. Make it 96 for alignment purposes, and so people don't start whining about the 999 moves limit (will now be 999,999,999), and you're there.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: Is 79 maximal?

Post by Brunetti »

lucasart wrote:* 3 for half move clock (cannot be 100 or it has to be mate)
Actually there's no limit on this counter: draw is not automatic and has to be claimed by a player (if he likes so), so a fully legal position may have values higher than 100. Just a detail, this doesn't alter your 96-byte allocation.


Alex
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Is 79 maximal?

Post by lucasart »

Brunetti wrote:
lucasart wrote:* 3 for half move clock (cannot be 100 or it has to be mate)
Actually there's no limit on this counter: draw is not automatic and has to be claimed by a player (if he likes so), so a fully legal position may have values higher than 100. Just a detail, this doesn't alter your 96-byte allocation.


Alex
That's some of the most idiotic xboard legacy...

An UCI capable GUI should act as a referee and terminate the game. Same for mate, stalemate, 3-rep, etc.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.