Wukong JS - chess engine with UCI support, own GUI and public API

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

Moderators: hgm, Rebel, chrisw

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

Wukong JS - chess engine with UCI support, own GUI and public API

Post by maksimKorzh »

Hi guys

I'd like to expose in public the first results regarding my new project:
Pure JavaScript Chess engine that has own GUI, can play play versus other engines via UCI (using nodejs)
and has a small public API (used in both interfaces) so it can be embedded to third party websites.

Play online (faster in Chrome, slower in Firefox): https://maksimkorzh.github.io/wukongJS/wukong.html
Source code: https://github.com/maksimKorzh/wukongJS

I also have a few words to say to those of you who know me.
You know like I've been doing lots of stuff recently, but quite often used
cheats and hacks to promote my youtube channel. None of that stuff with this project.
I'm doing it 100% for myself - no more NNUE copypasting, no more CPW snippets copypasting.
I've been working on the look of source code the most, so PLEASE have a look at the source code,
especially generateMoves() and isSquareAttacked() functions - want to get your feedback regarding
refactoring I'm proud of)))

Generally it would most likely be interesting for programmers, because the most of work I put into it
relies within the architecture and code itself.

Regarding playing style and strength - after 5+ years of chess programming I must admit that I'm a noob
and probably be that until the dying day - that's the reason of considering RELATIVE strength improvement
instead of absolute - I would probably never master NNUE but I want to make this engine play in an agressive
tactical style like Fritz 5-12 did. That's the major approach regarding the further development.

This is just a random success, for now it losses to TSCP all the games
[pgn]
[Event "Computer chess game"]
[Site "maksim-Inspiron-3582"]
[Date "2020.12.18"]
[Round "?"]
[White "TSCP"]
[Black "WukongJS"]
[Result "0-1"]
[BlackElo "2000"]
[ECO "A25"]
[Opening "English"]
[Time "20:51:16"]
[Variation "Closed, 3.g3 Nf6"]
[WhiteElo "1723"]
[TimeControl "120+1"]
[Termination "normal"]
[PlyCount "68"]
[WhiteType "program"]
[BlackType "program"]

1. c4 e5 {(e7-e5 Nb1-c3 Nb8-c6 Ng1-f3 Bf8-c5 e2-e4) -0.00/6 4} 2. g3 Nf6
{(Ng8-f6 Nb1-c3 Bf8-c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 Ra2xd2)
+15.00/5 2} 30. Kd1 {(e1d1 e4d3 d1e1 d3c2 h3h4 a3a2 g3g4 d4f2) -14.62/5 2}
Qd3+ {(Qe4-d3+ Kd1-e1 Qd3xc2 h3-h4 Ra3xa2 Rh2-h3) +16.05/5 2} 31. Ke1
{(d1e1 d3c2 e1f1 c2b1 f1g2 a3a2 h2h1 b1b5) -15.34/5 2} Qxc2 {(Qd3xc2 h3-h4
Qc2-b1+ Ke1-e2 Ra3xa2+ Ke2-f3 Qb1xb5) +16.25/5 2} 32. Kf1 {(e1f1 a3f3 f1e1
d4f2 h2f2 c2f2 e1d1 f3g3) -17.03/6 2} Rxa2 {(Ra3xa2 h3-h4 Qc2-d3+ Kf1-g1
Qd3xg3+ Rh2-g2 Bd4xf2+) +17.05/5 2} 33. h4 {(h3h4 c2e4 g3g4 a2a1) -99.96/5
0} Qe4 {+M2/5 2} 34. Kg1 {(f1g1 a2a1) -99.98/3 0} Ra1# {+M1/5 2} 0-1
[/pgn]
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Wukong JS - chess engine with UCI support, own GUI and public API

Post by maksimKorzh »

I've separated UCI module from engine so from now on engine can be used as a library.
I've added some API usage examples, pretty basic at the moment but already usable.

API function declarations: https://github.com/maksimKorzh/wukongJS
API usage examples: https://github.com/maksimKorzh/wukongJS ... ain/API.MD

Works for both browser and nodejs only the init is slightly different.