Page 1 of 2

Chess.lua

Posted: Wed Apr 29, 2015 10:13 am
by ivan
This is sort of a side thing I play around with and it's still very much WIP.
For now, it's kind of slow as I tried to keep the code as short as possible.

What it does:
-generates moves
-validates positions
-parses PGN files
-parses FEN notation
-castling
-promotion

What needs work:
-SAN notation

What would be nice to have someday:
-actual AI
-FICS client using LuaSocket

It's open source so if you have suggestions and improvements please visit the repo at:
https://github.com/2dengine/chess.lua

Instructions for the love2d demo:
left click for 1 random move
middle click for 100 moves
right click for new game

Re: Chess.lua

Posted: Wed Apr 29, 2015 10:16 am
by Robin

Code: Select all

Error: terminal.lua:101: bad argument #2 to 'format' (string expected, got boolean)
stack traceback:
	[C]: in function 'format'
	terminal.lua:101: in function 'printf'
	main.lua:69: in function 'status'
	main.lua:121: in function 'mousepressed'
	main.lua:124: in main chunk
	[C]: in function 'require'
	[string "boot.lua"]:374: in function <[string "boot.lua"]:244>
	[C]: in function 'xpcall'
:(

Re: Chess.lua

Posted: Wed Apr 29, 2015 10:21 am
by ivan
Hey Robin, I must be using a different version of Love2d, could you please try again?

Re: Chess.lua

Posted: Wed Apr 29, 2015 2:39 pm
by qubodup
No problem with LOVE 0.9.2 on Linux.
Image

Re: Chess.lua

Posted: Wed Apr 29, 2015 4:28 pm
by Robin
The new version works fine!

Re: Chess.lua

Posted: Fri May 08, 2015 4:56 am
by ivan
Thanks so much for taking a look.
I know a few people on here have programmed chess in Lua.
So I'm open to suggestions on improving the code
in particular with the '10x12 mailbox' and perhaps even the board representation.
Seems like the 'mailbox' approach is more suited for non-interpreted languages.

Re: Chess.lua

Posted: Sun May 31, 2015 8:08 pm
by ivan
Just wanted to mention that we've released our old "Touch Chess" iOS app for free on Windows:
http://2dengine.com/chess/
It's uses the Faile engine.

And yes, I'm aware of the asynchronous issue and the awful title screen.

ImageImage

Re: Chess.lua

Posted: Tue Jun 02, 2015 4:06 am
by ivan
I wrote a very crude front-end for the moves validator using a chess font (somebody removed quads from Love 0.9 and I'm too lazy to read the docs).
Note that castling doesn't work and EPS captures need more testing.
Other than that it seems to work fine.
Love2D would be a nice front-end for a chess program.
Don't know if it would be worth it to implement the AI in Lua but as a front end it could work really well.

Re: Chess.lua

Posted: Tue Jun 02, 2015 10:12 am
by ivan
Attached is a rendering demo using fonts. The drawing routine is slow and highly inefficient but looks cool, so I'll post it.

Re: Chess.lua

Posted: Tue Jun 02, 2015 10:22 am
by Nixola
ivan wrote:(somebody removed quads from Love 0.9 and I'm too lazy to read the docs)
Since you're too lazy to go to the docs, I'll bring you them:
lg.drawq wrote:Removed in LÖVE 0.9.0
It has been merged into love.graphics.draw
lg.draw wrote:Available since LÖVE 0.9.0
It has replaced love.graphics.drawq

Synopsis:
love.graphics.draw( image, quad, x, y, r, sx, sy, ox, oy, kx, ky )