[TI BASIC] Optimizing

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

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

Post by kalan_vod »

Could anyone help Optimize this for speed, i have made all the ifs into booleans, but a couple didnt help the speed so i changed them back.

Code: Select all

[A](A,B
If 25=Ans or 14=Ans
Then
prgmA3
Else
prgmLVL
End
[A](A,B
Repeat A=1 or B=1 or A=8 or B=12 or 25=Ans or 14=Ans
Repeat O
real(1,8B-8,8A-8,1,8,0,0,X,3,0,1
getKey->O
real(1,8B-8,8A-8,1,8,0,0,X,3,0,0
End
B+(O=26 and 12<[A](A,B+1))-(O=24 and 12<[A](A,B-1->B
A+(O=34 and 12<[A](A+1,B))-(O=25 and 12<[A](A-1,B->A
X+(O=26)(8-(8+X)(X≥16
Ans+(O=24)(8-(Ans-16)(Ans≥40 or Ans≤16
If O=25
55
If O=34
48
Ans->X
If O=21
prgmA1
[A](A,B
End
prgmSTART
>_= greater than or equal to
<_= less than or equal to
Last edited by kalan_vod on Fri 23 Sep, 2005 1:18 am, edited 2 times in total.
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

change

Code: Select all

If O=25 
55->X 
If O=34 
48->X 

Code: Select all

30(O=25)+14(O=34)+X->X
and thats all i can think of. Although all the [A] references are slow and it would be faster for you to copy the term into a variable and use the variable sdince you are using it more than 1 time.
Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

threefingeredguy wrote: and thats all i can think of. Although all the [A] references are slow and it would be faster for you to copy the term into a variable and use the variable sdince you are using it more than 1 time.
Thanks I will try this out, and I never thought about placing it into a variable.
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

threefingeredguy wrote:change

Code: Select all

If O=25 
55->X 
If O=34 
48->X 

Code: Select all

30(O=25)+14(O=34)+X->X
yeah, this doesnt work....
Edit: code is now updated.
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

Replace S with Ans and instead of ->S write nothing.

Also, -16+X is the same as X-16.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

DarkerLine wrote:Replace S with Ans and instead of ->S write nothing.

Also, -16+X is the same as X-16.
Yeah, thanks for the optimization there sir :) .
Edit: code is updated. (thanks guys keep it coming :D)
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

A bit late, but

real(1,8B-8,8A-8,1,8,0,0,X,3,0,1
getKey->O
real(1,8B-8,8A-8,1,8,0,0,X,3,0,0

can be changed to

For(I,0,1
real(1,8B-8,8A-8,1,8,0,0,X,3,0,I
End
getKey->O
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

For speed it would be faster but its not much faster and for size its bigger :D, thanks anyway.
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

It's bigger? Count again, I got a result of 21 bytes smaller. :o
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

kalan_vod wrote:
threefingeredguy wrote:change

Code: Select all

If O=25 
55->X 
If O=34 
48->X 

Code: Select all

30(O=25)+14(O=34)+X->X
yeah, this doesnt work....
Edit: code is now updated.
Errr, do

Code: Select all

55(O=25)+48(O=34)+X(O<doesntequal>25 and O<doesntequal>25)->X
That's what I meant, maybe I sick when I wrote that one before.
Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

err, i meant it......ill try it :D, maybee i was sick when i did that :lol: .
Edit: Thanks it works dl, but tfg yours dosn't :D.
BASIC Code wrote::real(7,0
:If 38Image[A](A,B:Then :prgmA3:Else :prgmLVL:End
:Repeat 39=Ans or 38=Ans
:Repeat Image
:For(I,1,0,(-)1
:real(1,8B-8,8A-8,1,8,0,0,X,3,0,I
:End
:getKeyImageImage
:End
:B+(Image=26 and 36<[A](A,B+1))-(Image=24 and 36<[A](A,B-1ImageB
:A+(Image=34 and 36<[A](A+1,B))-(Image=25 and 36<[A](A-1,BImageA
:X+(Image=26)(8-(8+X)(XImage16
:Ans+(Image=24)(8-(Ans-16)(AnsImage40 or AnsImage16
:If Image=25:55
:If Image=34:48
:AnsImageX
:If Image=21:prgmA1
:[A](A,B
:End
:prgmSTART
Thats the updated version :P.
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Nuts.
Image
User avatar
Loki
Extreme Poster
Posts: 314
Joined: Thu 18 Aug, 2005 7:01 pm
Location: My world is in grayscale, but if i stand still long enough, i see it in black and white.
Contact:

Post by Loki »

Anyone know a smaller way of doing this:

Code: Select all

Delvar A
While not(A
getKey
If Ans=21
1->A
End
for pausing until 2nd is pressed? Like Pause, except i want the key to continue to be the 2nd key.
Image
pacHa
Sir Posts-A-Lot
Posts: 190
Joined: Sun 09 Jan, 2005 9:51 am
Contact:

Post by pacHa »

Code: Select all

:Repeat Ans=21
:GetKey
:End
This might work, if my basic memories are good (assuming Ans != 21 before this)
Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Code: Select all

Repeat getkey=21
End
Post Reply