Xiangqi chess engine in javascript - YouTube tutorial series

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

Xiangqi chess engine in javascript - YouTube tutorial series

Post by maksimKorzh »

Hi guys

I've just started new tutorial series on youtube - this time we gonna be implementing Xiangqi (Chinese chess) engine
in javascript from scratch, Web and UCCI (UCI dialect for CHinese chess) interfaces would be available like in WukongJS.

We've just started so feel free to join this exciting journey!


Development progress:
https://github.com/maksimKorzh/wukong-xiangqi
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by mvanthoor »

I love this... the only thing I can say is: could you make a tutorial about how to get 38 hours into a single day?

Even if I'd work on chess all the time next to my day job I couldn't hope to match your output... not even mentioning that I don't want to neglect either my girlfriend, or my piano practice (and I also want to read some books in the meantime too).

I've dabbled in Go for some time (reached about 5 kyu) and looked into Shogi, but the ultimate reason I put them aside is because there are no Electronic / DGT-boards available to play those games.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by hgm »

BTW, note that HaQiKi D is also available as Linux binary: http://hgm.nubati.net/haqikid . And MaxQi is in the Debian and Ubuntu fairymax packages. I think that both engines are also available in the XBoard Xiangqi App for OS X.
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by maksimKorzh »

mvanthoor wrote: Sun Jan 24, 2021 7:45 pm I love this... the only thing I can say is: could you make a tutorial about how to get 38 hours into a single day?

Even if I'd work on chess all the time next to my day job I couldn't hope to match your output... not even mentioning that I don't want to neglect either my girlfriend, or my piano practice (and I also want to read some books in the meantime too).

I've dabbled in Go for some time (reached about 5 kyu) and looked into Shogi, but the ultimate reason I put them aside is because there are no Electronic / DGT-boards available to play those games.
Having 38 hours a day is very simple - all you need is to consider freedom and following your own nature while taking paid jobs
and trying to avoid any sort of business bullshit at any cost. Then you'll be able to make money only around 15% of the time with
the same efficiency as if it was full time. Well, at least that's what I do) Meanwhile I have a wife and living in a private house in the village,
so no city, no apartments - lots of physical on housekeeping. And apart chess programming I'm also doing chinese martial arts for health
(sort of alternative to piano play, btw I ones was playing a bit as well)
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by maksimKorzh »

hgm wrote: Sun Jan 24, 2021 8:39 pm BTW, note that HaQiKi D is also available as Linux binary: http://hgm.nubati.net/haqikid . And MaxQi is in the Debian and Ubuntu fairymax packages. I think that both engines are also available in the XBoard Xiangqi App for OS X.
Already heavily testing them for a couple of days)
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by hgm »

Oh, I got the impression you were omly using the Windows versions, under wine.

Anyway, the Interactive Diagram also is a JavaScript engine that can play Xiangqi. It is quite weak, but that could make it fun to play against, for a beginner. (Which was its design goal.)
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by maksimKorzh »

hgm wrote: Sun Jan 24, 2021 10:50 pm Oh, I got the impression you were omly using the Windows versions, under wine.

Anyway, the Interactive Diagram also is a JavaScript engine that can play Xiangqi. It is quite weak, but that could make it fun to play against, for a beginner. (Which was its design goal.)
Cool! Thanks for sharing - I'll try it!
Also one of the goals for my xiangqi engine (apart from being highly didactic) is to serve as the playing partner for absolute beginners.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by hgm »

Another interesting web project that supports Xiangqi is Jocly. It is mainly a (3d) GUI, but, like the Interactive Diagram, it also contains a generic AI that can play any game you specify the rules for at a modest level. It is also written in JavaScript. The AI there uses an MCTS search, but the programmer has to specify piece values, and can add game-specific evaluation terms. The Interactive Diagram (which uses alpha-beta search) is configured by just the rules, and estimates the piece values by itself.
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by maksimKorzh »

hgm wrote: Mon Jan 25, 2021 9:59 am Another interesting web project that supports Xiangqi is Jocly. It is mainly a (3d) GUI, but, like the Interactive Diagram, it also contains a generic AI that can play any game you specify the rules for at a modest level. It is also written in JavaScript. The AI there uses an MCTS search, but the programmer has to specify piece values, and can add game-specific evaluation terms. The Interactive Diagram (which uses alpha-beta search) is configured by just the rules, and estimates the piece values by itself.
I've found amazing resource as well:
- awesome GUI
- strong enine (well at least 12+ depth online)
- analyze game mode
- play with a fiend mode

http://www.xichess.com/
Also guy has an awesome YouTube channel (where I found him) - he's analyzing GM's games - fantastic resource
on what is "good" and what is "bad".

I've also started playing online myself to better understand the game flow - the interaction between pieces is fantastic.
Without looking to PST from other engines I already have a couple of ideas for PST values for my future values.

I'm now writing movegen. Unfortunately the list of FENs someone sent me has strange format (bigger board) but now
I can compose my own positions similar to Kiwipete in terms of "trickiness" - then run perft test of existing engine and
then compare results to my own.

HGM, I don't know whether it works or not bit I hope you would be proud of me in terms of coming up with absolutely my own movegen code.
I mean I was looking for different sources but for general observations and not implementation details so I just take rules and trying to
implement them as I can - that's the first time in my life when I do something completely on my own just like you do! e.g. today I am writing
isSquareAttacked(square, side) function and designing offset arrays to detect attacks by knight was amazing experience.
Well anyway perft tests would show how correct it is.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xiangqi chess engine in javascript - YouTube tutorial series

Post by hgm »

maksimKorzh wrote: Mon Jan 25, 2021 2:13 pmHGM, I don't know whether it works or not bit I hope you would be proud of me...
Well, whether it works or not would not be an unimportant detail for determining that. :wink:

The reason I am now rethinking move generation is that there also exists a game Janggi (Korean Chess), which is very much like Xiangqi (played with the same equipment), but even more awful w.r.t. the location-dependent move rules: Rooks and Cannons there can also move along the diagonal lines that are drawn in the Palace on a traditional board. And that means there effectively are finite-range sliders in that game, as a Rook on d0 could move diagonally to e1 and f2, but not any further, as that is where the diagonal line stops. If each piece could specify a different set of moves (range and direction) for every square it is on, that would make it easier to implement such weirdness.