Chess.lua

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Roland Chastain
Prole
Posts: 41
Joined: Sat Feb 07, 2015 2:30 pm
Location: France
Contact:

Re: Chess.lua

Post by Roland Chastain »

Hello!

Very interesting project. I have just downloaded it and read the overview.

As a first step in Lua chess programming, I made a simple FEN Validator. With your permission, I post it here.
Attachments
fen-validator.lua
(1.74 KiB) Downloaded 216 times
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post by ivan »

Hello Roland,
Not a bad start, but I should point out that you can't really validate a position just based on FEN input -
Ya, it's good to check if the material is right and that the two kings are on the board but you still need moves validation
to make sure that the game doesn't start in check. For example, if I'm white and I'm on the move, I shouldn't be
able to 'capture' the opponent's king.
It's a good start though and chess programming is awesome.
Last edited by ivan on Sat Jun 20, 2015 4:44 am, edited 1 time in total.
User avatar
Roland Chastain
Prole
Posts: 41
Joined: Sat Feb 07, 2015 2:30 pm
Location: France
Contact:

Re: Chess.lua

Post by Roland Chastain »

Yes, it's true. The purpose of that little function is just to check that the form of the string is correct. Thank you for your observation.
shedletsky
Prole
Posts: 1
Joined: Thu Apr 23, 2020 6:09 pm

Re: Chess.lua

Post by shedletsky »

Cool library. I'm trying to use it as a move validator for an interface that I am building.

What is the state of of code? I uncommented out the auto-play demo in example1.lua and was able to get it running after making some minor changes (mostly making dots into colons on the function calls). It seems like the example code tries to call some functions that don't exist (pos.isCheck() and pos.isThreefold()). There's also some serialization code to support (I assume) detection of the 3-fold repetition case in the pos.lua file that is commented out.

Looked at the commit history, it looks like maybe the functionality I am looking for was working in with commit ec18735 on
2019-10-20.

I'm trying to figure out if I should:
1. Try to merge that code over to the latest branch
2. If that code doesn't work well anyways, write my own versions of the functions I need
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post by ivan »

Thank you for using the library. I had done some additional improvements so the examples were out of date.
I have just pushed an update so the examples should be working fine now.

1.The "best" version of the code is available here:
https://github.com/2dengine/chess.lua
2.As far as I know everything should work fine.
If you want to test it, I recommend running the validator on large PGN files as shown in the first example.
The second example shows how to make an interface.
There's also some serialization code to support (I assume) detection of the 3-fold repetition case in the pos.lua file that is commented out.
I had temporarily disabled this for testing purposes.
It looks like some historical games don't follow the threefold repetition rule so you only need this for live games.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests