Re: TIB: challenge


[Prev][Next][Index][Thread]

Re: TIB: challenge



While this is true, it will not work with an 89/92/+ calculator because the x=y logic returns either a ''true or a 'false', not a '1' or a '0' like all the rest of the 8x calcs.  (But I assume that we are using an 83 here because of the screen coordinates and the parenthesis after Output)  There are also a few drawbacks with the loop itself:
 
:4->X
:X->Y
:While A<>22            ;assuming that A<>22 to begin with...
:getKey->A
:Output(X,Y," "
:X+(A=26)(X<16)-(A=24)(X>1)->X
:Y+(A=34)(Y<8)-(A=25)(Y>1)->Y
:Output(X,Y,"O"
:End
 
With this loop, you will see not a 'O' on the screen, but a constant flash of 'O' on the screen, and this is where you must decide if you would rather have it constantly flashing, or have the loop be a little less responsive...
 
:4->X
:X->Y
:While A<>22            ;assuming that A<>22 to begin with...
:0->A
:While A=0
:getKey->A
:End
:Output(X,Y," "
:X+(A=26)(X<16)-(A=24)(X>1)->X
:Y+(A=34)(Y<8)-(A=25)(Y>1)->Y
:Output(X,Y,"O"
:End
 
-Miles Raymond      EML: m_rayman@bigfoot.com
ICQ: 13217756       IRC: Killer2        AIM: KilIer2 (kilier2)
http://www.bigfoot.com/~m_rayman/
----- Original Message -----
From: <-Dave->
To: ti-basic@lists.ticalc.org
Sent: Tuesday, June 15, 1999 6:01 PM
Subject: Re: TIB: challenge

Well, you could shrink it a bit by combining the statements dealing with the same variable (meaning just one store [->] for the X var etc), since the less store [->] operations the calc does, the faster it goes.
 
Try this for the X and Y operations:
 
:X+(A=26)(X<16)-(A=24)(X>1) /->/ X
:Y+(A=34)(Y<8)-(A=25)(Y>1) /->/ Y
 
This code uses no IF statements and reduces the number of stores [->] to just 2, while retaining full functionality.  It relies on Boolean logic to determine whether (A=26) AND (X<16), returning a 1 or 0 if each tests true or false, respectively.  You can manipulate these values to either add 1 or subtract 1 from the value of X (or Y) to get the desired effect.
 
(Can you tell I'm a big fan of Boolean logic?)
 
Plus, if you build a loop around the GetKey within the main loop, the code will be more responsive when the user hits a key. (because otherwise, if you hit a key while the calc is handling the IFs, there's no response.)
 
        --Dave Twaddell <d_twaddell@bigfoot.com>
here's my 83 version, I have refined a lot, I think this is THE smallest
you can get for 83> Tell me if I'm wrong.

:8->X:4->Y
:While A<>45
:getKey->A
:Output(Y,X," "
:If A=24 and X<>1
:X-1->X
:If A=25 and Y<>1
:Y-1->Y
:If A=26 and X<>16
:X+1->X
:if A=34 and Y<>8
:Y+1->Y
:Output(Y,X,"O"
:End

The Character is "O" and if you press [CLEAR] it stops.

Follow-Ups: References: