Coding Adventure: Chess AI

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor »

lithander wrote: Sat Feb 20, 2021 2:55 am In all seriousness: If there's any interest I can clean my hack up a little and put it on github.
What hack?

If you add QSearch and MVV-LVA move sorting, the engine WILL gain a few hundred Elo-points.

I'm trying to gain a few hundred by adding a hash table... but I want to do it by making a generic hash table (so, not implement 3 hash tables, for searching, perft, and pawns) but in Rust generics + traits are so much harder to get right than it is in the object oriented way of doing things (probably I've not had enough practice with generics + traits just yet).
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

mvanthoor wrote: Sat Feb 20, 2021 1:39 pm What hack?
I gutted MinimalChess so that only the UCI part remained. Then copied all the relevant code files from Sebastian Lague Unity project, removed every dependency on Unity (which was the hardest part) and modified it until it compiled and then called his search instead of mine. Just to make sure my joke isn't accidently taken serious by someone: The "Fat MinimalChess" I talked about earlier was 99% based on the Chess-AI he presented in his video and to which he put the source on github. I did nothing except downgrading it from a full featured Unity-based chess program with GUI into a rudimentary UCI chess engine.
Last edited by lithander on Sat Feb 20, 2021 2:42 pm, edited 1 time in total.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor »

lithander wrote: Sat Feb 20, 2021 2:55 am So, allow me to present to you Fat MinimalChess! :twisted:
...
Now, all that's left to do is to remove all traces of Sebastian Lague from the source code and slap a price tag on it. Would you think 99€ to be excessive?
Ouch...

But you bring up a good point. Why, in Heaven's name, would anyone pay any money for an engine that plays Western Chess? There are 50 bazillion engines out there, and anything over CCRL 2850 is more than strong enough to analyze our own amateurisch, error-riddled games, because engines like that have kept grand masters in their prime days to a draw.

People who're still stating that you have to run an engine like Stockfish for hours, on strong hardware, to "get a somewhat decent analysis" should get their behind out of the 80's and into the 21st century... where a random laptop (or maybe even a phone) has the computing power of a super computer from the days of back there.

Personally, I'd not pay money anymore for a western chess engine. In fact, after my engine reaches somewhere around 2850, I'll switch to my own engine for analyzing my own games.

The one thing I'd pay good money for is a good, cross-platform GUI, that takes a few things into account:
- modern user interface, that can be scaled well on high-dpi screens.
- that user interface also needs to take into account that there are many people with poor vision -> thus, ability to resize fonts
- don't jangle around with skeuomorphic interfaces (wooden panels and such) because interfaces in the past did this. Some nice light/dark modes are enough, and some themes for the chess board.
- If at all possible, good support for a DGT-board.

Well... PicoChess runs on Linux (but not on Windows, thanks to some very Linux-specific Python libraries it uses)... but the point is that it has, somewhere, some functions written that communicate with the DGT board and clock. At some point I'm probably going to lift them out and turn them into a Rust module.

Then I'll be able to write both my own PicoChess-like service, and my own user interface.

See you in 10 years or so... told you this would be a very long-term project.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor »

lithander wrote: Sat Feb 20, 2021 2:38 pm I gutted MinimalChess so that only the UCI part remained. Then copied all the relevant code files from Sebastian Lague Unity project, removed every dependency on Unity (which was the hardest part) and modified it until it compiled and then called his search instead of mine. Just to make sure my joke isn't accidently taken serious by someone: The "Fat MinimalChess" I talked about earlier was 99% based on the Chess-AI he presented in his video and to which he put the source on github. I did nothing except downgrading it from a full featured Unity-based chess program with GUI into a rudimentary UCI chess engine.
Cool. If the software is open source (GPLv3, MIT, or something compatible), then you could fork his repository, and derive "Ucinity Chess" from it. Just state that you took his Unity chess engine, and replaced the Unity GUI with the Uci Interface from MinimalChess (which creates Ucinity Chess) so the engine can be run in a chess user interface.

If there's a binary available, I'd be happy to run some quick tests, and CCRL will probably test it at some time.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
odomobo
Posts: 96
Joined: Fri Jul 06, 2018 1:09 am
Location: Chicago, IL
Full name: Josh Odom

