This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
GloryMXE7
Puzzleman 3000


Active Member


Joined: 02 Nov 2008
Posts: 604

Posted: 27 Oct 2009 10:09:06 pm    Post subject:

Ok in order to avoid what happened lasttime we got to set some ground rules
1. try to optimize the program yourself first
2. only submit your own programs, if you take a program from somewhere else there is a chance it has been optimized already
3.only post optimizations of code or code to be optimized

anyway i had some code but im tired so ill post it tommorow
rules go into effect now
Back to top
GloryMXE7
Puzzleman 3000


Active Member


Joined: 02 Nov 2008
Posts: 604

Posted: 13 Nov 2009 07:50:47 pm    Post subject:

*bump*


Code:
:1
:real(0
:If not(Ans=0
:Then
:Output(1,1,"X-LIB NOT FOUND:MAKE SURE X-LIB IS INSTALLED.
:Pause
:Stop
:End
:Output(3,5,"THIN ICE
:Output(6,3,"BY GLORYMXE7
:DelVar SPause
:6{1,2,4,6,8,10,1
:List►matr(Ans,[A]
:List►matr(Ans≠6,[I]
:{7,11→dim([I]
:cumSum(augment([A],cumSum([I]т)т)т)т→[I]
:Lbl 4
:real(2,8,0,0,12,8,0,12,0,8,0,0,1
:Text(-1,0,0,"--LEVEL-SELECT--
:Text(‾1,48,0,"----------------
:8→A:DelVar Breal(1,B,A,2,8,0,4,0,3,0,1
:DelVar KWhile K≠105 and K≠23
:getKey→K
:abs(S-(k=21→S
:Text(-1,56,0,"SKILL MODE:(O",sub("FF)N!)",3S+1,3
:A+8((K=34)-(K=25→Y
:If Y>40 or Y<8
:A→Y
:B+16((K=26)-(K=24→X
:If X<0 or X>80
:B→X
:If X≠B or Y≠A
:Then
:real(1,B,A,2,8,0,4,0,3,0,1
:real(1,X,Y,2,8,0,4,0,3,0,1
:Y→A
:X→B
:End
:End
:If K=23
:Stop
:{8,12→dim([J]
:30→dim(L6
:{5.07,5.07,2.02,4.09,2.06,7.03,2.11,5.07,5.07,2.02,4.09,2.06,7.03,4.11,7.10,7.1
1,4.03,4.03,5.11,2.02,7.02,7.02,5.02,5.08,2.11,7.07,3.02,6.07,6.04,4.07→L6
:DelVar UDelVar V95→C
:For(Y,1,8
:For(X,1,12
:abs(‾1+pxl-Test(A+Y-1,B+1+X→[J](Y,X
:C-pxl-Test(A+Y-1,1+X+B→C
:End
:End
:3A/4+B/16-5→L
:iPart(L6(L→Y
:100fPart(L6(L→X
:3→[J](Y,X
:real(2,9,0,0,12,8,0,12,0,8,0,0,1
:If Not(S
:Then
:DelVar UDelVar VGoto 0
:End
:DelVar T
:While Not(U+V
:getKey→K
: (K=34)-(K=25→U
: (K=26)-(K=24→V
:End
:Lbl 0
:getKey→K
:If K=31
:Goto 99
:If K=45
:Goto 2
:If K=21
:Goto 4
:If K=22
:prgmICESKILL
: (K=34)-(K=25→A
: (K=26)-(K=24→B
:If A and S
:Then
:A→U
:DelVar V
:End
:If B and S
:Then
:B→V
:DelVar U
:End
:T+.2→T
:If Ans≠.4 and S
:Goto 0
:DelVar TX+V+B(S=0→Z
:Y+U+A(S=0→θ
:If 2=[J](θ,Z
:Goto 2
:If S and Not([J](θ,Z
:Goto 2
:If 1=[J](θ,Z
:Then
:C-1→C
:2→[J](Y,X
:3→[J](θ,Z
:Y+U+A(S=0→Y
:X+V+B(S=0→X
:real(2,9,0,0,12,8,0,12,0,8,0,0,1
:End
:If Not(C
:Goto 1
:Goto 0
:Lbl 1
:Text(‾1,24,28,"YOU WIN!
:Pause
:Goto 4
:Lbl 2
:Text(‾1,24,28,"YOU LOST
:Pause
:Goto 4
:Lbl 9
:Stop


heres my code for ThinIce maybe someone can find some stuff I missed. oh and if there's any questions about what is supposed to do what
Ill answer them


Last edited by Guest on 14 Nov 2009 05:09:57 pm; edited 1 time in total
Back to top
FinaleTI


Advanced Newbie


Joined: 28 Oct 2009
Posts: 81

Posted: 13 Nov 2009 10:05:10 pm    Post subject:

GloryMXE7,
I have spied a few optimizations for ThinIce.
There might some I haven't caught, but these should save you a few bytes.

I believe that the
If variable=0
could be replaced by
If not(variable
and the
If variable=1
could be replaced with
If variable
The 0 -> variable statements could be replaced by Delvar variable and then it could be further optimized by removing the line break right after it, as Delvar will act as if there is a line break after it, which can save a few bytes in the long run. I can see you used the Delvar trick a few times, but then went back to 0 -> variable.
I also saw a few quotes that could be removed.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 13 Nov 2009 11:29:30 pm    Post subject:

*puts on his GooseVision™ goggles*

Original:

{8,12→dim([I]
11→C
Fill(6,[I]
For(A,2,6
For(B,1,12
C+1→C
Ans→[I](A,B
End
End

Reduced size by 6 bytes:

{8,12→dim([I]
11
Fill(6,[I]
For(A,2,6
For(B,1,12
Ans+1→[I](A,B
End
End

Or, you could use this faster one (9 bytes larger than what you had, but 230% the speed):

6{1,2,4,6,8,10,1
List►matr(Ans,[A]
List►matr(Ans[font="verdana"]≠
6,[I]
{7,11→dim([I]
cumSum(augment([A],cumSum([I][font="arial"]т
)[font="arial"]т)[font="arial"]т)[font="arial"]т[I]

Here's another original (found twice in the code):

If S=0
Text(-1,56,0,"SKILL MODE:(OFF)
If S=1
Text(-1,56,0,"SKILL MODE:(ON!)

...and this is the same thing for 21 fewer bytes:

Text(-1,56,0,"SKILL MODE:(O",sub("FF)N!)",3S+1,3

Finale TI wrote:
If variable=1
could be replaced with
If variable
More generally, If var[font="verdana"]≠0 can be changed to If var—using the very same rule that applies to the movement code in this game.

Last edited by Guest on 01 Jul 2010 10:27:52 am; edited 1 time in total
Back to top
GloryMXE7
Puzzleman 3000


Active Member


Joined: 02 Nov 2008
Posts: 604

Posted: 14 Nov 2009 06:32:36 am    Post subject:

Thanks for the help
I added the changes, I got rid of the first skillmode on/off sequence and move the second one closer to the beginning of the while loop, and replaced
If k=21
then
abs(s-1→s
[skill mode on/off code]
End

with
abs(s-(k=21→s
[skill mode on/off code]


Last edited by Guest on 14 Nov 2009 11:11:49 am; edited 1 time in total
Back to top
kinkoa


Member


Joined: 28 Jul 2009
Posts: 103

Posted: 14 Nov 2009 11:44:19 pm    Post subject:

my original pong code could use some improvements im sure so please help with it

PROGRAM:PONG
:ClrHome
:Output(4,1,"::::::PONG::::::BY: ADAM WHEELER
:Output(8,3,"PRESS ENTER
:Pause
:ClrHome
:Lbl 1
:ClrHome
:-2->I
:7->A:8->B
:DelVar C1->X
:-1->Y:6->Z
:While Not(C
:ClrHome
:Output(A,B,"O
:Output(8,Z,"(---)
:If A=1
:-X->X
:If A=7 and B>=Z and B<=Z+5
:-X->X
:If A=7:I+1->I
:Output(1,1,I+1
:Output(1,14,U
:If B=1 xor B=16
:-Y->Y
:If A=8:Then
:1->C
:V-1->V
:End
:A+X->A
:B+Y->B
:Getkey
:Z+(ans=26)-(ans=24)
:If 13<=ans
:1
:If 0>=ans
:12
:ans->Z
:End
:ClrHome
:Output(4,5,"YOU LOSE
:Pause
:ClrHome
:If I>U:Then
:I->U
:Output(4,2,"NEW HIGH SCORE
:Output(5,8,U
:End
:Menu("PLAY AGAIN","YES",1,"NO",3
:Lbl 3
:ClrHome


Last edited by Guest on 01 Jul 2010 10:29:31 am; edited 1 time in total
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 15 Nov 2009 10:36:07 am    Post subject:

The end could be:

If I>U
Then
I->U
Output(4,2,"NEW HIGH SCORE
Output(5,8,U
End
Menu("PLAY AGAIN","YES",1,"NO",3
Lbl 3
ClrHome
Output(1,1,"


Last edited by Guest on 01 Jul 2010 10:29:51 am; edited 1 time in total
Back to top
vic9317


Newbie


Joined: 16 Nov 2008
Posts: 26

Posted: 15 Nov 2009 12:49:41 pm    Post subject:

You could also take advantage of Output('s wrap around ability.

:Output(4,1,"::::::PONG::::::"
:Output(5,1,"BY: ADAM WHEELER


could be

:Output(4,1,"::::::PONG::::::BY: ADAM WHEELER


Saves about 7-8 bytes.


Last edited by Guest on 01 Jul 2010 10:30:06 am; edited 1 time in total
Back to top
Flofloflo


Member


Joined: 07 Nov 2007
Posts: 120

Posted: 16 Nov 2009 06:45:31 pm    Post subject:

While Not(C
Could be Repeat C
I don't see other optimisations at the moment...
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 16 Nov 2009 09:51:03 pm    Post subject:

uhh.. whats a:
':DelVar C1->X'
(maybe a typo?)
:DelVarC
:1->X

Lets see what else... You might wanna Re-Structure the program.. Although thats a bit of work.

To increase some speed.. i think..

:Getkey
:If Ans //this bit just helps the prgm skip the whole Movement part of the prgm if no keys were pressed
:Then
:Z+(ans=26)-(ans=24)
:If 13<=ans
:1
:If 0>=ans
:12
:ans->Z
:End
:End


*EDIT.. actually, idk if that'd work.. considering u have B+Y->B right infront of that..


Last edited by Guest on 16 Nov 2009 09:54:08 pm; edited 1 time in total
Back to top
Eeems


Advanced Member


Joined: 25 Jan 2009
Posts: 277

Posted: 16 Nov 2009 10:11:08 pm    Post subject:

U can do the delvar thing, it's because it works. You don't need a beeline char after a delvar, unless it's part of a loop (ie: while statements, repeat statements, for statements)
Back to top
kinkoa


Member


Joined: 28 Jul 2009
Posts: 103

Posted: 17 Nov 2009 10:23:16 am    Post subject:

TI-newb wrote:
uhh.. whats a:
':DelVar C1->X'
(maybe a typo?)
:DelVarC
:1->X

Lets see what else... You might wanna Re-Structure the program.. Although thats a bit of work.

To increase some speed.. i think..

:Getkey
:If Ans //this bit just helps the prgm skip the whole Movement part of the prgm if no keys were pressed
:Then
:Z+(ans=26)-(ans=24)
:If 13<=ans
:1
:If 0>=ans
:12
:ans->Z
:End
:End


*EDIT.. actually, idk if that'd work.. considering u have B+Y->B right infront of that..


you do not need a line break after a delvar statement and the improved code would work except its already past that and far more advanced
PROGRAM:PONG
:ClrHome
:Output(4,1,"::::::PONG::::::BY: ADAM WHEELER
:Pause
:Lbl 1
:DelVar C1→X
:-1→I
:7→A:8→B
:-1→Y:6→Z
:Repeat Not(C
:ClrHome
:Output(A,B,"O
:Output(8,Z,"---"
:If A=1
:-X→X
:If A=7 and B≥Z and B≤Z+3
:-X→X
:If A=7:I+1→I
:Output(1,1,I
:Output(1,14,U
:If B=1 or B=16
:-Y→Y
:V-1(A=8→V
:End
:A+X→A
:B+Y→B
:Getkey
:Z+(ans=26)-(ans=24
:Ans-14(Ans=15)+14not(Ans->Z
:End
:Output(4,5,"YOU LOSE
:Pause
:If I>U:Then
:I→U
:Output(4,2,"NEW HIGH SCORE
:Output(5,8,U
:End
:Menu("PLAY AGAIN","YES",1,"NO",3
:Lbl 3
:ClrHome


Last edited by Guest on 01 Jul 2010 10:30:30 am; edited 1 time in total
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 17 Nov 2009 07:41:28 pm    Post subject:

Are you annoyed with the "Done" at the end of your program. If so, you can get rid of this by placing Output(1,1," (with no space) on the last line.

Last edited by Guest on 01 Jul 2010 10:30:58 am; edited 1 time in total
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 17 Nov 2009 08:18:04 pm    Post subject:

ztrumpet wrote:
Are you annoyed with the "Done" at the end of your program. If so, you can get rid of this by placing Output(1,1," (with no space) on the last line.


or just a " will work as well


Last edited by Guest on 01 Jul 2010 10:26:51 am; edited 1 time in total
Back to top
calcdude84se


Member


Joined: 09 Aug 2009
Posts: 207

Posted: 17 Nov 2009 09:28:29 pm    Post subject:

Yes, but it adds an extra line (so it's an empty line instead of "Done") and it modifies Ans. If you're all right with that, then just " will work fine.
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 17 Nov 2009 09:32:37 pm    Post subject:

Does it relly mess with ans : GRabs calculator
Back to top
kinkoa


Member


Joined: 28 Jul 2009
Posts: 103

Posted: 18 Nov 2009 09:21:42 am    Post subject:

i dont know if it messes with ans but i have the " at the end it doesnt need an output(1,1,"
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 18 Nov 2009 05:05:33 pm    Post subject:

dxfan101010 wrote:
Does it relly mess with ans : GRabs calculator

Yes, it changes Ans to "
That dosn't really matter, because it's the end of your program.
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement