Chess engine with GUI in under ~250 lines of JS code

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

User avatar
maksimKorzh
Posts: 785
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Chess engine with GUI in under ~250 lines of JS code

Post by maksimKorzh »

User avatar
towforce
Posts: 13463
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Re: Chess engine with GUI in under ~250 lines of JS code

Post by towforce »

Very good!

* can the pieces be clearer? Maybe loaded as images?

* I know the idea is to be a tiny program - but it would be lovely to have a way to save the game as a PGN
Human chess is partly about tactics and strategy, but mostly about memory
User avatar
maksimKorzh
Posts: 785
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Chess engine with GUI in under ~250 lines of JS code

Post by maksimKorzh »

Thank you, I think this is closer to what you are looking for:
https://github.com/maksimKorzh/wukongJS
User avatar
towforce
Posts: 13463
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Re: Chess engine with GUI in under ~250 lines of JS code

Post by towforce »

maksimKorzh wrote: ↑Sat Oct 31, 2026 1:05 am Thank you, I think this is closer to what you are looking for:
https://github.com/maksimKorzh/wukongJS
Perfect! Direct link: https://maksimkorzh.github.io/wukongJS/wukong.html

The first game at the default (max) level ended in an incorrect outcome, so I won't post the pgn here. :)
Human chess is partly about tactics and strategy, but mostly about memory
User avatar
maksimKorzh
Posts: 785
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Chess engine with GUI in under ~250 lines of JS code

Post by maksimKorzh »

towforce wrote: ↑Fri Nov 06, 2026 3:39 pm
maksimKorzh wrote: ↑Sat Oct 31, 2026 1:05 am Thank you, I think this is closer to what you are looking for:
https://github.com/maksimKorzh/wukongJS
Perfect! Direct link: https://maksimkorzh.github.io/wukongJS/wukong.html

The first game at the default (max) level ended in an incorrect outcome, so I won't post the pgn here. :)
First, this is the link to a completely different project, not the one the post is about.

Second, what do you mean by default max level? Default is 1 sec per move, max is 1 min

What do you min by wrong outcome?
User avatar
towforce
Posts: 13463
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Re: Chess engine with GUI in under ~250 lines of JS code

Post by towforce »

maksimKorzh wrote: ↑Fri Nov 06, 2026 4:15 pm
towforce wrote: ↑Fri Nov 06, 2026 3:39 pm
maksimKorzh wrote: ↑Sat Oct 31, 2026 1:05 am Thank you, I think this is closer to what you are looking for:
https://github.com/maksimKorzh/wukongJS
Perfect! Direct link: https://maksimkorzh.github.io/wukongJS/wukong.html

The first game at the default (max) level ended in an incorrect outcome, so I won't post the pgn here. :)
First, this is the link to a completely different project, not the one the post is about.

Second, what do you mean by default max level? Default is 1 sec per move, max is 1 min

What do you min by wrong outcome?
Sorry - I caused confusion by waiting for a week before replying!

I reviewed the 250 line engine, you recommend I tried the fully-featured engine, which turned out to be better for me. On that engine, the levels are 1876 Elo (default), 1700 Elo, 1500 Elo and 1000 Elo.

The "wrong outcome" was that the engine won instead of myself. I will fix this unconscionable error by selecting a lower level for the next game! :)
Human chess is partly about tactics and strategy, but mostly about memory
User avatar
maksimKorzh
Posts: 785
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Chess engine with GUI in under ~250 lines of JS code

Post by maksimKorzh »

towforce wrote: ↑Fri Nov 06, 2026 6:28 pm
maksimKorzh wrote: ↑Fri Nov 06, 2026 4:15 pm
towforce wrote: ↑Fri Nov 06, 2026 3:39 pm
maksimKorzh wrote: ↑Sat Oct 31, 2026 1:05 am Thank you, I think this is closer to what you are looking for:
https://github.com/maksimKorzh/wukongJS
Perfect! Direct link: https://maksimkorzh.github.io/wukongJS/wukong.html

The first game at the default (max) level ended in an incorrect outcome, so I won't post the pgn here. :)
First, this is the link to a completely different project, not the one the post is about.

Second, what do you mean by default max level? Default is 1 sec per move, max is 1 min

What do you min by wrong outcome?
Sorry - I caused confusion by waiting for a week before replying!

I reviewed the 250 line engine, you recommend I tried the fully-featured engine, which turned out to be better for me. On that engine, the levels are 1876 Elo (default), 1700 Elo, 1500 Elo and 1000 Elo.

The "wrong outcome" was that the engine won instead of myself. I will fix this unconscionable error by selecting a lower level for the next game! :)
I thought wrong outcome means incorrect pgn data, thank God that's not the case)
Another engine you liked more, WukongJS, is something I use quite often to play with, mostly as
progressive web application installed to the phone and using mobile version.

This one is not intended as an end user product but as an example of how little code one can use to get a complete engine,
for example first 2 functions of this engine form a complete standalone chessboard library with move validation - just two little
functions instead of tons of code and another little function already can beat a beginner.