Re: Coding Adventure: Chess AI

Post by odomobo »

lithander wrote: Sat Feb 20, 2021 2:38 pm I gutted MinimalChess so that only the UCI part remained. Then copied all the relevant code files...
So I was planning on doing this, because I'd like a UCI (or CECP) version of his engine to play around with. Since you already did the work, can you name it something appropriate, credit Sebastian, and publish it on GitHub? I'm sure I'm not the only person who would like this. It'd also be interesting to see how it fares against other engines.
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

odomobo wrote: Sat Feb 20, 2021 7:27 pm So I was planning on doing this, because I'd like a UCI (or CECP) version of his engine to play around with. Since you already did the work, can you name it something appropriate, credit Sebastian, and publish it on GitHub? I'm sure I'm not the only person who would like this. It'd also be interesting to see how it fares against other engines.
I was thinking of doing that tonight and naming the repository "SebLagueChessEngine" because that's what his username on Github is. Is that appropriate enough? ;) (No, it's not going to be named Fat MinimalChess... that was a joke. With the forum being saturated with threads about FatFritz 2 I thought that would be obvious enough)

I'm open for naming suggestions if they reach me within the next ~2 hours^^
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor »

Ucinity Chess

Engine by Sebastian, Unity replaced by Uci by me (you: you know what I mean).
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
odomobo
Posts: 96
Joined: Fri Jul 06, 2018 1:09 am
Location: Chicago, IL
Full name: Josh Odom

Re: Coding Adventure: Chess AI

Post by odomobo »

lithander wrote: Sat Feb 20, 2021 7:38 pm I'm open for naming suggestions...
It doesn't feel right giving it a name that he didn't provide. "SebLagueChessEngine" is pretty descriptive. Some other options are "SebLagueChessAI" or "CodingAdventureChessAI", since "Chess AI" is the closest thing to a name that it has.
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

Windows Build & Source Code available here:
https://github.com/lithander/SebLagueChessEngine
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor »

lithander wrote: Sun Feb 21, 2021 12:28 am Windows Build & Source Code available here:
https://github.com/lithander/SebLagueChessEngine
I just ran two tests of this engine in CuteChess:

Score of Rustic 2021-02-15 vs SebLague 0.1: 73 - 15 - 12 [0.790]
... Rustic 2021-02-15 playing White: 40 - 5 - 5 [0.850] 50
... Rustic 2021-02-15 playing Black: 33 - 10 - 7 [0.730] 50
... White vs Black: 50 - 38 - 12 [0.560] 100
Elo difference: 230.2 +/- 78.1, LOS: 100.0 %, DrawRatio: 12.0 %
100 of 100 games finished.

Rustic: 1680
SebLague: ~1450

Score of SebLague 0.1 vs Dreamer 0.3: 40 - 52 - 8 [0.440]
... SebLague 0.1 playing White: 17 - 28 - 5 [0.390] 50
... SebLague 0.1 playing Black: 23 - 24 - 3 [0.490] 50
... White vs Black: 41 - 51 - 8 [0.450] 100
Elo difference: -41.9 +/- 66.5, LOS: 10.5 %, DrawRatio: 8.0 %
100 of 100 games finished.

Dreamer: 1581
SebLague: ~1540

I think the Elo-rating of the engine can be tentatively estimated at around 1500 Elo, +/- 40 points.

To be honest I had hoped that it would have been a bit stronger. Compared to Rustic Alpha 1:
- It has pin detection and other move generator tricks to make a fully legal move generator
- It has a transposition table already
- It has a somewhat more advanced evaluation function

Maybe the hash table was disabled; I don't know. There are no settings in the UCI dialog, so I just ran the program by default.

Still, even if the only thing it does is provide another STABLE engine around the 1500 region, it will be useful. I've tried too many engines under 1500 (when I was first testing Rustic half a year ago) that are just... blergh. Often just a piece of code on Github, without documentation, hard to compile, and if one succeeds, they're unstable, or make illegal moves and are thus killed by CuteChess. This engine performed admirably in that regard. If someone would add move stats / output the PV through the UCI interface, this engine would be a fine first target for new engine programmers.

The video is excellently done by the way. I could see this guy narrating RPG's and game cutscenes.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL