CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: semiprocoder on September 10, 2015, 04:10:54 AM

Title: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 10, 2015, 04:10:54 AM
I searched for a chess game on ti calc, and I couldn't find it, so I decided to make my own. I so far am nowhere near finishing. All that is done drawing the board and moving the pieces, but the code doesnt check for illegal moves and it allowes anything to move anywhere, including blank spaces onto pieces, for now. Also I plan to maybe eventually make an ai, but im not sure. Anyways, here is the chess game. I will probably make a few more simple games and then go on to making an empire earth like rts game.


EDIT: I updated the chess file so that it checks whether you make a valid move. It doens't detect checkmates yet, but it doesnt let you move if you are checked. Please report any bugs you find cause there were a lot during development and I might have missed some.

Also now if you press clear(ctr+del) it clears the board.

Second Edit: sorry for uploading the screenshot instead of the actual game, I was rushing to upload it.
Title: Re: Lua Chess for the Ti Nspire
Post by: gameblabla on September 10, 2015, 04:13:47 AM
It looks sharp and clean for a chess game but what are the controls ?
I can't quite figure it out.
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 10, 2015, 04:28:55 AM
Sorry for not adding instructions. I will add a readme later. But for now, all you do is move the mouse and click on a piece, and then click where you want to move the piece to.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on September 10, 2015, 06:00:31 AM
Do you have screenshots? I am curious about how the pieces look like. I don't have time to try it now since I am going to bed in a few minutes and I work tomorrow. I assume that the two players play on the same calc, right?   Will the calc be used sideways?
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 10, 2015, 11:39:40 AM
Yeah sure I will update the original post right now.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on September 11, 2015, 06:05:29 AM
Ooh I love it. The pieces are simple, but they surprisingly do the job very well. I'll have to give the game a try. An AI would be cool but quite hard, I assume. Even console Chess games often have crappy AI, so it's probably very hard to make a good one that runs at reasonable speed.
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 12, 2015, 12:50:57 AM
Yeah. I plan to maybe eventually make an ai based on minimax. I dont personnally know how a chess ai works specifically though, so it wont be fully optimized or as good as it could be, if I decide to make it. I am not sure right now that I will make it yet, as I plan to, as I said, make some more games and then work on a long term rts project, with some small projects in between. But even if I do I am not sure that it would run at reasonable speads, as I said, so even if I end up making one I might not post it.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on September 13, 2015, 05:49:03 PM
Are there chess AI documented online? That said, I think a chess game is fine if it's only multiplayer. After all, it can be an handy way to play chess during lunch break at school without having to bring a big chess board and stuff. :P
Title: Re: Lua Chess for the Ti Nspire
Post by: alexgt on September 13, 2015, 06:26:43 PM
I wanted to make a chess game for the prime but I have to many other unfinished projects xD looks good so far then :)
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 14, 2015, 08:04:52 PM
Yeah maybe I will make it. I will probably use a tutorial I found online for making a chess algorithm on gamedev. For now though I am working on remaking the game flow on android for the nspire. Once I am done with making the mechanics of it, I will post it and start polishing up this chess game and making an ai for it.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on September 14, 2015, 09:08:24 PM
Do you mean you might do an HP Prime version?
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 15, 2015, 12:26:23 AM
Nah I don't have a prime so I couldn't do that. I wish I had one because it seems sooo much better than an nspire based on the descriptions, but unfortunately my teacher reccomended an nspire, so I had to get one. I meant I would make an ai, not chess for the prime, sorry :(. If there are any free emulators for the prime I may start making some things for it, but I don't know about any and I don't know any prime languages.
Title: Re: Lua Chess for the Ti Nspire
Post by: Adriweb on September 15, 2015, 12:38:38 AM
The HPPL is [much] better than the Nspire's Basic, but on the other hand, the Nspire has Lua.
(and, well, lots of other languages if you can Ndless it)
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on September 16, 2015, 03:14:57 AM
Quote from: semiprocoder on September 15, 2015, 12:26:23 AM
Nah I don't have a prime so I couldn't do that. I wish I had one because it seems sooo much better than an nspire based on the descriptions, but unfortunately my teacher reccomended an nspire, so I had to get one. I meant I would make an ai, not chess for the prime, sorry :(. If there are any free emulators for the prime I may start making some things for it, but I don't know about any and I don't know any prime languages.
Aah thanks for explaining. :) I can't wait to see what future projects and Chess/Learn to Fly Idle updates from you and I hope you enjoy CodeWalrus so far. :)
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on September 16, 2015, 03:43:18 AM
Yeah thanks I really like codewalr so far and I like watching all the forums. Currently I am not really active in any other threads but I still read them. Also I just posted flow for the nspire. I hope you like it. It should work on any os version with lua because it doest use images.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on September 16, 2015, 07:54:42 AM
That is cool. Have you set up the minimul API level properly, though? Because even if you don't use images, I think programs will still warn about outdated OS if the program's minimum API level is too high for the OS.
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on November 25, 2015, 06:52:26 PM
So I decided to look at my code again just cause I was bored, and I found a glitch where if you take anything with a pawn you get to move again, and I deleted the one line of code that caused that. Now it should be free of such glitches
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on November 25, 2015, 06:54:31 PM
Awesome, I didn't realize there was this bug but I'm glad it's fixed now. Do you have plans for other Nspire/non-Nspire games? Maybe Checkers since those seems rare for calcs.
Title: Re: Lua Chess for the Ti Nspire
Post by: calcplays on November 25, 2015, 09:43:01 PM
TI-Chess ( http://www.ticalc.org/archives/files/fileinfo/116/11606.html ) for the TI-89 has a CPU (which, according to the reviews, is somewhere between incredibly easy and impossible) and source code, along with puzzles and other features. Perhaps the 10th most downloaded file of ticalc.org's history might hold to the key to creating a CPU for your chess program on the TI Nspire (a calculator I do not have.) 
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on November 25, 2015, 10:11:16 PM
Would it be easy to port to Lua?
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on November 26, 2015, 12:13:53 AM
I mean, it would take a while(but probably could be done) because its in c and its a really big game. I'll take a look at it though. I am a very inexperienced programmer though(not too many game/c programming courses for eight graders, although I do take c, but not graphical and I am still inexperienced) so don't promise anything at all.
Title: Re: Lua Chess for the Ti Nspire
Post by: Lionel Debroux on November 26, 2015, 06:37:07 AM
TI-Chess is indeed by far the most popular TI-68k file on ticalc.org :)
IIRC, it used to rank higher, but the popularity of the TI-68k series has waned.

Using existing Lua chess engines as a starting point should be easier than using a C chess engine, though.
Also, the speed of an AI written in Lua won't be that great on the Nspire. Only native code would make the more advanced (3 and beyond) levels of the TI-Chess AI acceptably fast on the Nspire, whose raw power is quite a bit higher than that of the TI-68k series.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on November 26, 2015, 07:39:22 PM
What about OS 3.6 Lua, though? Didn't speed improve significantly over OS 3.1, or was it only graphical-wise?
Title: Re: Lua Chess for the Ti Nspire
Post by: Lionel Debroux on November 26, 2015, 07:46:46 PM
Only some graphical functions were made faster in OS 3.6, AFAICT. The Lua core hasn't changed.
Title: Re: Lua Chess for the Ti Nspire
Post by: Adriweb on November 26, 2015, 08:25:07 PM
Eh, image handling changed massively in 3.6, with resources instead of inline strings :)

Other changes are minor for the handheld (for the iPad, there is now a touch library): https://wiki.inspired-lua.org/Changes_in_OS_3.6
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on November 26, 2015, 08:50:30 PM
I see. That said I guess it would not hurt to try. I doubt the speed can be anywhere close to as bad as 83+ basic. :P
Title: Re: Lua Chess for the Ti Nspire
Post by: semiprocoder on November 27, 2015, 05:10:26 PM
Someone else should probably do this(contest?) because I have never even wrote minimax(I know how it works though and I started but gave up). I would probably need more ai training before writing this.
Title: Re: Lua Chess for the Ti Nspire
Post by: Dream of Omnimaga on November 27, 2015, 07:38:51 PM
An AI co test would be nice, but unfortunately, CW Contest #2 (which starts soon) is something different. :P