Open tissatussa opened 2 months ago
I am sure that Rust has already good chess support -- but I was not aware of this project.
But generally I am not really interested in computer chess that much.
I ported my salewski-chess to Rust as a tiny exercise -- my larger project https://github.com/StefanSalewski/SDT would be much more effort to port unfortunately.
I have still to learn a lot about Rust, and still I am not sure if I will really seriously continue using Rust. Julia and Mojo are options too, perhaps even Kotlin or Zig. Rust is the most difficult, so I think it is a good idea to learn it now, than the other languages will appear easy. But perhaps Rust is just good enough. I recently heard that MicroSoft and Google are using Rust now also, and soon we should get the fine Xilem GUI, which might further increase the Rust popularity.
..Julia and Mojo are options too, perhaps even Kotlin or Zig..
i also wondered which new language to learn .. i came upon Nim and i like it -- we discussed some .. i know Julia a little, it resembles Python but its logic is special and somewhat awkward, also Julia can do many rather complicated 'structures' .. Zig seems a good choice also, i'm not familiar with Kotlin .. maybe stick to a language with many users and thus info for answers .. the Xilem thing sounds good!
Yes, deciding about a computer languages is difficult. Some say just learn many -- but for languages like C++, Haskel, or Rust the effort is really large. Even learning all the details of Nim was some effort, and Nim changed over time (e.g. new ARC and ORC memory management with destructors.). For Rust, the official Book is by far not sufficient, it is more an instructional tutorial. The book of Blandy, "Programming Rust" has 700 pages. And then remains much more to learn. Xilem might become really a large step forward, Raph Levien and others have done already a lot of great work. I saw a video about Vello, the drawing kit they are using. It is very fast because of GPU usage. Xilem and Vello might be a good reason to stick with Rust. Bevy, the game engine, and Redox, the OS, are great too. And there is much more to learn. Zig has become popular, but I am not a friend of fully manual memory management. For embedded stuff it might be OK. Kotlin is not usable for low level systems programming. Julia is nice for fast scientific computing. Finally, Mojo was hyped a lot one year ago, but I have doubts that it will be ever fully open source. Swift, with some similarity to Rust, is unfortunately mostly used for Apple only. (I also should learn more Python, as it is the most popular language currently. 15 years ago I decided to use Ruby instead of Python, at that time it was not that clear that Python would win.)
So Rust remains my best candidate for now.
so, you're not into chess like me .. i'm a clubplayer for years, but simple programmer .. JS and PHP were my pets, but i learned Python and do most (fun) projects with it .. but trying to write a fast binary, preferably a single binary (for multi OS), i found and learned some Julia, which can be compiled and runs fast, but compared by running a (original) Python script by Pypy gives same speed .. i don't know how fast Rust chess engines can operate, but it's critical when evaluating many nodes .. in general i like to keep things simple, only learning complex things when needed - and i learn by examples, often combining code parts i don't fully understand ..
can you tell me a bit about the HCE of your engine ? Are Piece-Square-Tables used etc. Did you ever consider implementing the (simple) TuroChamp rules ? I think they're genius and it can be a great exercise for you. And i have another little programming idea - related to chess though ..
so, you're not into chess like me .. i'm a clubplayer for years,
I think I have spent about 150 hours totally with playing chess, most of it as a small boy playing against my grandma. Some years later, when I got an Amiga computer, I created my first computer chess engine with a nice GUI. But it played very weak, as I was not able to invent alpha-beta-prunning myself, so it had to evaluate the complete search tree, which limited dept to about 4 plys. Later, when I begun to study physics at hamburg university, I got Internet access for the first time, and learned about alpha-beta-prunning, the idea of a transposition table to reuse results, and the move generation by pre-calculated tables as done in GnuChess. Maybe a year later, I also heard about the bitboard chess representation, which became popular when we got the first 64-bit CPUs. But I did no chess coding for about 20 years. Then, in 2014, I started learning Nim, comming from Modula/Oberon/Ruby/C. And I thought it would be some fun to create a tiny chess engine from scratch.
You can study my engine yourself, it is very simple. The Nim or the Rust one. Board is an array of 64 integers, with indices from 0 to 63. For move generation I use a precalculated array similar as GnuChess did it. I Guess GnuChess used linked lists, but an array is simpler and faster, now that we have a of lot memory available. Then we generate the search tree full width up to a specified dept, followed by full capture sequence , doing megamax evaluation with alpha-beta-prunning to cut of most branches. The actual evaluation occurs when there are no more possible captures possible. The evaluation is very simple, taking account only the values of the figures (100 for a pawn, 300 for a bishop, ...) and the value of the position. The position value is determined by the possibility of a figure to move -- the theoretical one, determined by the actual position, plus the actual one, as it may be blocked by figures. Finally, I am using a custom hash table as transposition table to reuse positions that have already been evaluated.
So the engine is really very simple. But for most human players it should be a strong opponent, and I like its playing: It is not too boring in my view.
For a more complicated engine, with a detailed position evaluation, very good chess knowledge would be necessary, which I do not have. And actually this kind of "knowledge" can be questionable. Using bitboards might be useful, but it needs a lot of ugly and boring coding for all the bit fiddling. What I could do: Better GUI (Xilem), saving/loading games, opening library, setting up a position, and some more. Well, not difficult, but not really interesting. I might do it as an Xilem exercise later.
Note that AI can already learn to play strong chess without any actually programming, just by getting the rules, observing games of humans, and playing against itself. That is how Alpha-Go learned to win against the best human players. And AI makes currently such a fast progress, that many experts believe that in a few years AI will be smarter than the brightest humans. Then the AI will improve itself further, and can do all our mental work including writing computer programs. Perhaps then, when there is no more labor to do, I will spent some time playing chess again. Actually, I have the idea of asking an AI to create a chess engine from scratch. Current AI can generate already simple programs, like a snake or pong game. I assume that GPT-4 or Claude-3 would be already able to create the skeleton of a chess engine, but I will wait at least for GPT-5. Then I might ask it also to port my rust-chess back to Nim, so that we have identical code then. Currently, the Rust engine is cleaner, as it uses a Game struct instead of a global board representation, and the Rust code contains a few fixes and improvements. Actually, I might delete the old Nim version soon.
nice written info .. just what i imagined to know about you and the engine .. i also did some own projects with GUI building and managing settings with buttons etc. .. it's tedious .. i think understand the components of the HCE engines, yuo described well .. not reaching a high depth but getting the full tree, mmmm .. but with simple eval : what about the pruning : i guess HCE engines will never play very strong without specific factors, depending on position types & other ? Anyhow, your program plays chess rather good, and programming must be fun, not by perfection
what happens to the eval when introducing a 'factor' like consider positions which can be reached by [#] variations ? Tho hard to say how to define such 'aspect' ..
About asking AI to write code eg. a chess engine .. could we ask it to determine the underlaying magic square ? Probably having multi dimensions ? Some construct without the variations, in time :)
[ this is not real Issue, it just gives some info and poses questions about Rust chess programming ]
hi, i just found Liberty-Chess, see https://github.com/Mathmagician8191/Liberty-Chess , a complete chess application in Rust, with own GUI and even sound .. compiling on Linux went flawless .. it comes with the engine Oxidation (v0.6.2 now) which is UCI about 2200 ELO .. it has good code i guess, and uses a lot of modules, i've never seen that many .. also some specific chess / UCI related stuff .. maybe you'll get inspired or even contact the author for questions ?!
happy programming ! (i might dive into Rust myself, it seems nice..)