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.
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
Chess
Re: Chess
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
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.
Re: Chess
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
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
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
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 12 guests