Is there a "Hello World" or MVP of chess programming?

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

Moderator: Ras

smatovic
Posts: 3169
Joined: Wed Mar 10, 2010 10:18 pm
Location: Hamburg, Germany
Full name: Srdja Matovic

Re: Is there a "Hello World" or MVP of chess programming?

Post by smatovic »

jaroslav.tavgen wrote: Thu Feb 13, 2025 10:16 am [....]
I don't understand how can you learn from MSCP. The source code is unreadable.
Then try Micro-Max ;)

--
Srdja
jaroslav.tavgen
Posts: 12
Joined: Fri Oct 25, 2019 2:51 pm
Full name: Jaroslav Tavgen

Re: Is there a "Hello World" or MVP of chess programming?

Post by jaroslav.tavgen »

smatovic wrote: Thu Feb 13, 2025 10:49 am
jaroslav.tavgen wrote: Thu Feb 13, 2025 10:16 am [....]
I don't understand how can you learn from MSCP. The source code is unreadable.
Then try Micro-Max ;)

--
Srdja
Thank you! Will take a look at it.

Oh, it was a joke! Micro-Max is the standard for undeadability.
User avatar
lithander
Posts: 912
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Is there a "Hello World" or MVP of chess programming?

Post by lithander »

My Hello World (first step) program was just talking to a chess GUI using the uci interface. It was hardcoded to move the king's pawn.

The next step would be an engine that plays legal chess. If you can generate the legal moves in a given position you can just pick one randomly.

The next step is to use a simple search algorithm like Minimax. It will require a way to compare two different positions, counting material is the simplest way to do that.

(this is how I started after watching Queen's Gambit and I even documented it in 4 Youtube videos)
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
jaroslav.tavgen
Posts: 12
Joined: Fri Oct 25, 2019 2:51 pm
Full name: Jaroslav Tavgen

Re: Is there a "Hello World" or MVP of chess programming?

Post by jaroslav.tavgen »

lithander wrote: Thu Feb 13, 2025 11:55 am My Hello World (first step) program was just talking to a chess GUI using the uci interface. It was hardcoded to move the king's pawn.

The next step would be an engine that plays legal chess. If you can generate the legal moves in a given position you can just pick one randomly.

The next step is to use a simple search algorithm like Minimax. It will require a way to compare two different positions, counting material is the simplest way to do that.

(this is how I started after watching Queen's Gambit and I even documented it in 4 Youtube videos)
But this is not enough. Every single person on this forum would beat a chess engine that uses only Minimax. That's why I am interested in "minimum set" of the engine that plays somewhat decent.

Minimax is a must, Alpha Beta pruning is a must. But is a Quiescence? Or search killers/killer moves? Or Mvva? Or a Principle Variation?
User avatar
lithander
Posts: 912
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Is there a "Hello World" or MVP of chess programming?

Post by lithander »

you have to define "somewhat decent" then! There are a lot of simple techniques that - piled together - quickly get you to something like 2000 Elo which most casual chess players will find hard to beat.

After Minimax works you can add Iterative Deepening search with Alpha-Beta pruning that collects just the Principal Variation and when available plays PV moves first. Even when you still evaluate by counting material this should get you close to 1000 Elo, already. Adding Q-Search would push you beyond and make the engine look much less stupid. The simple MVV-LVA move ordering will give another big boost. At some point you should add Piece-Square-Tables instead of assuming a piece has a fixed material value... adding Transposition Tables are also a huge win at this point.

...the sequence in which you add features is not super critical and you can just stop when you feel your engine has reached that MVP stage. Quiescence, MVV-LVA and Principle Variation are quite important. Killers not so much. I'd rather go for the TT at that point. And a better eval.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
jaroslav.tavgen
Posts: 12
Joined: Fri Oct 25, 2019 2:51 pm
Full name: Jaroslav Tavgen

Re: Is there a "Hello World" or MVP of chess programming?

Post by jaroslav.tavgen »

lithander wrote: Thu Feb 13, 2025 1:06 pm you have to define "somewhat decent" then! There are a lot of simple techniques that - piled together - quickly get you to something like 2000 Elo which most casual chess players will find hard to beat.

After Minimax works you can add Iterative Deepening search with Alpha-Beta pruning that collects just the Principal Variation and when available plays PV moves first. Even when you still evaluate by counting material this should get you close to 1000 Elo, already. Adding Q-Search would push you beyond and make the engine look much less stupid. The simple MVV-LVA move ordering will give another big boost. At some point you should add Piece-Square-Tables instead of assuming a piece has a fixed material value... adding Transposition Tables are also a huge win at this point.

...the sequence in which you add features is not super critical and you can just stop when you feel your engine has reached that MVP stage. Quiescence, MVV-LVA and Principle Variation are quite important. Killers not so much. I'd rather go for the TT at that point. And a better eval.
lithander, thank you very much for this summarizing!
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Is there a "Hello World" or MVP of chess programming?

Post by Henk »

I can supply some "bye world"code. Some code for move generation that was so optimized that nobody understands it.
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Is there a "Hello World" or MVP of chess programming?

Post by Mike Sherwin »

jaroslav.tavgen wrote: Thu Feb 13, 2025 10:53 am
smatovic wrote: Thu Feb 13, 2025 10:49 am
jaroslav.tavgen wrote: Thu Feb 13, 2025 10:16 am [....]
I don't understand how can you learn from MSCP. The source code is unreadable.
Then try Micro-Max ;)

--
Srdja
Thank you! Will take a look at it.

Oh, it was a joke! Micro-Max is the standard for undeadability.
Micro-Max has a readable version here https://home.hccnet.nl/h.g.muller/maximax.txt
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Is there a "Hello World" or MVP of chess programming?

Post by Mike Sherwin »

This is an interesting topic. For many years and probably still, TSCP is a good if not best starting point. But it also has problems. The coding style can be confusing especially how it uses structures. And the constant translating between a board8x8[64] and a board12x10[120] is very annoying. And it is too slow.

In my opinion what is needed is a modern engine with just the very basic TSCP like search and evaluation features but also runs a bit faster. And it should be written in two languages, QB64 BASIC and C++. BASIC for those that do not know C++ and C++ because it is most popular. Then we need to put the two versions on a web site where they can be downloaded from. The C++ version will run in a class so that a multi-threaded version can follow. And authors can add features and upload those feature added versions.

I would do it but I'm too old. :lol:

Still it would be nice if something like that existed! :D
User avatar
hgm
Posts: 28321
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Is there a "Hello World" or MVP of chess programming?

Post by hgm »

jaroslav.tavgen wrote: Thu Feb 13, 2025 10:53 am Oh, it was a joke! Micro-Max is the standard for undeadability.
Micro-Max was written as an experiment for how small a source code could be, and not to be an educational example. As a result it uses mostly meaningless one-character variable names.

But there does exist a version that uses meaningful variable names: https://home.hccnet.nl/h.g.muller/maximax.txt . This should not be very difficult to understand, because it is still very small, if not in number of characters then in number of statements. And in addition it is heavily commented, and there are some 20 pages of a tutorial description on what exactly the code is designed to do.