[TI BASIC] Optimizing
Moderator: MaxCoderz Staff
[TI BASIC] Optimizing
well is there a way to optimize this?
getkey->O
if O=26
then
if x>16
-8->x
x+8->x
if x=24
delvar x
end
if O=24
then
if x<=16 or x>+40
16->x
x+8->x
end
like is there a boolean way or am i blind?
getkey->O
if O=26
then
if x>16
-8->x
x+8->x
if x=24
delvar x
end
if O=24
then
if x<=16 or x>+40
16->x
x+8->x
end
like is there a boolean way or am i blind?
Re: [Ti Basic] optimizing
kalan_vod wrote:well is there a way to optimize this?
getkey->O
if O=26
then
if x>16
-8->x
x+8->x
if x=24
delvar x
end
if O=24
then
if x<=16 or x>+40
16->x
x+8->x
end
like is there a boolean way or am i blind?
Code: Select all
getKey
If Ans=26
Then
If X>16
-8->X
X+8->X
X-(X=24)X->X
End
If Ans=24
Then
If X<=16 or X>+40
16->X
X+8->X
End
I believe this code can replace the "if O=26:then:end" code:
Code: Select all
X+(O=26)(8-(8+x)(x>=16)->X
I, too, am in need of some optimization help, and this has become the official BASIC optimization thread, so here's my code:
I am looking more for speed than size, any help would be appreciated, thanks.[/code]
Code: Select all
If K=24 or K=31:3->D
If K=25 or K=22:1->D
If K=26 or K=33:2->D
If K=34 or K=32:0->D
Shaun
This code should do what you want. It is optimized for speed and size. The one caution about it is that it sets the D variable to zero if none of the Boolean conditionals are true. You don't specify if you need the D variable for anything else, so I just assumed you didn't.
Code: Select all
3(K=24 or K=31)+2(K=26 or K=33)+(K=25 or K=22->D
- Shadow Phoenix
- Calc Guru
- Posts: 835
- Joined: Mon 03 Jan, 2005 7:54 pm
- Location: out there. seriosly.
Is there anyway to optimize this?
Attempting to make the smallest Cops and Robbers game =\
Code: Select all
1->B
16->Y
For(F,1,99
If X=A and Y=B
Goto 3
Output(X,Y,6
Output(A,B,9
randInt(1,5-C
If C=/5
Output(X,Y,"_
getKey->K
If K=/0
Output(A,B,"_
X-(C=1 and X=/1)+(X=/8 and C=2)->X
Y-(C=3 and Y=/1)+(Y=/8 and C=4)->Y
B-(K=24 and B=/1)+(B=/16 and K=26)->B
A-(K=25 and A=/1)+(A=/8 and K=34)->A
End
Lbl 3
_ means space
=/ means not equal to
Code: Select all
If K=/0
to
If K
-------
X-(C=1 and X=/1)+(X=/8 and C=2)->X
to
X-(C=1 and X=/1)+(X=/8 and C=2->X