• Advertisement
Sign in to follow this  

TI-83 Plus - "Hero"

This topic is 4294 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Edit: Problem resolved. See bottom posts.   I don't expect there to be many people on this forum who program a TI-83 calculator, but in case there is anyone, please help me with my code.   First, I'll tell you what code I have. In my code below I represent two symbols as follows: STO symbol: -> does not equal: /= Also, if I mess up the code tags, can someone tell me how they are done?
:0->Q
:1->E
:1->F
:0->U
:0->V
:ClrHome
:
:Disp "USE THE ARROW","BUTTONS TO","NAVIGATE.","","PRESS ANY BUTTON","TO CONTINUE."
:Pause
:
:While Q/=1
:ClrHome
:
:For(V,1,8)
:For(U,1,16)
:If U=E and V=F
:Then
:Output(V,U,"O")
:Else
:Output(V,U,".")
:End
:End
:End
:
:If E=16 and F=8
:Goto ND
:If getKey=24
:E-1->E
:If getKey=25
:F-1->F
:If getKey=26
:E+1->E
:If getKey=34
:F+1->F
:End
:
:Lbl ND
:ClrHome
:Disp "YOU WIN!"
:DelVar V
:DelVar U
:DelVar F
:DelVar E
:DelVar Q
:Stop



  I realize that this code isn't terribly efficient, especially at refreshing, which takes ages, but that isn't my concern right now. I'm trying, first of all, to figure out what I did wrong on the movement. If anyone can direct me on how to make the code more efficient, that would help as well. For example, I tried building up a string in the for-loop nested within the for-loop, but it gave an invalid dimension error. This is how I did it, by the way:
:"O"+Str1->Str1
  Thanks in advance for anyone with any answers. If you need me to clarify my problem, just let me know. [Edited by - Tallun on April 21, 2006 4:17:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
Well I'm not sure what the problem with the movement is even (and I don't know where my calculator is to test it :\) but for the efficiency bit, instead of redrawing the entire screen each time through the loop, how about filling it with .'s before the main loop then inside the loop all you need to do is replace the old position, which would be an 'O', with a '.' and replace the new position (which would be a '.' with an 'O'. Writing 2 chars each loop should give a decent increase over writing 8*16 chars.

Hopefully that made sense... but it also wouldn't be the first time I've been accused of not making sense. Also note that it's been quite some time since I've done any programming on my calc ;]

Share this post


Link to post
Share on other sites
What specific problems are you having?

As for efficiency, one thing you could do is use lists rather than individual variables, for that you would first create a list (in this case named "Name") in memory, then to use it:

14->dim(lName)

essentially a list "lName" of length 14, to access the list you would write:

lName(n)

where 'n' is the index. This allows you to use more than 26 variables at any given time, which is especially good since all variables in TI-83 Basic are global (last I checked)

Keep in mind that TI-83 Basic was never meant to be particularly fast, for that you'll need a link cable and some of the TI tutorials on Z-80 assembly. They also have TI-83 emulators so you can test it on your computer without bricking your $100 calculator.

Share this post


Link to post
Share on other sites
I LOVE programming for TI-83's [smile]

Your problem is that you have no loop to wait for user input; you just move on to the next frame. This code fixes that problem.

:0->Q

:1->E

:1->F

:0->U

:0->V

:ClrHome

:

:Disp "USE THE ARROW","BUTTONS TO","NAVIGATE.","","PRESS ANY BUTTON","TO CONTINUE."

:Pause

:

:While Q/=1

:ClrHome

:

:For(V,1,8)

:For(U,1,16)

:If U=E and V=F

:Then

:Output(V,U,"O")

:Else

:Output(V,U,".")

:End

:End

:End

:

:If E=16 and F=8

:Goto ND

/* This part changed */

:Repeat X
:getKey->X
:End

:If X=24
:E-1->E

:If X=25
:F-1->F

:If X=26
:E+1->E

:If X=34
:F+1->F

/* End change */

