Coding Adventure: Chess AI

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Harald
Posts: 317
Joined: Thu Mar 09, 2006 1:07 am

Coding Adventure: Chess AI

Post by Harald »

I just found this video from Sebastian Lague (Feb 12, 2021):
Coding Adventure: Chess AI


Chess programming looks so easy! :-)
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

It is really interesting how one can condense the work of hours into a few minutes of video and it still feels like you're watching someone over the shoulder and don't realize how sped up, cut and 'faked' everything is.

I also tried to document my journey of writing my first engine with a video series on Youtube. And I totally underestimated how much effort it takes to make such effortless seeming videos. I spent many more hours on the videos than on the code I'm showing there.
For example just figuring out the overall narration and then writing it down before you speak it so it's somewhat coherent and fluent and then cut the video to match it and then iterate on all that. I spent 5-10 hours on 15 minutes of video.

Of course this may change with more experience but I know I have gained a lot of newfound respect for content creators on Youtube!
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Coding Adventure: Chess AI

Post by Henk »

My video's did not get more then 100 views. Last video took two years of work.
hi hi hi hi. I mean the work to get user interface running.
Maybe I had better produce digital paintings for I can't paint. So result is the same. Nothing.
Mike Sherwin
Posts: 860
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Coding Adventure: Chess AI

Post by Mike Sherwin »

Harald wrote: Tue Feb 16, 2021 3:49 pm I just found this video from Sebastian Lague (Feb 12, 2021):
Coding Adventure: Chess AI


Chess programming looks so easy! :-)
Unity was used to write this chess app. Therefore C# is the programming language. When I played against the app the quality of the moves seem to be way better than what the source code should produce. I had an easier time playing against SF at 7 ply than against this engine that searches 5 to 7 play and may reach 9 ply in the endgame. The Eval of this engine is not much more than static piece square tables with an adjustment between middlegame and endgame. Maybe there is more but I did not see it.

There is a new programming language called Beef that is compiled C# with extensions that uses LLVM as a backend. It should be trivial to get this engine working as a Winboard or UCI engine using Beef. I want to learn Beef anyway so maybe I'll give it a try.
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

Mike Sherwin wrote: Wed Feb 17, 2021 9:37 pm Maybe there is more but I did not see it.
The interpolation between midgame and endgame is only used for the King. All other types have only a single PST. I think it's a pretty faithful implementation of this:
https://www.chessprogramming.org/Simpli ... n_Function

But there's another interesting tweak to the evaluation for the endgame that is called MopUpEval in the evaluation code and described in the video at this timecode
Mike Sherwin wrote: Wed Feb 17, 2021 9:37 pm It should be trivial to get this engine working as a Winboard or UCI engine using Beef. I want to learn Beef anyway so maybe I'll give it a try.
It would be even more trivial to get the engine working as a UCI engine using C# ;)
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: Thu Feb 18, 2021 3:17 pm It would be even more trivial...
IT-person: "It's trivial to get this to work." (<- air of confidence)
Manager: "OK, that's great. Could you fix this before tomorrow, 10:00? Thanks."
IT-person: :shock: "... Sure deal." ("I'm so f****...)

Me: "This is gonna take some time... maybe 2-3 days. Friday... thursday, if we're lucky."
Manager: "Hm... not great, but we'll manage in those days. So Friday it is?"
Me: "Sure thing." ("That went well." *whistle*)


- "You didn't tell him how long it would REALLY take, did you?"
- "You got a lot to learn if you want people to think of you as a miracle worker."

*whistle*
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

And Friday you realize that your estimate was in fact not considering complication X, Y and Z which of course only surfaced after you started working on the task. Right? ;)
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: Thu Feb 18, 2021 7:13 pm And Friday you realize that your estimate was in fact not considering complication X, Y and Z which of course only surfaced after you started working on the task. Right? ;)
LOL, nope.

"How long is this going to take?"
- "Hm.... about (4 hours) 4 days... if there are no complications."

In time, I have learned to pad time estimates quite generously, because there are ALWAYS complications. (But 4 hours -> 4 days is a bit tongue-in-cheek, obviously.)
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander »

lithander wrote: Thu Feb 18, 2021 3:17 pm It would be even more trivial to get the engine working as a UCI engine using C# ;)
Well, that was meant as a purely rethorical statement...
mvanthoor wrote: Thu Feb 18, 2021 7:36 pm "How long is this going to take?"
- "Hm.... about (4 hours) 4 days... if there are no complications."
...but after this I couldn't stop wondering how long it would really take.

So, allow me to present to you Fat MinimalChess! :twisted:

The new MinimalChess gains HUNDREDS of ELO over the previous version of MinimalChess. When do you ever see that kind of improvement in new versions of Stockfish, eh? It also dominates Sargon which only recently (1978) won a computer chess tournament with a score of 5–0.

The following test results will give testament to the claim that Fat MinimalChess is arguably™ the strongest entity that has ever played chess.

Code: Select all

Rank Name                          Elo     +/-   Games   Score    Draw 
   1 Fat MinimalChess              390     136      73   90.4%    8.2% 
   2 Sargon 1978                     0      74      73   50.0%   15.1% 
   3 MinimalChess 0.2             -379     136      74   10.1%    6.8% 

110 of 150 games finished.
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?

---

In all seriousness: If there's any interest I can clean my hack up a little and put it on github.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Coding Adventure: Chess AI

Post by Henk »

mvanthoor wrote: Thu Feb 18, 2021 7:36 pm
lithander wrote: Thu Feb 18, 2021 7:13 pm And Friday you realize that your estimate was in fact not considering complication X, Y and Z which of course only surfaced after you started working on the task. Right? ;)
LOL, nope.

"How long is this going to take?"
- "Hm.... about (4 hours) 4 days... if there are no complications."

In time, I have learned to pad time estimates quite generously, because there are ALWAYS complications. (But 4 hours -> 4 days is a bit tongue-in-cheek, obviously.)
If your manager would ask to add four more rows to the chess board. How long would it take to get engine running.
Two minutes? For you only have to set number of rows to 12? Or one or two months because that would mean to almost start all over again.

Bitboards only work for 64 bits. Or you have to make it generic. Also have to regenerate suitable magic numbers.