A chess player I wrote

A mention of a Prolog chess player in this thread reminded me of one I wrote (or rather translated from a kif file) which I found very educational.

I’ve put the code at github since it break’s Discourse’s 32000 character limit.

I wrote the above as part of an online course I did offered by Stanford University professor Michael Genesereth and it follows naming conventions explained in his notes.

3 Likes

I did at one stage have this driving a web-based chess player which could beat me (I’m not a good player) and should go back and get an improved version working at some stage.

One of the bug’s in the code I “borrowed” from Stanford’s game server is it hardcodes pawn promotion as to queen, whereas an interpreter I wrote to run PGN files through the above often threw errors due to knight promotions being common in contemporary games, and vintage chess rules seem to have been “only the pieces in a standard box allowed on the board at one time”.

Anyways, the tough part wasn’t the Prolog so much as that chess and similar games take way more RAM than $5/month servers offer, so I ended up pushing most of the work and the code into a Postgresql database. For rule checking and generating legal moves, Prolog definitely makes life a lot easier than any other programming language I’ve encountered.

1 Like