Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: joao9856 on October 25, 2012, 09:45:10 am

Title: Chess for Ti-Nspire CX
Post by: joao9856 on October 25, 2012, 09:45:10 am
I think it would be great if someone created a chess game for Ti-Nspire CX(I would create it myself but i don't have any programming skills).
Just saying that it would be awsome to have a game a with some many rules to run on my Ti-Nspire CX!
Title: Re: Chess for Ti-Nspire CX
Post by: Augs on October 25, 2012, 10:42:27 am
Just get a gameboy emulator and get a chess ROM.
Title: Re: Chess for Ti-Nspire CX
Post by: Lionel Debroux on October 25, 2012, 10:43:57 am
Emulation works, but wastes significant CPU power. A much more challenging game engine could be made by using a native Nspire chess engine instead ;)
Title: Re: Chess for Ti-Nspire CX
Post by: joao9856 on October 25, 2012, 11:57:30 am
Just get a gameboy emulator and get a chess ROM.
I tried that already there is no chess rom that works on the emulators.
Title: Re: Chess for Ti-Nspire CX
Post by: Augs on October 25, 2012, 12:44:18 pm
Emulation works, but wastes significant CPU power. A much more challenging game engine could be made by using a native Nspire chess engine instead ;)

You can get %100 speed on a GBC emulator plus you don't need much speed while playing chess. CPU is not really a problem.
Title: Re: Chess for Ti-Nspire CX
Post by: Lionel Debroux on October 25, 2012, 01:02:07 pm
Of course CPU is a problem ;)
FYI, while I'm not its creator, I'm the maintainer of TI-Chess (see my signature), i.e. by far the most advanced chess engine for TI-68k platforms, and also the most downloaded TI-68k program (on ticalc.org) ever ;)
I therefore expect to be reasonably informed of the CPU consumption of a chess engine for embedded platforms, and of the tradeoffs (memory consumption, CPU consumption, depth of analysis) that this requires. A chess engine with an AI (which TI-Chess is) will be an order of magnitude faster without emulation - and it can use plenty more memory, which, in turn, can make it even faster.

Anyone feeling like porting Toledo Nanochess ( http://nanochess.110mb.com/chess3.html ) to the Nspire, with NspireIO and/or nSDL ?
Title: Re: Chess for Ti-Nspire CX
Post by: thepenguin77 on October 25, 2012, 01:44:48 pm
Of course CPU is a problem ;)

(http://www.ticalc.org/archives/files/ss/827/82708.gif)

Man, that would suck to have to make a chess AI on a 180MHz ARM processor with native grayscale... ;D


(Btw, as for how good was my AI, SirCmpwn told me that he lost every single game he ever played. And it will beat me every now and then if I make a mistake)
Title: Re: Chess for Ti-Nspire CX
Post by: Lionel Debroux on October 25, 2012, 01:52:04 pm
As for me, I suck at playing chess. I never beat TI-Chess' level 2, and level 1 (which does make silly mistakes) often beat me, in the sense that I often used take back; but some people could beat level 3 on a pretty regular basis (and beyond that, TI-Chess was pretty slow).

But a quick port of Toledo Nanochess, with a simple NspireIO-based UI on top, looks both doable and attractive :)
Title: Re: Chess for Ti-Nspire CX
Post by: Hayleia on October 25, 2012, 03:11:17 pm
Of course CPU is a problem ;)

(http://www.ticalc.org/archives/files/ss/827/82708.gif)

Man, that would suck to have to make a chess AI on a 180MHz ARM processor with native grayscale... ;D


(Btw, as for how good was my AI, SirCmpwn told me that he lost every single game he ever played. And it will beat me every now and then if I make a mistake)
We are not even talking about greyscale but colors since the title mentions the CX ;)
Even though of course the program should run fine with greyscale on non CX Nspires.

And yeah, your AI is pretty hard to beat. I've won some games but sometimes it kills me in less than 10 rounds (because I try to trick it but it gets me in the meantime while I am looking at something else :P).
Title: Re: Chess for Ti-Nspire CX
Post by: ElementCoder on October 26, 2012, 03:16:17 am
Anyone feeling like porting Toledo Nanochess ( http://nanochess.110mb.com/chess3.html ) to the Nspire, with NspireIO and/or nSDL ?
For some reason I read this like nacho nes o.o But yeah that would be nice to have on the nspire :)
Title: Re: Chess for Ti-Nspire CX
Post by: Wayne on October 26, 2012, 10:54:09 am
3D chess would be awesome ;)
Title: Re: Chess for Ti-Nspire CX
Post by: DJ Omnimaga on October 31, 2012, 05:58:20 pm
Just make sure to have difficulty levels.
Title: Re: Chess for Ti-Nspire CX
Post by: Augs on October 31, 2012, 08:11:16 pm
Guys, You can get chess for the gbc.

A)It runs at 100% so speed is not a problem
B)Even if it didn't it does not matter as it is chess

The AI is depends on the ROM. Not worth the effort.
Title: Re: Chess for Ti-Nspire CX
Post by: DJ Omnimaga on October 31, 2012, 08:40:44 pm
Guys, You can get chess for the gbc.

A)It runs at 100% so speed is not a problem
B)Even if it didn't it does not matter as it is chess

The AI is depends on the ROM. Not worth the effort.

Care to give us the exact name (not a download)  of the ROM/game in question?
Just get a gameboy emulator and get a chess ROM.
I tried that already there is no chess rom that works on the emulators.

Also Augs what if someone wanted to make a better Chess game? By the way it is against Omnimaga rules to discourage someone from working on a project under such circumstances.
Title: Re: Chess for Ti-Nspire CX
Post by: cyanophycean314 on October 31, 2012, 09:59:14 pm
There's a game called Chessmaster that is apparently available for both gbc/gba. Haven't tried it though.

A chess project would be interesting... probably don't have time though
Title: Re: Chess for Ti-Nspire CX
Post by: Hayleia on November 01, 2012, 03:21:00 am
Guys, You can get chess for the gbc.

A)It runs at 100% so speed is not a problem
B)Even if it didn't it does not matter as it is chess

The AI is depends on the ROM. Not worth the effort.
I don't agree with the A: the game is quite slow. I tried it and decided to remove it because it was getting me bored. I returned to thpenguin's chess instead.
And I don't agree with the B because it is annoying to wait for 5 minutes before the opponent makes a move.

So really, it would be worth the effort to start a chess project:
-In C, it would surely be faster than Chessmaster and graphics could be improved too
-In Lua, the game would be compatible with all OSes without the need for Ndless.
Title: Re: Chess for Ti-Nspire CX
Post by: Lionel Debroux on November 01, 2012, 03:42:43 am
Augs, I already explained above why it was not satisfactory to use an emulated chess engine. I'm more knowledgeable about those matters than you are, and so is Hayleia (among others). Please stop proposing this kind of simplistic, and wrong, solutions (and thereby lower your total post ratings even further) ;)

I've silently looked at Toledo Nanochess, which is indecipherable (it was made for that purpose !), and therefore very hard to modify. If functions equivalent to getchar() and putchar() (or these functions, as defined by the C89 / C99 / C11 standards) are provided by NspireIO, a rough port might just be easy. Otherwise, well, better look at a different chess engine :D

EDIT: in fact, NspireIO does provide putchar() and getchar(): http://nspforge.unsads.com/p/nspireio/wiki/Documentation . Go ahead, those who use an up to date Ndless SDK ;)
Title: Re: Chess for Ti-Nspire CX
Post by: DJ Omnimaga on November 01, 2012, 03:59:42 am
By the way, since the GB/GBC are old and weaker consoles than the TI-Nspire, developers have to abuse all sort of cheap shortcuts during programming. Although it is less likely to happen with chess, there are more chances to run into exploits or glitches due to the weird coding. Remember for example how in most old Mario games you could go through walls while jumping backwards due to them not checking for such collision detection in order to save every bit of speed possible. In most console games the randomizer is much cheaper too, so there is more risk for luck manipulation.

Besides, by making a brand new game using all the calc CPU power, you could have a much better Chess clone than the GB/GBA clones or even allow players to play the game at much lower MHz speed to save battery life.
Title: Re: Chess for Ti-Nspire CX
Post by: aeTIos on November 01, 2012, 08:12:43 am
I am looking into creating a chess game for ndless. There are plenty of tutorials around on the web, so I think I can do this ;D
Title: Re: Chess for Ti-Nspire CX
Post by: compu on November 01, 2012, 08:29:43 am
EDIT: in fact, NspireIO does provide putchar() and getchar(): http://nspforge.unsads.com/p/nspireio/wiki/Documentation . Go ahead, those who use an up to date Ndless SDK ;)
Yup, but it doesn't work with Nspire I/O :(
Title: Re: Chess for Ti-Nspire CX
Post by: excale on November 01, 2012, 09:00:06 am
I made the same thing a few hours about (with Lionel's help), but I get something a little different (your >> are ΓΏ for me), and I can type (but only large amounts of characters!) and get some obscure answers from the program.

(http://www.mirari.fr/zVry)

I sent a mail to the original author asking for a documentation.

Code:
Code: [Select]
char*l="ustvrtsuqqqqqqqqyyyyyyyy}{|~z|{}"
"   76Lsabcddcba .pknbrq  PKNBRQ ?A6J57IKJT576,+-48HLSU";
#include <os.h>
#define NIO_REPLACE_STDIO
#include <nspireio2.h>
#define F getchar()&z
#define v X(0,0,0,21,
#define Z while(
#define _ ;if(
#define P return--G,y^=8,

int _isatty(int file) {
   (void)file; // avoid warning
   return 1;
}

B,i,y,u,b,I[411],*G=I,x=10,z=15,M=1e4;X(w,c,h,e,S,s){int t,o,L,E,d,O=e,N=-M*M,K
=78-h<<x,p,*g,n,*m,A,q,r,C,J,a=y?-x:x;y^=8;G++;d=w||s&&s>=h&&v 0,0)>M;do{_ o=I[
p=O]){q=o&z^y _ q<7){A=q--&2?8:4;C=o-9&z?q["& .$  "]:42;do{r=I[p+=C[l]-64]_!w|p
==w){g=q|p+a-S?0:I+S _!r&(q|A<3||g)||(r+1&z^y)>9&&q|A>2){_ m=!(r-2&7))P G[1]=O,
K;J=n=o&z;E=I[p-a]&z;t=q|E-7?n:(n+=2,6^y);Z n<=t){L=r?l[r&7]*9-189-h-q:0 _ s)L
+=(1-q?l[p/x+5]-l[O/x+5]+l[p%x+6]*-~!q-l[O%x+6]+o/16*8:!!m*9)+(q?0:!(I[p-1]^n)+
!(I[p+1]^n)+l[n&7]*9-386+!!g*99+(A<2))+!(E^y^9)_ s>h||1<s&s==h&&L>z|d){p[I]=n,O
[I]=m?*g=*m,*m=0:g?*g=0:0;L-=X(s>h|d?0:p,L-N,h+1,G[1],J=q|A>1?0:p,s)_!(h||s-1|B
-O|i-n|p-b|L<-M))P y^=8,u=J;J=q-1|A<7||m||!s|d|r|o<z||v 0,0)>M;O[I]=o;p[I]=r;m?
*m=*g,*g=0:g?*g=9^y:0;}_ L>N){*G=O _ s>1){_ h&&c-L<0)P L _!h)i=n,B=O,b=p;}N=L;}
n+=J||(g=I+p,m=p<O?g-3:g+2,*m<z|m[O-p]||I[p+=p-O]);}}}}Z!r&q>2||(p=O,q|A>2|o>z&
!r&&++C*--A));}}}Z++O>98?O=20:e-O);P N+M*M&&N>-K+1924|d?N:0;}

main()
{
nio_use_stdio();
Z++B<121)*G
++=B/x%x<2|B%x<2?7:B/x&4?0:*l++&31;Z B=19){Z B++<99)putchar(B%x?l[B[I]|16]:x)_
x-(B=F)){i=I[B+=(x-F)*x]&z;b=F;b+=(x-F)*x;Z x-(*G=F))i=*G^8^y;}else v u,5);v u,
1);}
nio_free_stdio();
}


Title: Re: Chess for Ti-Nspire CX
Post by: aeTIos on November 01, 2012, 09:10:31 am
Maybe put this in another topic (or is this related?)
Title: Re: Chess for Ti-Nspire CX
Post by: Lionel Debroux on November 01, 2012, 09:20:27 am
Toledo Nanochess is a chess engine, and Nspire I/O might just have enabled to port it to the Nspire.
But the code is derived from a winning entry at IOCCC: it has many warnings, it's extremely hard to understand and therefore to modify. It's not necessarily Nspire I/O's fault if it does not work as is on the Nspire.
Title: Re: Chess for Ti-Nspire CX
Post by: DJ Omnimaga on November 01, 2012, 09:39:06 am
Do you mean warnings as in errors or warnings as in copyright lawsuit threats if re-used as is?
Title: Re: Chess for Ti-Nspire CX
Post by: compu on November 01, 2012, 09:47:48 am
Do you mean warnings as in errors or warnings as in copyright lawsuit threats if re-used as is?
Errors ;)

It looks like my getchar() implementation is not ANSI C compliant (mine is non-blocking, the ANSI C one waits for Enter being pressed, that's why you get large amounts of characters), but modifying Nspire I/O doesn't solve the problems... (-> my screenshot)
Title: Re: Chess for Ti-Nspire CX
Post by: Augs on November 01, 2012, 12:17:33 pm
Well OK then. I am fine with just the emulator but obviously you are not. So I am not going to stop you. Whatever floats your boat.

Quote
Care to give us the exact name (not a download)  of the ROM/game in question?

Isn't that against the rules of the forum?

Quote
Also Augs what if someone wanted to make a better Chess game? By the way it is against Omnimaga rules to discourage someone from working on a project under such circumstances.

Sorry.
Title: Re: Chess for Ti-Nspire CX
Post by: TIfanx1999 on November 01, 2012, 01:25:40 pm
DJ_O was asking you for the name of the chess rom, not a download. So no, that is not against forum rules. :)
Title: Re: Chess for Ti-Nspire CX
Post by: Augs on November 01, 2012, 02:11:19 pm
Well I found one called chess master.
Title: Re: Chess for Ti-Nspire CX
Post by: SpiroH on November 01, 2012, 05:08:42 pm
I am looking into creating a chess game for ndless. There are plenty of tutorials around on the web, so I think I can do this ;D
I've just spotted the source code for a simple chess game written in C/SDL, here: http://www.thomasdupuis.com/portfolio/en/2010/03/23/chess-game-project-1st-year-prepa/ . Do you think it can help? Go ahead and do it! Cheers.'Ik zal wachten' ;)
Title: Re: Chess for Ti-Nspire CX
Post by: lkj on November 01, 2012, 07:13:33 pm
I am looking into creating a chess game for ndless. There are plenty of tutorials around on the web, so I think I can do this ;D
I've just spotted the source code for a simple chess game written in C/SDL, here: http://www.thomasdupuis.com/portfolio/en/2010/03/23/chess-game-project-1st-year-prepa/ . Do you think it can help? Go ahead and do it! Cheers.'Ik zal wachten' ;)

The website says "There's no AI" ;)
Title: Re: Chess for Ti-Nspire CX
Post by: renatose on November 01, 2012, 07:35:01 pm
I am looking into creating a chess game for ndless. There are plenty of tutorials around on the web, so I think I can do this ;D
I've just spotted the source code for a simple chess game written in C/SDL, here: http://www.thomasdupuis.com/portfolio/en/2010/03/23/chess-game-project-1st-year-prepa/ . Do you think it can help? Go ahead and do it! Cheers.'Ik zal wachten' ;)

The website says "There's no AI" ;)
It could be integrated with gnuchess to have an AI...
http://www.gnu.org/software/chess/
Title: Re: Re: Chess for Ti-Nspire CX
Post by: DJ Omnimaga on November 01, 2012, 09:33:40 pm
With juju and co trying to bring internets to the Nspire CX, maybe at one point if someone starts a Chess clone there could be online play? O.O It might be complicated if the project is being worked on by a newer coder, though.
Title: Re: Chess for Ti-Nspire CX
Post by: Lionel Debroux on November 02, 2012, 03:40:48 am
With the Linux port, a male mini-A <-> female A cable, possibly a powered USB hub, and a cheap USB network adapter, I'm positive it's possible to just port an existing chess program with online playing capability ;)
GNU Chess is one of the programs that buildroot directly supports (even if it weren't, it's easy to use the toolchain built by buildroot), and according to its manual ( https://www.gnu.org/software/chess/manual/gnuchess.html#Internet ) it can be networked to the Internet through an auxiliary program.


On a platform, when a usable port of Linux becomes available, it radically changes the landscape. Billions of lines of portable open source code suddenly become available for reuse. Many programs work out of the box, while others need some effort (e.g. to cope with a low resolution screen, if possible). In normal markets (those which are not completely biased by stupid testing regulators, into closed platforms made of years-old technologies sold to the consumer at extremely high price tags), the value in providing open-minded systems is tremendous.
ARM completely owns the mobile space, clearly largely thanks to Linux. iP* are the main exception to that rule, but as far as smartphones are concerned, they now represent a minority of new purchases, and the lackluster new iP* will probably worsen the trend for Apple.
Title: Re: Chess for Ti-Nspire CX
Post by: wurm 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 :)