:End



:Lbl ND

:ClrHome

:Disp "YOU WIN!"

:DelVar V

:DelVar U

:DelVar F

:DelVar E

:DelVar Q

:Stop



What this basically does is repeat until the user gives X a value by hitting a key. Then it compares X to each arrow value.

As for the very slow updates, you will have to change your code so that it only calls Output for 2 cells: the one Where the player goes and the one where he came from (to replace the old 'O' with a '.') This will take some logic, but should be doable.

Hope that helps!

Share this post


Link to post
Share on other sites
@All: Will try. I was kinda thinking about the replacement thing before but I wasn't entirely sure how to do it.

I'll post my results in a moment.

Edit: Okay, I did Simian Man's improvement. Much better. Now to the rest...

Edit 2: Is it possible to erase a character in a specified position?

Share this post


Link to post
Share on other sites
Good ole' TI-83 calcs. :) Programmed my first game on an 83, which was a very primitive version of number munchers (took forever). After that I did simpler games, such as blackjack, hi-low, several variations of those games where you have to memorize a sequence of lights and repeat it (although, I used numbers and characters instead), and once I even made a mini text-based RPG with combat and the works. Then I realized it was way better to do that sort of stuff in C++. :)

Anyway, as px said, you can cut down your drawing by pre-drawing the scene and then only updating the spaces where movement has occured. With TI-83's, never, ever try to redraw the entire scene each frame; 83's are way too slow at processing and you'll never get any decent graphics results trying to refresh so often. Just draw the field ahead of time before the While statement, and then all your while statement should be is checking for user input and then updating the spaces needed (also remember to take ClrHome out of the While loop). And draw only when there is user input; don't draw every frame.

Another suggestion: for your getkey, store it as a variable (such as theta). I'd do that because getkey grabs the current key the user is pressing, which could actually change between the if statements; storing the getkey as a variable keeps the same input throughout the rest of that iteration of the loop. I'd also turn the direction checks (left, right, up, down) into an if-else branch.

Hope that helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tallun
Edit 2: Is it possible to erase a character in a specified position?
Yes. Just use Output() as you have been, only do something like Output(x, y, " ") with an empty character (i.e. a space).

Share this post


Link to post
Share on other sites
@Omega147: Yes, Simian Man posted code doing that already, but thanks anyway.

Edit: Right, too slow, never mind this portion.

Thanks again everyone.

Edit 2: That'd be it Omega147, thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tallun
@Omega147: Yes, Simian Man posted code doing that already, but thanks anyway.
Actually, Simian's code is still redrawing at every pass through the loop...

Edit: Or, if you're referring to the key input thing, the Repeat is one way to do it, but if you want to check for other things within the loop (such as if you have a timer going) then I wouldn't take that route.

Share this post


Link to post
Share on other sites
I once wrote a football game for the TI-83 that was so large I had to stop working on it because it was too big to fit on the calculator's memory. I had deleted everything else and it was still too big.

Using a real language is so much easier, but with the TI, you always have bored math students to test your games on [smile].

I read about a C compiler for the Z80 a while ago. I might have to look into that.

Share this post


Link to post
Share on other sites
@Omega147: I was referring to your first post, but you posted while I was writing that message.

Edit: No, no timer, though I will build on this once I get it working well.

Edit 2: Okay, I think what I need here are some previous position variables.

Edit 3: Great frame rate just drawing a new O, and apparently there's no need for writing a blank space, I can just write completely over whatever is already there with the ".".

Share this post


Link to post
Share on other sites
I have no time left to do more with this now, but I thank all of you and have rated you up for your help. I'll be back later.

Share this post


Link to post
Share on other sites
I'm back, as I said I'd be. Now the major problems have been fixed, and I've even reinstated the "collision detection". And it turns out I didn't need last position variables, I just needed to time the drawing differently. Here is the latest code:


:0->Q
:0->X
:0->U
:0->V
:0->E
:0->F
:ClrHome
:
:Disp "USE THE ARROW","BUTTONS TO","NAVIGATE.","","PRESS ANY BUTTON","TO CONTINUE."
:Pause
:ClrHome
:
:For(V,1,8)
:For(U,1,16)
:Output(V,U,".")
:End
:End
:
:Output(F,E,"O")
:
:While Q/=1
:If E=16 and F=8
:Goto ND
:
:Repeat X
:getKey->X
:End
:
:Output(F,E,".")
:
:If X=24 and E>1
:E-1->E
:If X=25 and F>1
:F-1->F
:If X=26 and E<16
:E+1->E
:If X=34 and F<8
:F+1->F
:
:Output(F,E,"O")
:End
:
:Lbl ND
:ClrHome
:Disp "YOU WIN!"
:DelVar F
:DelVar E
:DelVar V
:DelVar U
:DelVar X
:DelVar Q
:Stop



I've certainly come out of this with more than I entered. The program is effectively finished, though now I'll experiment with additions to it.

Thanks all!

[Edited by - Tallun on April 21, 2006 4:31:57 PM]

Share this post


Link to post
Share on other sites
Update
  Since posting the working program previously, I've changed it bit by bit, adding modes and such. Here is the new code:


:Lbl AZ
:0->D
:1->E
:1->F
:16->I
:8->J
:1->O
:1->P
:0->U
:0->V
:0->X
:ClrHome
:
:Disp " -- HERO --","","USE THE ARROW","BUTTONS TO","CATCH THE X.","","PRESS ENTER."
:Pause
:ClrHome
:
:Menu("MODE","EASY",EZ,"NORMAL",NM,"HARD",HD,"MIRROR",MR,"IDIOT",ZA,"(SUGGESTION)",SG)
:
:Lbl SG
:ClrHome
:Disp "MIGHT I SUGGEST","NOT IDIOT?","","PRESS ENTER."
:Pause
:Goto AZ
:
:Lbl MR
:3->D
:8->E
:4->F
:Goto EZ
:
:Lbl HD
:2->D
:Goto EZ
:
:Lbl NM
:1->D
:
:Lbl EZ
:ClrHome
:
:For(V,1,8)
:For(U,1,16)
:Output(V,U,".")
:End
:End
:
:Output(F,E,"O")
:Output(J,I,"X")
:If D=3
:Output(P,O,"X")
:
:While 1
:If D/=3 and E=I and F=J
:Goto ZA
:
:If D=3 and E=I and F=J
:Then
:O->I
:P->J
:1->D
:Goto EZ
:End
:
:If D=3 and E=0 and F=P
:Then
:1->D
:Goto EZ
:End
:
:Repeat X
:getKey->X
:End
:
:If D/=2
:Then
:Output(F,E,".")
:Output(J,I,".")
:End
:
:If D=3
:Output(P,O,".")
:If X=24 and E>1
:E-1->E
:If X=25 and F>1
:F-1->F
:If X=26 and E<16
:E+1->E
:If X=34 and F<8
:F+1->F
:
:If D/=0
:Then
:int(4rand)->X
:If X=0 and I>1
:Then
:I-1->I
:If D=3
:O+1->O
:End
:
:If X=1 and J>1
:Then
:J-1->J
:If D=3
:P+1->P
:End
:
:If X=2 and I<16
:Then
:I+1->I
:If D=3
:O-1->O
:End
:
:If X=3 and J<8
:Then
:J+1->J
:If D=3
:P-1->P
:End
:End
:
:Output(F,E,"O")
:Output(J,I,"X")
:If D=3
:Output(P,O,"X")
:End
:
:Lbl ZA
:Menu("YOU WIN! AGAIN?","YES",AZ,"NO",ND)
:
:Lbl ND
:ClrHome
:DelVar X
:DelVar V
:DelVar U
:DelVar P
:DelVar O
:DelVar J
:DelVar I
:DelVar F
:DelVar E
:DelVar D
:Stop




Details
  There are now a few different modes. In easy mode, the goal doesn't move. In normal mode, the goal moves. In hard mode, the goal moves and tiles entered by you or the goal don't revert back to regular dots, thus allowing the goal to hide inside its path, and you to get lost in yours, though this really doesn't happen much unless you try to do it. In mirror mode, there are two goals, both of which you must collect, which mirror each other's moves. (This is because they might have overlapped otherwise.) In idiot mode, you win. Period.
  Enjoy.

Edit: Editted code in all posts in thread to put in code box.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Can anyone here post the code for "completing the square" THNX.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
what i do is use the calculator for a campaign. i ask them if they want to vote for a certain person and if they say anything but yes i have it say error: vote again

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
my math teacher is always wathing for us making programs and things on the TI-83 and then clears the memory if he catches you. which is why on my personal calculator i blocked the memory menu from access unless you know the password.

Share this post


Link to post
Share on other sites
I'm afraid I don't see the relevance of these last three posts other than that they involve the TI-83. You didn't really need to revive this thread, but since you did, expect another update on the program momentarily...

Edit: Here it is.


:Lbl AZ
:0->D
:1->E:1->F
:16->I:8->J
:1->O:1->P
:25->S
:0->U:0->V
:0->X
:
:ClrHome
:Disp " -- HERO --", "BY TALLUN"
:Pause
:ClrHome
:
:Menu("MODE","EASY",EZ,"NORMAL",NM,"HARD",HD,"MIRROR","MR","QUIT",ZA)
:
:Lbl MR
:3->D
:8->E:4->F
:20->S
:Goto EZ
:
:Lbl HD
:2->D
:25->S
:Goto EZ
:
:Lbl NM
:1->D
:30->S
:
:Lbl EZ
:ClrHome
:
:For(V,1,8)
:For(U,1,16)
:Output(V,U,".")
:End
:End
:
:Output(1,8,S)
:Output(F,E,"O")
:Output(J,I,"X")
:If D=3:Output(P,O,"X")
:
:While 1
:If D/=3 and E=I and F=J:Goto WN
:
:If D=3 and E=I and F=J
:Then
:1->D
:O->I:P->J
:S+10->S
:Goto EZ
:End
:
:If D=3 and E=O and F=P
:Then
:1->D
:S+10->S
:Goto EZ
:End
:
:If S=0:Goto LS
:
:Repeat X
:getKey->X
:End
:
:S-1->S
:If D/=2:Output(F,E,".")
:If D/=0 and D/=2: Output(J,I,".")
:If D=3:Output(P,O,".")
:If X=24 and E>1:E-1->E
:If X=25 and F>1:F-1->F
:If X=26 and E<16:E+1->E
:If X=34 and F<8:F+1->F
:
:If D/=0
:Then
:RandInt(0,3)->X
:
:If X=0 and I>1
:Then
:I-1->I
:If D=3:O+1->O
:End
:
:If X=1 and J>1
:Then
:J-1->J
:If D=3:P+1->P
:End
:
:If X=2 and I<16
:Then
:I+1->I
:If D=3:O-1->O
:End
:
:If X=3 and J<8
:Then
:J+1->J
:If D=3:P-1->P
:End
:End
:
:Output(1,9,".")
:Output(1,8,S)
:Output(F,E,"O")
:If D/=0:Output(J,I,"X")
:If D=3:Output(P,O,"X")
:End
:
:Lbl WN
:Menu("YOU WIN! AGAIN?","YES",AZ,"NO",ZA)
:
:Lbl LS
:Menu("YOU LOSE! AGAIN?","YES",AZ,"NO",ZA)
:
:Lbl ZA
:ClrHome
:DelVar X
:DelVar V:DelVar U
:DelVar S
:DelVar P:DelVar O
:DelVar J:DelVar I
:DelVar F:DelVar E
:DelVar D




Edit: Removed stupid readme.

[Edited by - Tallun on June 2, 2006 7:01:07 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement