1
TI-Nspire / Re: Chess for Ti-Nspire CX
« on: December 29, 2023, 03:41:06 pm »
Hello everybody,
Seeing as this topic has not been discussed since 2012 (!!!) I have rather limited hopes of receiving any feedback on this, yet I would still like to share what I have to say.
About a quarter year ago, I had a cold which kept me out of school for a week and left me quite bored. Out of this boredom I decided to learn how to code and write a little chess engine for my calculator, as to make my maths classes a little more interesting. Little did I know this would haunt me for such a long time. So here are my insights into chess on a calculator.
First Version was written in Python (as the TI-Nspire CX II-T natively supports that) and took ~2 Weeks to complete. Speed: Absolutely unplayable at around 20 Nodes per second searched. (10000 nps on my pc) -> Python (ON A CALCULATOR) is definitely not the way to go for speed. Especially considering the TI python interpreters unhinged slowness. I assume the same applies for TI-Basic, have not tried that tho.
For the second version I discovered the wonderous world of ndless and learned c++. After some experimenting with movegeneration techniques this seemed much more promising, beeing able to generate and evaluate ~20 kN/s on the calculator. Factoring in that this is with a very amateurishly written program which does around 8 MN/s on my pc that is quite alright.
As this was a major point of discussion here, I'd like to quickly get into the relevance of performance in chess programs. Due to the huge number of possible positions, brute-forcing your way to a checkmate is very computationally demanding and CPU is not in fact "not really the problem"! Given good enough search optimization one can get away with quite low speeds, but a certain baseline is absolutely necessary. The 200nps of the cited TI-Chess engine are not really in that range, with the limited ressources it's operating with it's an incredibly impressive piece of code nontheless!!
After letting my half finished program rott for a while, I took up working on it again lately and managed to massively improve it. Inspired by Daniel Infuehr's "Gigantua" Movegenerator, the program is now capable of generating ~1.8GN/s (yes that is 1.8 Billion nodes per second) on my PC. This is without evaluation mind you. This figure shrinks to a respectable 2MN/s on the calculator. This is very probably due to the calculator not having the PEXT instruction, which plays a key part in generating the sliding piece moves. This could be fixed in the future through the use of Magic Bitboards (https://www.chessprogramming.org/Magic_Bitboards).
In a very quick and dirty fashion I then added a search algorithm to the movegenerator, leaving a lot of performance behind. With ~4MN/s (on pc) the engine ZeroLogic 1 manages 1900 - 2000 elo, which is enough to beat most chess players. More importantly, it is still able to search circa 20kN/s on the calculator, enabling a depth of 5 ply in a second, which when tested on my pc was still above 1500elo performance. The playing experience needs some serious improvements, due to the only mode of communication with the engine being the uci protocol and it only being able to search for depth and not for time. This is all in the works tho.
So to summarize: A well performing chess engine on a calculator is very well possible, and will hopefully help through a lot of maths classes. You can find my very poorly commented project here : https://github.com/0xwurm/ZeroLogic.
Please excuse my bad English, have a great new year and bless your heart if you happen to stumble upon this comment in an almost 12 year old topic.
With kind regards, Christian
Seeing as this topic has not been discussed since 2012 (!!!) I have rather limited hopes of receiving any feedback on this, yet I would still like to share what I have to say.
About a quarter year ago, I had a cold which kept me out of school for a week and left me quite bored. Out of this boredom I decided to learn how to code and write a little chess engine for my calculator, as to make my maths classes a little more interesting. Little did I know this would haunt me for such a long time. So here are my insights into chess on a calculator.
First Version was written in Python (as the TI-Nspire CX II-T natively supports that) and took ~2 Weeks to complete. Speed: Absolutely unplayable at around 20 Nodes per second searched. (10000 nps on my pc) -> Python (ON A CALCULATOR) is definitely not the way to go for speed. Especially considering the TI python interpreters unhinged slowness. I assume the same applies for TI-Basic, have not tried that tho.
For the second version I discovered the wonderous world of ndless and learned c++. After some experimenting with movegeneration techniques this seemed much more promising, beeing able to generate and evaluate ~20 kN/s on the calculator. Factoring in that this is with a very amateurishly written program which does around 8 MN/s on my pc that is quite alright.
As this was a major point of discussion here, I'd like to quickly get into the relevance of performance in chess programs. Due to the huge number of possible positions, brute-forcing your way to a checkmate is very computationally demanding and CPU is not in fact "not really the problem"! Given good enough search optimization one can get away with quite low speeds, but a certain baseline is absolutely necessary. The 200nps of the cited TI-Chess engine are not really in that range, with the limited ressources it's operating with it's an incredibly impressive piece of code nontheless!!
After letting my half finished program rott for a while, I took up working on it again lately and managed to massively improve it. Inspired by Daniel Infuehr's "Gigantua" Movegenerator, the program is now capable of generating ~1.8GN/s (yes that is 1.8 Billion nodes per second) on my PC. This is without evaluation mind you. This figure shrinks to a respectable 2MN/s on the calculator. This is very probably due to the calculator not having the PEXT instruction, which plays a key part in generating the sliding piece moves. This could be fixed in the future through the use of Magic Bitboards (https://www.chessprogramming.org/Magic_Bitboards).
In a very quick and dirty fashion I then added a search algorithm to the movegenerator, leaving a lot of performance behind. With ~4MN/s (on pc) the engine ZeroLogic 1 manages 1900 - 2000 elo, which is enough to beat most chess players. More importantly, it is still able to search circa 20kN/s on the calculator, enabling a depth of 5 ply in a second, which when tested on my pc was still above 1500elo performance. The playing experience needs some serious improvements, due to the only mode of communication with the engine being the uci protocol and it only being able to search for depth and not for time. This is all in the works tho.
So to summarize: A well performing chess engine on a calculator is very well possible, and will hopefully help through a lot of maths classes. You can find my very poorly commented project here : https://github.com/0xwurm/ZeroLogic.
Please excuse my bad English, have a great new year and bless your heart if you happen to stumble upon this comment in an almost 12 year old topic.
With kind regards, Christian