CIL Toolkit: code snippets: move generation

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: CIL Toolkit: code snippets: EDN encoding, just for a lau

Post by sje »

mhull wrote:Is there some code that will convert EDN to SAN?
No. One quick way of producing a simple EDN->SAN converter would be to simply generate all EDN moves or a position and then do a simple string match.

The main problem is that there is no formal specification for EDN. Also, the simple EDN generator presented here can't handle common forms like "QN-Q2" and "PxKBP".
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: CIL Toolkit: code snippets: EDN encoding, just for a lau

Post by sje »

I can't believe that I used the word "simple" three times in one sentence. Obviously, I shouldn't post immediately after waking up from a nap.

Doing EDN the right way is not easy. One might well question why it should be done at all. Basic amusement is one reason. Another reason is that there are still a considerable number of chess fans, mostly American and mostly over fifty, that grew up with EDN and have never made the switchover. If these folk want to read chess games in EDN, then I don't see how that could harm anyone.
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: CIL Toolkit: code snippets: EDN encoding, just for a lau

Post by mhull »

sje wrote:I can't believe that I used the word "simple" three times in one sentence. Obviously, I shouldn't post immediately after waking up from a nap.

Doing EDN the right way is not easy. One might well question why it should be done at all. Basic amusement is one reason. Another reason is that there are still a considerable number of chess fans, mostly American and mostly over fifty, that grew up with EDN and have never made the switchover. If these folk want to read chess games in EDN, then I don't see how that could harm anyone.
I have quite a few issues of American Chess Bulletin. They are slowly deteriorating. I've pondered the idea of scanning them into PDFs and/or scanning/OCR all the games and converting them to SAN/PGN. Just wondering if anyone had programmed an EDN/SAN converter. It would be tedious to convert them all by "hand" via entry into xboard or something.
Matthew Hull
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: CIL Toolkit: code snippets: EDN encoding, just for a lau

Post by sje »

Also, consider the references to chess in classic cinema. Would the chess game in _2001_ still have been the same had HAL had not used spoken EDN? Note that the script has HAL making a rank inversion EDN error. I wonder if Kubrick did this deliberately; he himself was a strong amateur player.

----

Some of the most expensive chess sets available have flank indicators at the bases of the pieces. Example: one white knight will have a small "K" carving while the other has a "Q". This is a tradition from the Early Days of EDN that made it easy to record which knight was moving to a square.

For entirely different purposes, the new CIL Toolkit has a tracker object as a component of every position data object that does essentially the same thing. So at any point in the game the toolkit not only knows the difference between a side's king rook and the queen rook, it can also identify which pawn was used for each promoted piece.

The above won't work for set-up positions, though. There's no way for FEN to identify originating files or flanks.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: CIL Toolkit: code snippets: EDN encoding, just for a lau

Post by sje »

mhull wrote:I have quite a few issues of American Chess Bulletin. They are slowly deteriorating. I've pondered the idea of scanning them into PDFs and/or scanning/OCR all the games and converting them to SAN/PGN. Just wondering if anyone had programmed an EDN/SAN converter. It would be tedious to convert them all by "hand" via entry into xboard or something.
Is it possible that someone has already done a conversion of the ACB material? So many of the older chess books have seen new versions released with either FAN or SAN, so it's worth a search.

Years ago, IIRC, Ken Thomson published a paper while at Bell Labs titled "Reading Chess" in which he discussed the OCR techniques he used to convert the paper version of the five volume ECO into an opening book for his program Belle. Maybe it might have some helpful ideas.

It might also be the case that there are some commercial chess programs that can import EDN game text files. Another idea would be to take the source of Chess 0.5 or a similar program source in the public view and use it as a base to convert EDN games to PGN. I seem to remember that the software side of Belle, written in pre-ANSI C, could handle both EDN and coordinate input and that this source is available somewhere.

If all fails, I suppose I could add the capability to the new CIL Toolkit. Of course, it would only handle the post-OCR processing phases.
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: CIL Toolkit: code snippets: EDN encoding, just for a lau

Post by jwes »

sje wrote:
mhull wrote:I have quite a few issues of American Chess Bulletin. They are slowly deteriorating. I've pondered the idea of scanning them into PDFs and/or scanning/OCR all the games and converting them to SAN/PGN. Just wondering if anyone had programmed an EDN/SAN converter. It would be tedious to convert them all by "hand" via entry into xboard or something.
Is it possible that someone has already done a conversion of the ACB material? So many of the older chess books have seen new versions released with either FAN or SAN, so it's worth a search.

Years ago, IIRC, Ken Thomson published a paper while at Bell Labs titled "Reading Chess" in which he discussed the OCR techniques he used to convert the paper version of the five volume ECO into an opening book for his program Belle. Maybe it might have some helpful ideas.
http://doc.cat-v.org/bell_labs/reading_ ... _chess.pdf
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Reading Chess

Post by sje »

Thank you for the link; I had forgotten that the paper had appeared in PAMI and in retrospect that should have been the first place to look.

I can vouch for the authors' comments about the poor printing quality of ECO. I have the five volume set of that era and some of the pages require a magnifier plus a bit of guesswork.

Reading typical EDN will incur even more problems due in part to a reduced symbol set vs figurine notation. Also, my experience with EDN in the pre-computer days is that there are many more ambiguous move errors vs algebraic notation. Fixing some of these will require playing ahead along all possible interpretations and discarding choices that don't enable wholly legal continuations.

It's a bit quaint to read about the running times of computers of twenty years ago. Today, some of the manufacturers aren't even around, at least not as separate entities. I wonder which companies of today will still be in business in 2028.