Coding Adventure: Chess AI

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Harald
Posts: 297
Joined: Thu Mar 09, 2006 12:07 am

Coding Adventure: Chess AI

Post by Harald » Tue Feb 16, 2021 2:49 pm

I just found this video from Sebastian Lague (Feb 12, 2021):
Coding Adventure: Chess AI
https://www.youtube.com/watch?v=U4ogK0MIzqk

Chess programming looks so easy! :-)

User avatar
lithander
Posts: 75
Joined: Sun Dec 27, 2020 1:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander » Tue Feb 16, 2021 3:25 pm

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. My very first chess engine! Details on Youtube & Github

Henk
Posts: 6768
Joined: Mon May 27, 2013 8:31 am

Re: Coding Adventure: Chess AI

Post by Henk » Tue Feb 16, 2021 3:40 pm

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: 156
Joined: Thu Aug 20, 2020 11:25 pm
Full name: Michael J Sherwin

Re: Coding Adventure: Chess AI

Post by Mike Sherwin » Wed Feb 17, 2021 8:37 pm

Harald wrote:
Tue Feb 16, 2021 2:49 pm
I just found this video from Sebastian Lague (Feb 12, 2021):
Coding Adventure: Chess AI
https://www.youtube.com/watch?v=U4ogK0MIzqk

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: 75
Joined: Sun Dec 27, 2020 1:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander » Thu Feb 18, 2021 2:17 pm

Mike Sherwin wrote:
Wed Feb 17, 2021 8: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 8: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. My very first chess engine! Details on Youtube & Github

User avatar
mvanthoor
Posts: 768
Joined: Wed Jul 03, 2019 2:42 pm
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor » Thu Feb 18, 2021 2:59 pm

lithander wrote:
Thu Feb 18, 2021 2: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*)

https://www.youtube.com/watch?v=8xRqXYsksFg
- "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.
Releases | Code | Docs

User avatar
lithander
Posts: 75
Joined: Sun Dec 27, 2020 1:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander » Thu Feb 18, 2021 6: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? ;)
Minimal Chess. My very first chess engine! Details on Youtube & Github

User avatar
mvanthoor
Posts: 768
Joined: Wed Jul 03, 2019 2:42 pm
Full name: Marcel Vanthoor

Re: Coding Adventure: Chess AI

Post by mvanthoor » Thu Feb 18, 2021 6:36 pm

lithander wrote:
Thu Feb 18, 2021 6: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.
Releases | Code | Docs

User avatar
lithander
Posts: 75
Joined: Sun Dec 27, 2020 1:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Coding Adventure: Chess AI

Post by lithander » Sat Feb 20, 2021 1:55 am

lithander wrote:
Thu Feb 18, 2021 2: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 6: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. My very first chess engine! Details on Youtube & Github

Henk
Posts: 6768
Joined: Mon May 27, 2013 8:31 am

Re: Coding Adventure: Chess AI

Post by Henk » Sat Feb 20, 2021 11:58 am

mvanthoor wrote:
Thu Feb 18, 2021 6:36 pm
lithander wrote:
Thu Feb 18, 2021 6: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.

Post Reply