Code:
:26→K
:1.1→B
:{4Ans→A
:ClrHome
:For(A,1,E2
:randInt(1,16)+.1randInt(1,8→C
:Repeat C=Ans(1
:A→dim(⌊A
:⌊A(1
:Output(10fPart(Ans),int(Ans),"O
:Output(10fPart(B),int(B),"   // 1 space
:Output(10fPart(C),int(C),"*
:getKey
:If Ans=45
:Goto 0
:If Ans=34 or 2>abs(Ans-25
:Ans→K
:⌊A(A→B
:⌊A(1)+(K=26)-(K=24)+.1((K=34)-(K=25
:If max(LA=Ans
:Goto 0
:Ans+16(not(int(Ans))-(17=int(Ans)))+.8(not(fPart(Ans))-(.9=fPart(Ans
:augment({Ans},⌊A→A
:End
:augment(Ans,{Ans(A→A
:End
:Lbl 0
:ClrHome
:A


I don't understand why put Ans(1 in the Repeat loop instead of just Ans. I tried to, but it gives me a data type error. Can someone tell me why that happens?
I tried it on the Home Screen and it returns Ans. If I try with a number greater than 1 it returns Ans times that number.

And what does C= Ans(1 mean? To execute the loop until C equals C? So would the loop be executed only once?
It has to be Ans(1 because Ans is actually a list variable, which is accessing the first element in the list. The loop will not even run, because the repeat loop will never be executed because Ans == C, and C(1 = C. That's a big problem. Basically, it will keep looping until you hit the food piece, which is what is stored in the C variable. Technically, the loop is executed however many times depending on this line: For(A,1,E2 Basically, it will loop until A = 100. This is some code that could use some serious optimization... Smile

EDIT: See the "Epic Snake" program below Smile
How is C a list variable? Or is the Ans itself a list variable?

And I can't see the code of Epic Snake because i don't have my calcs usb cable, so I can't load the ROM image
You don't need need a calculator to see the code to TI-Basic programs. You can download the program and just drag it into Scourcecoder to view and edit the code. Alternatively, you can download TokenIDE, an offline program editor, and do the same.
AliceIsDead wrote:
How is C a list variable? Or is the Ans itself a list variable?

And I can't see the code of Epic Snake because i don't have my calcs usb cable, so I can't load the ROM image


Well, C is just the food's current position. Ans(1 is the snake's current position. Therefore, it will keep looping until they are equal to each other. But with the way it is currently set up, the loop will never execute because Ans*(1) is equal to the variable C. Hopefully this explains it a little better! Smile
MateoConLechuga wrote:
AliceIsDead wrote:
How is C a list variable? Or is the Ans itself a list variable?

And I can't see the code of Epic Snake because i don't have my calcs usb cable, so I can't load the ROM image


Well, C is just the food's current position. Ans(1 is the snake's current position. Therefore, it will keep looping until they are equal to each other. But with the way it is currently set up, the loop will never execute because Ans*(1) is equal to the variable C. Hopefully this explains it a little better! Smile


But it does. The loop is executed, the program works just fine.
Electromagnet8 wrote:
You don't need need a calculator to see the code to TI-Basic programs. You can download the program and just drag it into Scourcecoder to view and edit the code. Alternatively, you can download TokenIDE, an offline program editor, and do the same.


Hey thanks ^^'
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement