Chess.lua

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Chess.lua

Post 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
Attachments
chess.love
frontend
(24.06 KiB) Downloaded 491 times
Last edited by ivan on Sat Dec 11, 2021 8:29 am, edited 8 times in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Chess.lua

Post 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'
:(
Help us help you: attach a .love.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post by ivan »

Hey Robin, I must be using a different version of Love2d, could you please try again?
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: Chess.lua

Post by qubodup »

No problem with LOVE 0.9.2 on Linux.
Image
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Chess.lua

Post by Robin »

The new version works fine!
Help us help you: attach a .love.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post 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.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post 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
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post 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.
Attachments
chess.love
moves validation demo
(24.06 KiB) Downloaded 328 times
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess.lua

Post 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.
Attachments
multiview.love
(24.15 KiB) Downloaded 299 times
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Chess.lua

Post 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 )
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests