Fun challenge for best cool code

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Fun challenge for best cool code

Post by hgm »

EPDs have no 50-move or move-number fields. Only FENs have that...
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Fun challenge for best cool code

Post by Dann Corbit »

hgm wrote: Thu Feb 28, 2019 1:31 pm EPDs have no 50-move or move-number fields. Only FENs have that...
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - fmvn 1; hmvc 0;
They have them, but they are decorated with a label.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Fun challenge for best cool code

Post by hgm »

Sure. But they are optional, and 0, 1 are their default values.
chrisw
Posts: 4313
Joined: Tue Apr 03, 2012 4:28 pm

Re: Fun challenge for best cool code

Post by chrisw »

Dann Corbit wrote: Thu Feb 28, 2019 8:23 pm
hgm wrote: Thu Feb 28, 2019 1:31 pm EPDs have no 50-move or move-number fields. Only FENs have that...
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - fmvn 1; hmvc 0;
They have them, but they are decorated with a label.
I put that in as an issue to Python Chess about a week or so ago.

One more item: many online FEN strings come without the two final fields (moves since, movenum). the FEN reader complains. Might be useful if it added 0, 1, with some documentation explanation.

Response back: I need this quite frequently myself, but never got around to do it. Now implemented in 65e8729. Defaults to 0 1.

So, I think Python Chess now accepts both:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq x, y

and appends an 0, 1 if x, y missing. It used to just issue an error, "fen strings have six fields"
I'm not sure what happens if fmvn is specifically used as an identifier.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Fun challenge for best cool code

Post by hgm »

I hate pedantic interfaces. WinBoard just uses a default value 0 for the ply counter if it is missing, and ignores the move number anyway, when it parses a FEN.

I guess stupid old NotePad would not even have a problem doing this; just do a 'Replace All' on " id " for " 0 1 id " if you insist on beraking the EPDs that way.
niklasf
Posts: 42
Joined: Sat May 16, 2015 11:41 pm

Re: Fun challenge for best cool code

Post by niklasf »

chrisw wrote: Fri Mar 01, 2019 10:58 am So, I think Python Chess now accepts both:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq x, y
Yeah, on the master branch it now even defaults to

Code: Select all

w - - 0 1
respectively. Not sure if that's a bit too relaxed ... in any case a user could parse, regenerate, compare to do strict validation.
chrisw wrote: Fri Mar 01, 2019 10:58 am I'm not sure what happens if fmvn is specifically used as an identifier.
This always worked as expected:

Code: Select all

>>> import chess
>>> board, ops = chess.Board.from_epd("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - fmvn 2; hmvc 3;")
>>> board
Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 3 2')
>>> ops
{'fmvn': 2, 'hmvc': 3}
However it will still reject

Code: Select all

id unquoted_string
because it attempts to parse this as a number or move.