Toyfish: chess engine in Python for absolute beginners

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

Moderators: hgm, Rebel, chrisw

User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Toyfish: chess engine in Python for absolute beginners

Post by maksimKorzh »

The video tutorial series is now completed.
I'd like to thank all of you guys for being interested in my work!

Here're the step-by-step tutorials:
Defining board class, initializing game rules:
Implementing move generator:
Implementing make/unmake moves:
Implementing evaluation:
Implementing search:
Implementing CLI interface (+ playing vs engine!):

Special thanks to Gerd Isenberg for adding Toyfish to my CPW page!
https://www.chessprogramming.org/Maksim_Korzh
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Toyfish: chess engine in Python for absolute beginners

Post by maksimKorzh »

hgm wrote: Tue Jul 20, 2021 1:43 pm It is certainly possible to implement recursion 'by hand'. I.e. making an iterative search, rather than a recursive one. In languages that do not support recursion (such as Fortran) you had to do that anyway. The trick is just to keep everything that would be a local variable as an array element indexed by the ply level. To mimic the recursive call you just increment 'ply', and jump back to the beginning of the code that normally is in Search(). To mimic a return you decrement 'ply', and jump to just behind where a normal return should go (i.e. just behind the mimicked call). Except when ply == 0 (the root), where you just continue with the main loop (which would print and execute the move).
Wow! Awesome! Now this is exactly what I've been asking for! Thank you Mr. Muller!
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Toyfish: chess engine in Python for absolute beginners

Post by maksimKorzh »

Here's a minified version of stockfish, significantly stripped down:

I've encode piece move offsets into integers representing chess piece on board,
so no more need to source chess rules data from "settings.json" file

Source code:
https://github.com/maksimKorzh/toyfish/ ... yfish-mini