Your motivation for writing a chess engine?

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

Moderators: hgm, Rebel, chrisw

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

Your motivation for writing a chess engine?

Post by mvanthoor »

(Warning: massive ramble.)

Let's be honest; Alpha/Beta has been around since the late 1950's, and the method has known many optimizations and extensions. Board representations have evolved from the 10x12 bounded board to 0x88 (and many others) to rotated bitboards and magic bitboards. Hash tables, pruning techniques, sorting, and other ways of making the search tree smaller have been researched ad nauseaum.

Basically, everybody but his dog can have his or her own chess engine within a few months, just by researching the common techniques; and sometimes by just grabbing some code here or there if they're writing in C/C++. In the open source world nowadays, it's even possible to just start from any open source engine if you don't feel like putting in the work of writing your own.

You can go the NNUE-way, as an addition, or as a replacement for evaluation at some point, or built an MCTS function instead of Alpha-Beta. Those are details however; they can be added to an existing chess engine, or as replacements for existing functions. Nowadays, even these things aren't rocket science anymore. Given enough time, anyone with enough experience in writing software can research this.

Then why write a chess engine at all, nowadays?

For me, the reason of having my own engine was enough. I wanted that for a long time, but postponed it for 20 years because of other hobbies besides programming. And I didn't feel like to write the 500th engine in just C or C++, and I also didn't feel like putting lots of time into learning a programming language which I don't believe makes a chance to be used in place of C or C++ in the future.

Then Rust 1.0/2015 came along (I was watching that language for quite some time before that), and when the 2018 edition was released, I deemed it mature and stable enough to actually try to write some software in it. So, I embarked on writing my own chess engine, for no other reason than to write a chess engine, that is specifically mine, in a language that is not C or C++.

Do I use other engine's code?

No. However, sometimes I research topics, and I come across like a very convenient way of doing something. One example can be Marcel Kervinck's Carry Rippler. I understand WHAT it does, but because I'm not a mathematician, I can not "prove" that it is actually correct. I just assume it is, and use the Carry Rippler just like I would use a function in the standard library of the programming language, just as I'd use a vector.

I also look into other engine's code to see (for example) where/how they call the hash table exactly, and what they put in it. However, because I'm not writing in C or C++, I can't just grab that code; I have to understand the concept, and then rewrite it in Rust.

I don't think there's anything wrong with that; doing such things is called "learning", where you study the work of people that came before you. Inevitably, in people follow the path of "imitation, emulation, innovation": first they do what others did, then they do the same in a different way, and then they do their own thing. It's how people learn and gather knowledge.

But what about the rating lists? You can't ever hope to compete with Stockfish?

I can't, and I don't want to. There's no point in trying to do that. What I do, is just set my own targets:

- Build a basic engine with as high a rating as possible, without having an evaluation beyond material + PST. Features: only MVV-LVA, QSearch, Transposition Table, PV Move ordering, killers, history, and Texel Tuning of the PST's and material values, and that's it.
* Rustic Alpha 1 is the one with MVV-LVA and QSearch.
* Rustic Alpha 2 will have the TT and TT Move ordering
* Rustic Alpha 3 will have PV Move ordering, killers, and heuristics.
* Rustic 4 will be the Texel-tuned version of Alpha 3.
At that point the basic engine will be done.

- Defeat TSCP without having an evaluation in my engine, and without specifically programming to defeat TSCP (Elo 1725.)

- Surpass VICE (the legendary tutorial engine, Elo 2050) with the least amount of features built into my own engine. I'd love to get close or surpass it with the basic engine only, without actually having an evaluation function or any other function apart from what is mentioned above.

* Alpha 1 is Elo 1677.
* Alpha 2 will (hopefuly) gain 150 points, to 1827
* Alpha 3 hopefully gains +/- 70, to 1900
* Tuning may gain about 100, to +/- 2000.

I might just (not) make it with only the basic engine... we'll see.

- Hit the "magic" 2500 Elo mark to become a "grandmaster".

- Surpass Gandalf 7 (Elo 2667), because I'm a LotR fan and it's a commercial engine.

- Beat Fritz 11 (2888 Elo) "by proxy" (by using my own engine), in it's own GUI, at 5 minute + 10 seconds Blitz.

- Surpass Glaurung (Elo 2895), again because I'm a LotR fan, and because it's the direct predecessor to Stockfish.

- Hit 3000 Elo.

