[TI BASIC] Optimizing

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

[TI BASIC] Optimizing

Post by kalan_vod »

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? :?
Guest

Re: [Ti Basic] optimizing

Post by Guest »

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
Shrinked it just a pickle...
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

thanks but this wouldn't help much and also i use the getkey ans in the entire program, i just was trying to make it faster :D
Guest

Post by Guest »

Replace

Code: Select all

if x=24
delvar x 
with

Code: Select all

X-(X=24)X->X 
meh
Guest

Post by Guest »

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
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

gj man i appreciate it :D it didnt relly make it faster but its 2 bytes smaller :)
Virtuoso

Post by Virtuoso »

You could try to describe what you want
There could be a better way to do it that you dont see

~Virtuoso
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

I, too, am in need of some optimization help, and this has become the official BASIC optimization thread, so here's my 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
I am looking more for speed than size, any help would be appreciated, thanks.[/code]
Shaun
Guest

Post by Guest »

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
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

Yeah, I probaly should have specified that I do...
Shaun
User avatar
Shadow Phoenix
Calc Guru
Posts: 835
Joined: Mon 03 Jan, 2005 7:54 pm
Location: out there. seriosly.

Post by Shadow Phoenix »

Do
:D->L1(1)
:3(K=24 or K=31)+2(K=26 or K=33)+(K=25 or K=22->D
:if D = 0
:L1->D
Life is getting better.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

This isn't correct, because 0 is also a valid value.
leofox
Calc Master
Posts: 1064
Joined: Fri 17 Dec, 2004 3:22 pm
Location: Probably playing DDR
Contact:

Post by leofox »

If D=0

can be optimized to

If not(D
Image
Image
Guest

Post by Guest »

Is there anyway to optimize this?

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
Attempting to make the smallest Cops and Robbers game =\
Guest

Post by Guest »

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 
There might be more...
Post Reply