Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: DJ Omnimaga on August 27, 2007, 05:30:00 am

Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 27, 2007, 05:30:00 am
Ok, here is the new form of Omnimaga contests: we post a code sample, that is poorly optimized, and you optimize it. It is kinda like a game. Remember the spam forum games? It is the same, except that it's not spam, and it's 100% relevant to calculators. Everyone, give it a shot, this may also help practice your skills or learn more new stuff, and debate about which kind of optimization is better.

Here is the current code to optimize:

c1-->
CODE
ec1ArchivePic1:
{0}→L1:0→R:12→dim(?A):12→dim(?B):12→dim(?C)
FnOff:PlotsOff:Normal:Float:Full:GridOff:AxesOff:ZStandard
ClrDraw:ClrHome
"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: Netham45 on August 27, 2007, 08:45:00 am
french. :(sad.gif j/k

when I get home, I shall get this on my calc and try it.
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 27, 2007, 08:55:00 am
I realize this code is not really compatible with any editor on the computer. Could take a little bit for me to sort this thing out.

EDIT: Erm, is that line that says

"Horizontal(10"

meant to be that way? Or should it be:

"Horizontal (10"

or:

"Horizontal 10"

?
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 27, 2007, 09:10:00 am
Horizontal 10 because source coders seems to have issue parsing Horizontal x.x
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on August 27, 2007, 09:13:00 am
It takes a long time to type this all out on calc... and I'm not even halfway yet x_x
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 27, 2007, 09:33:00 am
Computer + Copy/Paste?

BTW, about the rules:

1. Are we optimizing for size, and size only?
2. The optimized program merely needs to function like the code, right? (We don't need to base it off that code?

And the second line:

"{0}→L1"

Is it meant to be:

"{0}→?1"

(list 1)?
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 27, 2007, 10:05:00 am
for size mostly, but if you manage to get it both small and fast it raise your chances of winning. The optimised program must function like the code does, but you can use different code to do it, as long as it works exactly like in the code. and yes it is meant to be list 1
Title: GAME: Optimize this! (83+BASIC)
Post by: Harrierfalcon on August 27, 2007, 10:48:00 am
c1-->
CODE
ec1Archive Pic1
DelVar R{0→L1
12→dim(?A
12→dim(?B
12→dim(?C
FnOff
PlotsOff
Normal
Float
Full
GridOff
AxesOff
ZStandard
ClrDraw
ClrHome
"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on August 27, 2007, 11:03:00 am
QuoteBegin-Harrierfalcon+27 Aug, 2007, 21:48-->
QUOTE (Harrierfalcon @ 27 Aug, 2007, 21:48)
c1-->
CODE
ec1Ans(1→A
Ans(2→B
Ans(3→C
Ans(4→D
Ans(5→E
Ans(6→F
Ans(7→G
Ans(8→H
Ans(9→J
Ans(10→T
Ans(11→U
Ans(12→Vc2
ec2  

 You... you can't be serious...
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on August 27, 2007, 11:54:00 am
To optimize Harrier's code...
c1-->
CODE
ec1Archive Pic1
DelVar R{0→L1
12→dim(?A
Ans→dim(?B
Ans→dim(?C
FnOff
PlotsOff
Normal
Float
Full
GridOff
AxesOff
ZStandard
ClrDraw
ClrHome
"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 27, 2007, 12:27:00 pm
c1-->
CODE
ec1:ArchivePic1
:12→dim(?A
:12→dim(?B
:12→dim(?C
:FnOff
:PlotsOff
:Normal
:Float
:Full
:GridOff
:AxesOff
:ZStandard
:ClrHome
:"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on August 27, 2007, 12:52:00 pm
Mine's going to take a few more hours/days. I'm doing it on calc, and I'm going to link to the actual program when I submit it :Ptongue.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 27, 2007, 01:38:00 pm
no problem with sub routine, as long as you post all of them  
Title: GAME: Optimize this! (83+BASIC)
Post by: burr on August 27, 2007, 07:31:00 pm
c1-->
CODE
ec1:ArchivePic1
:12→dim(LA
:12→dim(LB
:12→dim(LC
:FnOff
:AxesOff
:ZStandard
:ClrHome
:Output(7,2,"Programme par
:Output(8,2,"Kevin Ouellet
:Repeat getKey=105
:Output(1,1,"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: Jon on August 27, 2007, 08:20:00 pm
Heh the Ans(1 thing is easy. just do this each time:
c1-->
CODE
ec1
Ans->A
Ans+Ans->B
Ans+Ans->C
....and so on
c2
ec2
Title: GAME: Optimize this! (83+BASIC)
Post by: burr on August 27, 2007, 10:22:00 pm
QuoteBegin-Jon+28 Aug, 2007, 2:2-->
QUOTE (Jon @ 28 Aug, 2007, 2:20)
Heh the Ans(1 thing is easy. just do this each time:
c1-->
CODE
ec1
Ans->A
Ans+Ans->B
Ans+Ans->C
....and so on
c2
ec2

If you try that out, it actually doesn't work like you think. Because the current value in Ans is a list, storing Ans to A will actually make A into a list.  
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 28, 2007, 03:09:00 am
please dont murder my program jon lol... j/k its getting better and better at least ?ompared to the 5 years old crap I wrote in the first post ^^
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on August 28, 2007, 03:54:00 am
But if it would work, it would be better of like this:
c1-->
CODE
ec1
Ans->A
2Ans->B
2Ans->C
....and so on
c2
ec2
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on August 28, 2007, 04:28:00 am
This:
c1-->
CODE
ec1ClrHome
"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 28, 2007, 04:33:00 am
I was sure someone would manage to save over 100! %)rolleyes2.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 28, 2007, 07:20:00 am
c1-->
CODE
ec1:ArchivePic 1
:12→dim(LA
:Ans→dim(LB
:Ans→dim(LCc2
ec2
HA! 2 bytes!
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 28, 2007, 08:52:00 am
dont worry I'll make sure to check the code samples in some way to make sure they work, in the mean time make sure it work yourself :Ptongue.gif. It take ages to type everything people post here manually on calc because the formatting breaks when i paste it in TI-Graph Link or SourceCoder x.x
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on August 28, 2007, 09:06:00 am
c1-->
CODE
ec1:ArchivePic1
:{0→L1
:DelVar R12→dim(?A
:Ans→dim(?B
:Ans→dim(?C
:Degree
:FnOff
:PlotsOff
:Normal
:Float
:Full
:CoordOff
:GridOff
:AxesOff
:LabelOff
:ExprOff
:ZStandard
:Func
:Connected
:Sequential
:Real
:ClrHome
:Output(7,2,"Programme par
:Output(8,2,"Kevin Ouellet
:Repeat getKey=105
:Output(1,1,"TTT TTT
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 28, 2007, 06:19:00 pm
oh great somebody saved me some work. When I started those contest I didnt realised the huge task that was awaiting me (copy all programs posted one by one by and and compare size and see if they work) :Dbiggrin.gif now I have one done alerady  
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 29, 2007, 05:05:00 am
*Xphoenix can help. I converted the original into a program, and edited off of that, so it shouldn't be too hard to convert those . . . Should I help?
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 29, 2007, 11:22:00 am
well the original is alerady a program :Ptongue.gif

it's the launching program for Team Demo found in Downloads/Calculator RPGs and Programming Tools/TI-83+/
feel free too help but you dont have to do it, it will just take longer to declare the winner :Ptongue.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 29, 2007, 06:21:00 pm
Well, the original does not function right if you, for instance, just copy it into graphlink. You need to take care of those special characters. I thought you meant it would be hard to turn all of these into working programs, at which point you could compare the size.
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 29, 2007, 06:41:00 pm
yeah but i meant that there is alerady a downloadable 8xp version of the file in the archives here. in the team demo zip there is prgm thetathetathetathetathetathetathetatheta.8xp, which is that program. Idk if it was locked down tho, you may need Mirage to open it. In my first post i used source coder to post the code but edited it because it didnt showed fine
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on August 30, 2007, 07:43:00 am
I would give you mine, but it seems that the uploading is not working.
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 30, 2007, 05:11:00 pm
it should, else just upload to savefile.com
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on August 31, 2007, 11:35:00 am
harrier, never forget to remove the last " in string storage so
"TTT TTT  T  T  T T  T   T T TTTT T  TT  TTT TTTT T  T   T T T  T T  TTT T T T  T=  -= 2002 =-  ="→Str1
would become
"TTT TTT  T  T  T T  T   T T TTTT T  TT  TTT TTTT T  T   T T T  T T  TTT T T T  T=  -= 2002 =-  =→Str1


And burr it is Output(, not Text(, since the program title screen if homescreen

I still didnt checked all programs but I have went through some of them alerady on first page, don't worry ;)wink.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 02, 2007, 01:54:00 am
Update. I am sorry to announce that the first BASIC optimizing contest is being cancelled (in some ways).

As some people have noticed I've did lot of works and updates on Omnimaga website in the past week. When I've started those contests, I did not realise the pain and hassle I would have to try everybody's program. Since the formatting in those piece of code is different than TI-Graph Link and SourceCoder I have to copy every single piece of code by hand on my calculator, one by one, and this is just way too much work for me alone. Sorry everyone :(sad.gif

So what I am doing now, is that I am skipping to Contest 2 without declaring any winners for the first one, which is cancelled. However, contest 2 use the EXACT same piece of code than the first one (see the first post of this topic). You have to optimize it to make it as small as possible and make sure it still function like the original. However, you must include a 8xp file with your source code posted here. If the forum upload doesn't work for you use http://www.savefile.com to upload your optimized program.

Afterward, all programs will be tested directly on calc, and size of each of them will be compared, to finally declare the winner.

Sorry again for this.  
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on September 02, 2007, 04:21:00 am
Two things:

1. Forum upload doesn't work for me... When I attach, and then preview OR post, it takes me the portal.

2. This is sort of a compilation of everyone's code, so... (Namely Weregoose and burr)

3. http://www.savefile.com/files/1023805

4. I can't count right right now.

[ EDIT ]

Oh yeah...

5. Source:

QuoteBegin-"BASIC Code"+-->
QUOTE ("BASIC Code")
:ArchivePic1
:DelVar R12→dim(?A
:Ans→dim(?B
:Ans→dim(?C
:FnOff
:PlotsOff
:Normal
:Float
:Full
:GridOff
:AxesOff
:ZStandard
:ClrHome
:"?
:For(A,1,4
:For(B,1,40
:Ans+sub(" TTTT EEEE AAAA MMMM",5A-4,expr(sub("4412121221211225213145212112221221422212",B,1
:End
:Ans+sub("
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on September 02, 2007, 06:52:00 am
Wouldn't combining everyone else's code be cheating? ._.
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 02, 2007, 05:18:00 pm
not in this contest, because your goal is also to find more optimizations in the code people posts as well, so the prgm is even better. make sure to say you took some part of the code tho
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 02, 2007, 09:02:00 pm
In that case, you can change...
c1-->
CODE
ec1If θ=15 and LA(1
?A→L1
If θ=32 and LB(1
?B→L1
If θ=49 and LC(1
?C→L1c2
ec2
Into...
c1
-->
CODE
ec1For(X,1,3
expr("?"+sub("ABC",X,1
If θ=17X-2 and Ans(1
Ans→L1
Endc2
ec2
In order to save six bytes.
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on September 03, 2007, 05:19:00 am
http://www.savefile.com/files/1026482
Title: GAME: Optimize this! (83+BASIC)
Post by: dinhotheone on September 03, 2007, 08:44:00 am
QuoteBegin-Weregoose+3 Sep, 2007, 3:02-->
QUOTE (Weregoose @ 3 Sep, 2007, 3:02)
In that case, you can change...
c1-->
CODE
ec1If θ=15 and LA(1
?A→L1
If θ=32 and LB(1
?B→L1
If θ=49 and LC(1
?C→L1c2
ec2
Into...
c1
-->
CODE
ec1For(X,1,3
expr("?"+sub("ABC",X,1
If θ=17X-2 and Ans(1
Ans→L1
Endc2
ec2
In order to save six bytes.  

 WHOA! i didnt know you could do that! could you also declare lists like that? i must test this!

Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 03, 2007, 12:10:00 pm
The concept of a user giving a name to a list by any means other than explicitly typing it out has been beaten to death. I'm sorry to say that it cannot be done in TI-Basic.
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 03, 2007, 02:04:00 pm
you mean using input?
Title: GAME: Optimize this! (83+BASIC)
Post by: Speler on September 03, 2007, 03:00:00 pm
No, he means having the user input the name and for a list to then be created with that name.
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 03, 2007, 03:45:00 pm
yeah thats what i meant, i wish it was possible tho, too bad it isn't
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on September 06, 2007, 11:37:00 am
Sooooo. . . Contest over?
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 06, 2007, 05:33:00 pm
well if anyone still have new programs i can accept them, but for now you're kinda winner by default since you're the only one to meet the (new) requirements x.x (both source posted and a 8xp file)

thanks to everyone for participating though, I'll try to prepare more when i do the next contest. It may be another prgm from this game, but I'm not sure yet.
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on September 06, 2007, 10:57:00 pm
I provided a .8xp... just to the wrong upload site  :icebeam:s196.gif

Any thoughts on what the next basic optimization project could be?
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 07, 2007, 12:05:00 am
oh crap missed it, but i know the others people like weregoose didn't, even if they read the new rules
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 07, 2007, 04:03:00 am
If you guys want, I can post one of my own programs and see how you can optimize it. Note, however, that it uses xLib heavily.
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on September 07, 2007, 10:21:00 am
That sounds like a good challenge. xLib unreadability should be a tough obstacle to add to the contest.

I'm trying (once again) to program a Tic Tac Toe game. I could submit that for an optimization contest here, since it's not like I could submit it to ticalc ;)wink.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 07, 2007, 11:30:00 am
Alright then guys, here it is; turns it it doesn't use xLib as much as some of my other programs:
c1-->
CODE
ec1:6→dim(L5
:Text(‾1,0,0,"CHOOSE A TRAIT:
:Text(‾1,9,0,">DARE DEVIL
:Text(‾1,18,6,"CAUTIOUS
:Text(‾1,27,6,"GEAR HEAD
:Text(‾1,36,6,"PACIFIST
:Text(‾1,45,6,"BLOODTHIRSTY
:Text(‾1,54,6,"RANDOM TRAIT
:DelVar B1→A
:Repeat B=54
:0
:Repeat Ans
:real(8
:End
:Ans→B
:A→E
:A+(B=1 and A<6)-(B=4 and A>1→A
:If A≠E:Then
:For(C,9E,9A,A-E
:Text(‾1,C-1,0,"
:Text(‾1,C,0,">
:For(D,0,Z/5
:End:End:End:End
:A-(A=6)(randInt(1,5→L5(1
:prgmθSTDRKN
:real(12,6,0,0,95,62,1
:Text(‾1,0,0,"USE ARROW KEYS
:Text(‾1,9,0,"TO PUT POINTS IN
:Text(‾1,18,0,">PILOTING:
:Text(‾1,27,6,"GUNNERY:
:Text(‾1,36,6,"MERCHANT:
:Text(‾1,45,6,"ENGINEERING:
:Text(‾1,54,0,"EXTRA:
:4→dim(L2
:L5(1→A
:Fill 2,L5
:A→L5(1
:L5(2)+(A<3)-(A=3→L5(2
:L5(3)+(A=5)-not(fPart(A/2→L5(3
:L5(4)+(A=4)-(A=5→L5(4
:L5(5)+(A=3)-(A=1→L5(5
:For(A,1,4
:L5(A+1→L2(A
:End
:11→L5(6
:prgmθSTLGHT
:2→A
:While L5(6
:For(B,2,6
:Text(‾1,9B,82,L5(B
:If 10>L5(B
:Text(‾1,9B,88,"
:End
:Repeat B=3 or B=2
:Repeat Ans
:real(8
:End
:Ans→B
:A→E
:A+(B=1 and A<5)-(B=4 and A>2→A
:If A≠E:Then
:For(C,9E,9A,A-E
:Text(‾1,C-1,0,"
:Text(‾1,C,0,">
:For(D,0,Z/5
:End:End:End:End
:B=3 and L5(6)>0 and L5(A)+1≤7+L2(A-1→C
:C+L5(A→L5(A
:L5(6)-C→L5(6
:B=2 and L5(A)-1≥L2(A-1→C
:L5(A)-C→L5(A
:C+L5(6→L5(6
:End
:For(A,1,4
:Text(‾1,9A+9,82,L5(A+1
:End
:DelVar L2real(12,6,0,55,95,62,1
:Text(‾1,54,0,"CONFIRM? (Y/N)
:Repeat 5=abs(Ans-39
:real(8
:End
:If Ans=34
:Then
:DelVar L420→dim(L4
:{2,L5(1),L5(2),L5(3),L5(4),L5(5),125,100,0,2.2,5000,10→L4
:End
:DelVar L5c2
ec2
Title: GAME: Optimize this! (83+BASIC)
Post by: Xphoenix on September 07, 2007, 03:28:00 pm
Space Trader, right? Looks fairly well optimized, but I might be able to do a few bytes...
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 07, 2007, 04:26:00 pm
QuoteBegin-Xphoenix+7 Sep, 2007, 19:28-->
QUOTE (Xphoenix @ 7 Sep, 2007, 19:28)
Space Trader, right? Looks fairly well optimized, but I might be able to do a few bytes...

Yup, it actually took me some time to decide which one to post, as I didn't want to give away any secrets (like the two special reputations).

EDIT: W00t, 500 posts!
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 07, 2007, 04:40:00 pm
congrats delnar (*DJ Omnimaga
Title: GAME: Optimize this! (83+BASIC)
Post by: kalan_vod on September 08, 2007, 12:20:00 am
QUOTE
:If Ans=34
:Then
:DelVar L420→dim(L4
:{2,L5(1),L5(2),L5(3),L5(4),L5(5),125,100,0,2.2,5000,10→L4

:End
:DelVar L5

I just took a glance at this, looks fairly good. I just noticed that line, i wont point it out so you can find it ;)wink.gif.
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 08, 2007, 06:31:00 am
QuoteBegin-kalan_vod+8 Sep, 2007, 4:2-->
QUOTE (kalan_vod @ 8 Sep, 2007, 4:20)
QUOTE
:If Ans=34
:Then
:DelVar L420→dim(L4
:{2,L5(1),L5(2),L5(3),L5(4),L5(5),125,100,0,2.2,5000,10→L4

:End
:DelVar L5

I just took a glance at this, looks fairly good. I just noticed that line, i wont point it out so you can find it ;)wink.gif.  

 Hehe, that is the exact line I was expecting for people to optimize. :Ptongue.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: kalan_vod on September 08, 2007, 02:20:00 pm
Making sure you realized, other than that I see a few things but I will find some time ;)wink.gif (looking good though!).
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 09, 2007, 09:10:00 pm
c1-->
CODE
ec1augment({2},augment(seq(L5(X),X,1,5),{125,\EE\2,0,2.2,5\EE\3,1->L4c2
ec2
Just saves 14 bytes.
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 10, 2007, 03:48:00 am
Nice Weregoose!

How the heck could I forget about augment? :paf:tripaf.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 10, 2007, 09:35:00 am
For some reasons I think weregoose will win this one, because i didn't found anymore possible optimizing in his last post
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 10, 2007, 11:30:00 am
Actually, you can save 15 bytes here:
c1-->
CODE
ec1Text(-54125+1,0,0,"CHOOSE A TRAIT:
For(X,1,6
Text(-54125+1,9X,6(X≠1),sub(">DARE DEVIL CAUTIOUS
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 10, 2007, 11:45:00 am
user posted image
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 10, 2007, 12:21:00 pm
Update:
c1-->
CODE
ec1:L5(1
:2+{Ans,Ans<3,Ans=5,Ans=4,Ans=3,9}-{2,Ans=3,not(fPart(.5Ans)),Ans=5,Ans=1,0→L5
:seq(Ans(X),X,2,5→L2 -or- ΔList(cumSum(Ans→L2:4→dim(L2c2
ec2
Another 10 bytes taken from there.
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 10, 2007, 12:43:00 pm
O_Oshocked2.gif:bow:worship.gif

Well, I implemented all of the stuff I understood in Weregoose's post (aka everything, even if I don't use seq( and sub( ), and it turns out he optimized almost 100 Bytes off. The only thing I didn't implement was the rand(Z thing, because Weregoose probably didn't know what Z means (it is one of the most important variables, alongside Theta): in my program, Z represents the calculator model the program is running on so that the program doesn't go too fast or too slow during the "smooth" transitions. Z is determined towards the beginning of the first program that should be run.

Now that the obvious winner has been announced *cough*Weregoose*cough*, how about if I post the ugliest piece of code in Space Trader? It is kind of short, yet I am positive some of you will notice optimizations.
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 10, 2007, 01:04:00 pm
I think I'll only have more to say if I come up with something astronomical.

Looking forward to the next snippet. ;)wink.gif

(Congrats on 2^9 8
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 10, 2007, 01:19:00 pm
congrats ^.^
Title: GAME: Optimize this! (83+BASIC)
Post by: Radical Pi on September 10, 2007, 01:57:00 pm
Weregoose, how do you do that?! You are amazing...

Can anyone find a more elegant/smaller way to write:
c1-->
CODE
ec14+6fPart(A/3)+6not(fPart(A/3))c2
ec2
Those ending parentheses are there because this little slice of code is one of the coordinates in a text output.
I'm just trying to figure out a way to turn the numbers seq(X,X,1,9) into {6,8,10,6,8,10,6,8,10}. I'm pretty sure my way isn't the best...
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 10, 2007, 03:28:00 pm
6+6fPart(A/3-3‾
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 10, 2007, 04:58:00 pm
Alright guys, cringe at the most horrible piece of code there is so far in Space Trader (FYI, it's the huge line):
c1-->
CODE
ec1:real(0,0
:real(3,8,0,1
:DelVar W54→B
:Lbl A
:Repeat W≥7
:If B>48
:Then
:For(C,62,55,-1
:real(1,8,C,10,8,5,0,8W,0,0,1
:real(3,8,2,1
:For(D,0,Z
:End:End:End
:While Ans>53 or Ans<49
:real(8
:End
:Ans→B
:If W=2
:(B≠51)(55-B→E
:not(W)(2(B=53)+3(B=52)+4(B=50)+7(B=51))+(W=2)(1+15(B=51))+(B≠49)((W=1)(4E+53-B)+(W=3)(7-B-14(B<52))+(W=4)(72-B)+(W=5)(75-B)+(W=6)(78-B→D[/b]
:If D<7
:Then
:real(12,0,9,55,85,55,1
:For(C,57,62
:real(12,1,8,C-1,86,C-1,1
:real(1,8,C,10,8,5,0,8W,0,0,1
:real(3,8,2,1
:For(F,0,Z
:End:End:Endc2
ec2
Title: GAME: Optimize this! (83+BASIC)
Post by: calc84maniac on September 11, 2007, 02:08:00 am
Could you state what that line is trying to accomplish, in words? I don't feel like figuring it out myself. :Ptongue.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 11, 2007, 09:15:00 am
All that is equivalent to:
c1-->
CODE
ec1If W=2
(B≠51)(55-B→E
If W=0
2(B=53)+3(B=52)+4(B=50)+7(B=51→D
If W=2
1+15(B=51→D
If B≠49
Then
If W=1
4E+53-B→D
If W=3
7-B-14(B<52→D
If W=4
72-B→D
If W=5
75-B→D
If W=6
78-B→D
Endc2
ec2
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 11, 2007, 05:47:00 pm
O_Oshocked2.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 11, 2007, 06:09:00 pm
...if it helps. I didn't optimize anything.

(All that = that one line)
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 11, 2007, 06:25:00 pm
uhm i dont understand what you mean, i felt it was kinda optimised because of the size decrease
Title: GAME: Optimize this! (83+BASIC)
Post by: Weregoose on September 11, 2007, 09:09:00 pm
c1-->
CODE
ec1:not(W)(2(B=53)+3(B=52)+4(B=50)+7(B=51))+(W=2)(1+15(B=51))+(B≠49)((W=1)(4E+53-B)+(W=3)(7-B-14(B<52))+(W=4)(72-B)+(W=5)(75-B)+(W=6)(78-B→Dc2
ec2
=
c1
-->
CODE
ec1:If W=2
:(B≠51)(55-B→E
:If W=0
:2(B=53)+3(B=52)+4(B=50)+7(B=51→D
:If W=2
:1+15(B=51→D
:If B≠49
:Then
:If W=1
:4E+53-B→D
:If W=3
:7-B-14(B<52→D
:If W=4
:72-B→D
:If W=5
:75-B→D
:If W=6
:78-B→D
:Endc2
ec2
Title: GAME: Optimize this! (83+BASIC)
Post by: nitacku on September 11, 2007, 11:32:00 pm
c1-->
CODE
ec1:If W=2
:Then
:(B≠51)(55-B→E
:1+15(B=51
:End
:If not(W
:2(B=53)+3(B=52)+4(B=50)+7(B=51
:If B≠49
:Then
:If W=1
:4E+53-B
:If W=3
:7-B-14(B<52
:If W>3
:84-3W
:End
:Ans→D
c2
ec2

A little bit beter
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 12, 2007, 04:07:00 am
oh that line, i see
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 12, 2007, 01:17:00 pm
QuoteBegin-nitacku+12 Sep, 2007, 3:32-->
QUOTE (nitacku @ 12 Sep, 2007, 3:32)
c1-->
CODE
ec1:If W=2
:Then
:(B?51)(55-B?E
:1+15(B=51
:End
:If not(W
:2(B=53)+3(B=52)+4(B=50)+7(B=51
:If B?49
:Then
:If W=1
:4E+53-B
:If W=3
:7-B-14(B<52
:If W>3
:84-3W
:End
:Ans?D
c2
ec2

A little bit beter  

 Actually, since the code is all on one line, your optimization has no effect in the real code.

Here is what the code I posted above does. Some of you might have seen the screenshot a long time ago:
user posted image
Title: GAME: Optimize this! (83+BASIC)
Post by: dinhotheone on September 12, 2007, 02:40:00 pm
i think he was actually just tryng to help other people optimize it by making it more readable.  
Title: GAME: Optimize this! (83+BASIC)
Post by: Insanity on September 12, 2007, 05:04:00 pm
That looks awesome.
Title: GAME: Optimize this! (83+BASIC)
Post by: DJ Omnimaga on September 12, 2007, 05:56:00 pm
nice delnar :Dbiggrin.gif
Title: GAME: Optimize this! (83+BASIC)
Post by: kalan_vod on September 13, 2007, 03:46:00 am
If I did not know any better I would think this was a SS thread, as it is sick! :Ptongue.gif

Making something less sophisticated sometimes help with the speed.
Title: GAME: Optimize this! (83+BASIC)
Post by: Delnar_Ersike on September 13, 2007, 03:56:00 am
It's actually slower than in the screenshot, as I turned on power mode in PTI (by pressing the spark plug thingy).

Back on topic, can anybody actually optimize the code snippet? I know Weregoose is holding back on purpose, but is there anyone else who can read the line (other than me)?
Title: GAME: Optimize this! (83+BASIC)
Post by: kalan_vod on September 13, 2007, 09:08:00 am
c1-->
CODE
ec1:(B≠51 and W=2)(55-B→E
:not(W)(1+15(B=51))+(W=2)(6-(B-49)+3(B=51)-(B=50))+(B≠49)(4E(W=1)+6-B+3W+(W=3)-14(B<52 and W=3)-10(W=1→Dc2
ec2

Kinda ran through it, but I think it would work (can be made to work if not). This would be optimized of:
c1
-->
CODE
ec1:If W=2
:(B≠51)(55-B→E
:not(W)(2(B=53)+3(B=52)+4(B=50)+7(B=51))+(W=2)(1+15(B=51))+(B≠49)((W=1)(4E+53-B)+(W=3)(7-B-14(B<52))+(W=4)(72-B)+(W=5)(75-B)+(W=6)(78-B→Dc2
ec2
I know this can be optimized more, I am not too great with long logic :Ptongue.gif.