When I manage the last two points, I'll also probably be in the 2900 Elo range with my engine, and it will be stronger than the older versions of Stockfish. After the engine reaches 3000 Elo, I'll add Lazy SMP, and then I'll (probably) call it a day and only work on the engine when I feel like it.

Can I achieve that? Sure... given enough time, I think so, though it'll probably take me some years because I'm doing this in the evenings and weekends, and also have to do test runs.

Alongside the engine I'm writing a tutorial/book about the development of the engine (which will be at https://rustic-chess.org/ at some point, when I have sufficient stuff written), to gather most of the "common" knowledge in one place, such that if you follow/read that book, you have all the information necessary to write a chess engine in any programming language you want. It will probably turn out similar to the old Bruce Moreland site, or the TSCP one ( https://sites.google.com/site/tscpchess/home ), but hopefully a bit more modern. The older information is slowly getting lost/splintered across the internet; when researching, I'm finding topics archived somehwere, way back from the 90's, or the middle-2000's, but if somehwere, someone, decides that the archives aren't useful anymore... *poof* all gone. So I hope to be able to at least bring some of that information forward into a somewhat more modern representation in a newer programming language.

At some point, I also want to look into writing a new user interface (apart from the Fritz 11 GUI, and to some extent Banksia, I feel like the chess GUI's are stuck somewhere in the early 2000's), and lifting the DGT code out of PicoChess and write a similar program in Rust; because I think the PicoChess code can use some improvement (way too many nested if's, loops, and switches), and I just don't like Python. At all.

All of this will probably take at least a decade, next to a full-time job and many other hobbies; but that is no problem. I've always wanted some stuff to program on just for me, myself and I, but never knew what to program. You know; like the writer who wants to write a story but doesn't know what to write. It seems that Rust, as a programming language I really like (and feel could be an actual alternative to both C and C++ in the future), has given me the final push to actually begin at this.

All of it will be open source. I don't really mind if other people use it, or not. I'm writing this stuff to use for myself, and if it's useful to others, they can use it too. Especially with regard to the user interface (as I said; apart from Fritz 11, and to some extent, Banksia, I'm not too enamoured with the state and useability of current GUI's), and especially a Rust-version of PicoChess, I hope to provide something that isn't readily available. There are some programs, beside Fritz, that support the DGT-board to some level, but apart from Fritz and PicoChess, they all do a poor job (IMHO).
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
Kieren Pearson
Posts: 70
Joined: Tue Dec 31, 2019 2:52 am
Full name: Kieren Pearson

Re: Your motivation for writing a chess engine?

Post by Kieren Pearson »

It may not take as long as you think. Halogen gained ~1000 elo from Halogen 4 to Halogen 9 in only in 6 months.
User avatar
towforce
Posts: 11575
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: Your motivation for writing a chess engine?

Post by towforce »

Stop.

This is a naughty post. I shouldn't be telling other people what to do, and I shouldn't be telling people not to write chess programs in a computer chess forum. I know what I'm doing is bad: now nobody needs to tell me!

So here are some reasons why you should consider putting your chess program aside:

* your time is precious

* you're not doing anything for your family (except taking time away from them)

* you're not doing anything for yourself (the programming skills that work in chess (max speed) are the opposite of what's good for business (simplicity, maintainability and usability))

* you're not providing much for the chess community: most attention will be on engines that are very strong or great fun

* you're not teaching future chess developers: they will mostly use the chess programming wiki site (link)

* Developers seem to like Rust, but it's going out of fashion because the new mantra is that in most business situations, developer productivity trumps other considerations (this is why interpreted languages are enjoying a resurgence), and other languages (e.g. Go) outscore Rust on that

Use your time for things that give something back to you - preferably use most of your time on things that give the most back to you. Chess programming is a wrong turn on the map: it looks like a fun place, but it doesn't take you anywhere useful.
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
JohnW
Posts: 381
Joined: Thu Nov 22, 2012 12:20 am
Location: New Hampshire

Re: Your motivation for writing a chess engine?

Post by JohnW »

Because writing a tic-tac-toe engine is boring :D
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Your motivation for writing a chess engine?

Post by mvanthoor »

Kieren Pearson wrote: Fri Mar 05, 2021 1:32 pm It may not take as long as you think. Halogen gained ~1000 elo from Halogen 4 to Halogen 9 in only in 6 months.
Could be; but I took about 1.5 years already to get where I am now, writing the base engine.

But, as I mentioned, I'm just working on it a few hours here or there in the evenings, or in the weekends, and I'm using a programming language I didn't know when I started writing this thing. So, I have written and rewritten some parts several times. Not to mention the fact that I've been massively delayed for over 6 months due to the postponement of my cataract operation.

