Chess

Show off your games, demos and other (playable) creations.
Post Reply
mhazaza
Prole
Posts: 4
Joined: Thu Oct 08, 2020 2:43 pm

Chess

Post by mhazaza »

This is a very basic chess app.
Check, Mate, Stalemate, En Passant, Castling, Threefold Repetition and 50-Move Rule works.
The king lights up red on Checkmate and brown when a draw occurs.
LuaChess.love
(477.92 KiB) Downloaded 156 times
Key Controls
F --> flip Board
C --> switch Board color
S --> switch style of pieces
V ---> trigger fullscreen on/off
Left --> last turn
Right --> next turn
2,3,4 --> hold number for under promotion (quick fix)

Also all the piece-png's are literally stolen from marcelk.net/chess (the site seems not to have a safe connection).
Anyway, have a great day and keep on keeping this ultra awesome framework alive and well.

Edit: Added a basic movelist which adjusts to window space and reacts on mouseclick.
Edit: no more buggy movelist

https://github.com/halimbo/luachess
Last edited by mhazaza on Fri Feb 11, 2022 12:49 am, edited 46 times in total.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Chess

Post by ivan »

Not bad. I see you already have En-passant working so that's pretty good.
Good job at separating your logic code (which is in pure Lua) from the rest of the Love2d functions.
I'm not crazy about your use of closures which reminds me of JavaScript.
In general there is a lot that can be optimized and streamlines in your code.
Also, there is some silly stuff like your "unsign" function. Why not just use math.abs instead of "unsign"?
Having said that, your code is probably better than most of the chess stuff I have seen on this forum so good job there.

By the way, I'm the developer behind the following library:
https://github.com/2dengine/chess.lua
Last edited by ivan on Sat Dec 11, 2021 8:19 am, edited 1 time in total.
mhazaza
Prole
Posts: 4
Joined: Thu Oct 08, 2020 2:43 pm

Re: Chess

Post by mhazaza »

I didn't research any standard libraries, my goal was to do as much on myself as possible...it's kind of silly i guess :D
Yeah you're totally right about the "Call" metamethod nonsense. I'm definitely gonna clean that up soon.
The reason i did this was because a few weeks ago i was obsessed with having the pieces flip one square at a time via love.update in 60 frames per second. so i had to find a way to have an iteration which persists over multiple calls. i ended up using similar code for the move generation and just did the whole iteration at once recursively. i just kept it because it worked accurately. thanks a lot for pointing this out and even taking the time to look through my code <3
gonna check out your lib now
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 72 guests