Hey what's up guys, Code Monkey King's here.
I've deobfuscated Tiny Chess by Oscar Toledo G. (from his permission) during a live YouTube series of up to 6 videos:
And for those interested in the gist essence of how it works here's the 1 video summary:
Original code: https://github.com/maksimKorzh/toledo-c ... chess.html
Deobfuscated code: https://github.com/maksimKorzh/toledo-c ... cated.html
It took me around 5 years to get confident enough in chess programming to finally make it)
P.S. Oscar, if you're reading this please kindly let me know what do you think of this effort)
World's smallest chess program in JS but with meaningful variable names and commented source code
Moderators: hgm, Rebel, chrisw
-
- Posts: 771
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
World's smallest chess program in JS but with meaningful variable names and commented source code
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 11586
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
Re: World's smallest chess program in JS but with meaningful variable names and commented source code
Obviously in this case the agenda was to make the program as small and as fast as possible, but in general, clear code is of great value. Especially, of course, in a workplace where other people will have to maintain your code, but even for yourself when you have to come back to code that you wrote some time ago.
For me, clarity and maintainability is a priceless attribute of code, almost as important as the code actually working (even more important under some circumstances).
A top example to all of us!
If you have permission, you could now start to modify the code: maybe get it playing in a style that you like?
For me, clarity and maintainability is a priceless attribute of code, almost as important as the code actually working (even more important under some circumstances).
A top example to all of us!
If you have permission, you could now start to modify the code: maybe get it playing in a style that you like?
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!
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!
-
- Posts: 771
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: World's smallest chess program in JS but with meaningful variable names and commented source code
Thanks for your kind feedback)towforce wrote: ↑Sat Sep 04, 2021 1:27 pm Obviously in this case the agenda was to make the program as small and as fast as possible, but in general, clear code is of great value. Especially, of course, in a workplace where other people will have to maintain your code, but even for yourself when you have to come back to code that you wrote some time ago.
For me, clarity and maintainability is a priceless attribute of code, almost as important as the code actually working (even more important under some circumstances).
A top example to all of us!
If you have permission, you could now start to modify the code: maybe get it playing in a style that you like?
I did for clarity with didactic purposes in mind so that other people could learn from Oscar's masterpiece.
As for an idea to start modifying it - I don't need it for I have my own minimalist engine with unique design:
Obfuscated: https://github.com/maksimKorzh/toyfish/ ... sh-mini.py
Normal: https://github.com/maksimKorzh/toyfish/ ... toyfish.py
Data for normal: https://github.com/maksimKorzh/toyfish/ ... tings.json
FULL PROJECT: https://github.com/maksimKorzh/toyfish
I have a YouTUbe series on that as well btw)
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 1784
- Joined: Wed Jul 03, 2019 4:42 pm
- Location: Netherlands
- Full name: Marcel Vanthoor
Re: World's smallest chess program in JS but with meaningful variable names and commented source code
Cool I never took the time or made the effort to understand code such as Toledo NanoChess or HGM's MicroMax.
If code has non-useful or one-letter variable names, I have the same problem as I have in maths: I get confused very quickly. (I discovered that, if I replace letters in math with a descriptive variable name, I'm suddenly quite good at it.)
If code has non-useful or one-letter variable names, I have the same problem as I have in maths: I get confused very quickly. (I discovered that, if I replace letters in math with a descriptive variable name, I'm suddenly quite good at it.)