We'll see. I'm not going to hurry with this, and there's lots of stuff to study yet. I have completely NO idea how much strength will be gained by what feature. (And then, I'll have to also implement a level function so I can actually play against the thing myself :lol: )
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: Your motivation for writing a chess engine?

Post by mvanthoor »

towforce wrote: Fri Mar 05, 2021 1:34 pm Use your time for things that give something back to you - preferably use most of your time on things that give the most back to you. Chess programming is a wrong turn on the map: it looks like a fun place, but it doesn't take you anywhere useful.
Writing poetry also doesn't take you anywhere useful (except for some few very lucky individuals), but there are still lots of people doing it...
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Your motivation for writing a chess engine?

Post by mar »

mvanthoor wrote: Fri Mar 05, 2021 12:32 pm - Hit 3000 Elo.
on my list for years, not there yet, also assuming you refer to 3k CCRL? single threaded? LTC? because my engine isn't even 2900 in CEGT
I must be very stupid that it took me so long and I'm not there yet, though

btw Lazy SMP is much easier than breaking 3k, IMO - YMMV
Martin Sedlak
User avatar
towforce
Posts: 11575
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: Your motivation for writing a chess engine?

Post by towforce »

mvanthoor wrote: Fri Mar 05, 2021 2:01 pmWriting poetry also doesn't take you anywhere useful (except for some few very lucky individuals), but there are still lots of people doing it...

Writing poetry can help people dealing with difficult issues, and a beautifully presented poem can be a touching personalised gift to someone - but in general, you are right - it doesn't normally repay the investment in time.

You can certainly make a case that a hobby can give back - link. However:

1. a long term goal can give back an order of magnitude more - link

2. family is the most important thing in the world: making sure they're OK, that they know they're valued, and that you're willing to spend time with them is very important. Maybe you're not good at it? That's fine - it's a learnable skill!
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Your motivation for writing a chess engine?

Post by mvanthoor »

mar wrote: Fri Mar 05, 2021 2:31 pm
mvanthoor wrote: Fri Mar 05, 2021 12:32 pm - Hit 3000 Elo.
on my list for years, not there yet, also assuming you refer to 3k CCRL? single threaded? LTC? because my engine isn't even 2900 in CEGT
I must be very stupid that it took me so long and I'm not there yet, though

btw Lazy SMP is much easier than breaking 3k, IMO - YMMV
3000 Elo on the 2m+1s Blitz list. I don't have the hardware power (or patience) to run 15m+10s matches for hundreds of games.

I don't know what's required to break that barrier. Some engines seem to just fly up there and trhough it somehow. It's a very faraway goal. The "real" target is 2895, because that would put me on par with Glaurung and just ahead of Fritz 11. The rest is icing on the cake. After Rustic 4, I'll just add search features one by one (and verify that they are working correctly), and when I hit the point where I feel like I need more time to study something, I'll start on the evaluation. Eric (from MadChess) recently ripped his eval from the engine for testing purposes (except material and PST), and MadChess dropped 800 Elo. If there's 800 Elo in the evaluation, I only need another 400 Elo on top of my current engine with regard to search...

We'll see. One step at a time.
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: Your motivation for writing a chess engine?

Post by mvanthoor »

towforce wrote: Fri Mar 05, 2021 2:32 pm Writing poetry can help people dealing with difficult issues, and a beautifully presented poem can be a touching personalised gift to someone - but in general, you are right - it doesn't normally repay the investment in time. skill!
Chess programming outside of academia, where you do so to research one subject or another, is the same as reading fiction: you do it because you want to. Nothing more. Nothing less. I wanted to have my own chess engine written in a language not C or C++. It's done; I have one. I could stop here if I wanted to.

By the way, if you only do things with the intention of getting some sort of Return on Investment (or "profit"), apart from the fun or desire to do it, then (IMHO) you're living like a Ferengi. (In case you don't know anything about Star Trek: the Ferengi are a species where earning money and getting the greatest ROI possible are the only meaningful goals in life.)
towforce wrote: Fri Mar 05, 2021 2:32 pm 2. family is the most important thing in the world: making sure they're OK, that they know they're valued, and that you're willing to spend time with them is very important. Maybe you're not good at it? That's fine - it's a learnable skill!
That depends on your viewpoint. My family is quite small, and there are only a few people in it I actually have some sort of connection with outside of the fact that they happen to be family.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL