Don't have an account? Register now to chat, post, use our tools, and much more.
Online Users
There are 102 users online: 5 members, 70 guests and 27 bots.
Bots: MSN/Bing (1), Magpie Crawler (3), VoilaBot (5), Googlebot (17), MSN/Bing (1).
SAX
 » Goto page 1, 2, 3  Next
Author Message
rcplanegy

Member

Joined: 23 Sep 2010
Posts: 174

 Posted: 09 Oct 2010 03:59:17 pm    Post subject: Optimization Help: Moon Lander Game here is a moon lander game. movement, crashing, fuel count, and gravity all work. i need 3-5 landing pads, a way to 'refuel' at those landing pads, a way to pause when you touch a landing pad so you dont fly right through it and crash, and a way to count scores... THE FIRST PERSON TO MAKE A FEASIBLE, WORKING OPTIMIZATION GETS THERE NAME IN THE CREDITS!!!!!! Code: ```:31→Z :47→X :1→W :100→G :Lbl 1 :If Z≤7 and Z≥0:Text(34,47,"CRASH!" :If Z≤7 and Z≥0:Stop :If G≤0:0→G :W+.5→W :Z-W→Z :Horizontal(0 :Text(1,1,"FUEL:" :Text(1,20,G :Line(X-1,Z,X+1,Z :Line(X-2,Z-1,X+2,Z-1 :Line(X-1,Z-2,X+1,Z-2 :Line(X-2,Z-3,X-2,Z-4 :Line(X+2,Z-3,X+2,Z-4 :Line(X,Z-3,X,Z-3 :If G≥1:Goto 2 :If G≤0:Goto 1 :Lbl 2 :If K=34:Line(X,Z-5,X,Z-6 :getKey→K :If K=24:X+2→X:Z+.5→Z :If K=34:Z+3→Z :If K=34:W-1.25→W :If K=26:X-2→X:Z+.5→Z :If K=34:Line(X,Z-5,X,Z-6 :If K=34:G-1→G :ClrDraw :Goto 1```_________________Learning consists of questions and answers With every question we discover answers. With those answers we uncover more questions. So, are you answering your questions... ...Or questioning your answers?
qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

 Posted: 09 Oct 2010 04:03:55 pm    Post subject: instead of using labels to loop why dont you use a for() or while/repeat loop?_________________
MufinMcFlufin

Joined: 29 Aug 2009
Posts: 252

 Posted: 09 Oct 2010 04:04:46 pm    Post subject: Repeat would probably be best in this situation._________________ MufinMcFlufin's quote of the week: "Diapers and Politicians should both be changed often for the same reason." -Anonymous
calcdude84se

Power User

Joined: 14 Jun 2010
Posts: 408

 Posted: 09 Oct 2010 04:06:46 pm    Post subject: ^++ I second the notion of loops, etc. (not to mention that "If Condition1:Statement1:If Condition1:Statement2" can be condensed to "If Condition1:Then:Statement1:Statement2:End"). We can always help on that. After that's done so it's more readable, I might help _________________People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster. -Adam Osborne
MufinMcFlufin

Joined: 29 Aug 2009
Posts: 252

 Posted: 09 Oct 2010 04:18:47 pm    Post subject: rcplanegy, are you sure this program works as is? I put it on my calculator, and it doesn't seem to work almost at all._________________ MufinMcFlufin's quote of the week: "Diapers and Politicians should both be changed often for the same reason." -Anonymous
comicIDIOT

Guru

Joined: 01 May 2006
Posts: 5108
Location: SFBA, California

Posted: 09 Oct 2010 04:22:54 pm    Post subject:

 qazz42 wrote: instead of using labels to loop why dont you use a for() or while/repeat loop?
His use of Labels is fine. There's nothing wrong with labels in a program this small and when they are used correctly.
_________________

-Alex
MufinMcFlufin

Joined: 29 Aug 2009
Posts: 252

Posted: 09 Oct 2010 04:24:34 pm    Post subject:

comicIDIOT wrote:
 qazz42 wrote: instead of using labels to loop why dont you use a for() or while/repeat loop?
His use of Labels is fine. There's nothing wrong with labels in a program this small and when they are used correctly.

It's not whether or not they're correct, it's that he wants it optimized, and there are better ways than what he's doing here with labels.
_________________

MufinMcFlufin's quote of the week:
"Diapers and Politicians should both be changed often for the same reason."
-Anonymous
qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

Posted: 09 Oct 2010 05:09:54 pm    Post subject:

comicIDIOT wrote:
 qazz42 wrote: instead of using labels to loop why dont you use a for() or while/repeat loop?
His use of Labels is fine. There's nothing wrong with labels in a program this small and when they are used correctly.

yes, but he is asking for optimizations and frankly , loops are a bit faster....

(also, made the first optimization so credits )
_________________

comicIDIOT

Guru

Joined: 01 May 2006
Posts: 5108
Location: SFBA, California

Posted: 09 Oct 2010 05:13:16 pm    Post subject:

 qazz42 wrote: (also, made the first optimization so credits )
Not so.

 Quote: THE FIRST PERSON TO MAKE A FEASIBLE, WORKING OPTIMIZATION GETS THERE NAME IN THE CREDITS!!!!!!
By working, he needs landing pads that pause the game (more than the Pause token), landing pads, a way to count scores, and a method to refuel while landed.

You did none of those

Not to mention you didn't optimize anything. How would you get rid of the labels and add the loops? Share some optimized code with us, rather than suggesting.
_________________

-Alex
MufinMcFlufin

Joined: 29 Aug 2009
Posts: 252

 Posted: 09 Oct 2010 05:24:15 pm    Post subject: qazz, you didn't actually change any code. This is what an optimization looks like: Code: ``` :0→Xmin :1→ΔX :0→Ymin :1→ΔY :E2→F :31→D :Ans→E :47→O :Ans→P :DelVar HDelvar VClrDraw :Repeat D≤.5 :Text(0,1,"FUEL: ",F,"    :Pt-Off(P,E+1,3 :Pt-Off(P,E,2 :Pt-On(O,D+2 :Pt-On(O,D,2 :Pt-Off(O,D-1,3 :Horizontal(0 :getKey→G :D→E :O→P :If F and max(G={24,25,26,34 :Then :H-2(G=34)+2(G=25→H :V+2(G=26)-2(G=24→V :F-1→F :End :H-1→H :D+HE‾2→D :O+VE‾2→O :End :Pt-Off(O,2,2 :Pt-Off(O,3,2 :40≥√(H2+V2 :Pt-On(O,1,3-Ans :Pt-On(O,2+Ans :Text(6,1,sub("CRASHED!SAFE!",1+8Ans,8-3Ans :Pause ``` Haven't added anything that wasn't already in the game, but it's smaller now, and has safe/crashed landing._________________ MufinMcFlufin's quote of the week: "Diapers and Politicians should both be changed often for the same reason." -Anonymous
souvik1997

Guru-in-Training

Joined: 19 Apr 2010
Posts: 2870

 Posted: 09 Oct 2010 05:39:26 pm    Post subject: Why don't you use the SourceCoder optimizer? http://sc.cemetech.net_________________CALCnet Tournament-38% deviantArt
calcdude84se

Power User

Joined: 14 Jun 2010
Posts: 408

 Posted: 09 Oct 2010 05:46:54 pm    Post subject: It's not that kind of optimizer To my knowledge it does little more than removing closing parentheses/etc. and using Delvar. Correct me if I'm wrong _________________People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster. -Adam Osborne
qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

Posted: 09 Oct 2010 05:54:38 pm    Post subject:

comicIDIOT wrote:
 qazz42 wrote: (also, made the first optimization so credits )
Not so.

 Quote: THE FIRST PERSON TO MAKE A FEASIBLE, WORKING OPTIMIZATION GETS THERE NAME IN THE CREDITS!!!!!!
By working, he needs landing pads that pause the game (more than the Pause token), landing pads, a way to count scores, and a method to refuel while landed.

You did none of those

Not to mention you didn't optimize anything. How would you get rid of the labels and add the loops? Share some optimized code with us, rather than suggesting.

hmm, bah, good point x.x

unfortunetly, the TI-Basic part of my brain is not functioning, but I will tell you what I come up with later if I get the time >.>
_________________

KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

Posted: 09 Oct 2010 06:58:08 pm    Post subject:

 calcdude84se wrote: It's not that kind of optimizer To my knowledge it does little more than removing closing parentheses/etc. and using Delvar. Correct me if I'm wrong
That's correct. There is a topic in the SourceCoder subforum about why its optimizer works the way it does, actually, and a call for suggestions and code from people who want to make it smarter. At rcplanegy, I recommend you work through your program piece by piece, add functionality one thing at a time (ie, first the craft movement, then drawing the pads, etc etc), and present each of the pieces of code to us to optimize. Therefore, after we finish helping you with this, I recommend that you try to add your extra features that you suggested, and present that code to us, rather than asking us to write the extra features for you.
_________________

MufinMcFlufin

Joined: 29 Aug 2009
Posts: 252

Posted: 09 Oct 2010 08:54:37 pm    Post subject:

KermMartian wrote:
 calcdude84se wrote: It's not that kind of optimizer :P To my knowledge it does little more than removing closing parentheses/etc. and using Delvar. Correct me if I'm wrong :)
That's correct. There is a topic in the SourceCoder subforum about why its optimizer works the way it does, actually, and a call for suggestions and code from people who want to make it smarter. At rcplanegy, I recommend you work through your program piece by piece, add functionality one thing at a time (ie, first the craft movement, then drawing the pads, etc etc), and present each of the pieces of code to us to optimize. Therefore, after we finish helping you with this, I recommend that you try to add your extra features that you suggested, and present that code to us, rather than asking us to write the extra features for you. :)

Kerm++

Huge reason why I didn't add any functionality to the optimized program I made.

Besides, most people aren't going to go through those sorts of hoops if you're rewarding them a spot in the credits for a game they made.
_________________

MufinMcFlufin's quote of the week:
"Diapers and Politicians should both be changed often for the same reason."
-Anonymous
qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

 Posted: 09 Oct 2010 10:22:53 pm    Post subject: also, one thing I would like to point out is not to use stop, it is considered bad programming style. Use return instead... just to say that it can sometimes mess up a shell's parser_________________
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

Posted: 09 Oct 2010 10:41:31 pm    Post subject:

 qazz42 wrote: also, one thing I would like to point out is not to use stop, it is considered bad programming style. Use return instead... just to say that it can sometimes mess up a shell's parser
An excellent point, qazz42. As of Doors CS 7, DCS successfully catches and mitigates the problems associated with Stop, but if you disable the library support, use a competitor shell, or use DCS 6.2 or earlier, Stop can cause problems.
_________________

qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

 Posted: 09 Oct 2010 10:44:38 pm    Post subject: Yikes, the lib support option also combats the stop crappyness? Weird... I would think it to be the parser hook... anywho, I remember I crashed many calcs a day using stop with mirageOS_________________
KermMartian

Joined: 14 Mar 2005
Posts: 55764
Location: Earth, Sol, Milky Way

Posted: 09 Oct 2010 10:47:16 pm    Post subject:

 qazz42 wrote: Yikes, the lib support option also combats the stop crappyness? Weird... I would think it to be the parser hook... anywho, I remember I crashed many calcs a day using stop with mirageOS
I understand your confusion, let me clarify. The Parser Hook, aka HomeRun, is one parser hook: it catches program executions at the homescreen. That's all. Enabling/disabling third-party hybrid library support makes a different parser hook be enabled while a program is actually executing; that hook looks for real(, sum(, det(, and identity. I made it also watch for Stop, and if it is about to run it, throw a special type of TI-OS error code that Doors CS then catches and handles as a clean exit instead of letting the OS deal with it.
_________________

qazz42

Vampire Killer

Joined: 07 Apr 2010
Posts: 4177

 Posted: 09 Oct 2010 10:49:16 pm    Post subject: hmm, I get it, seems fair enough also, one more thing, the waiy you have :If G≥1:Goto 2 :If G≤0:Goto 1 would be easier to read if it said :If G≥1 :Goto 2 :If G≤0 :Goto 1 it just makes it a bit more understandable and easier on the eyes_________________ Last edited by qazz42 on 09 Oct 2010 11:02:10 pm; edited 1 time in total
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
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.

»
 » Goto page 1, 2, 3  Next Page 1 of 3 » All times are GMT - 5 Hours

 Jump to: Select a forum Announcements----------------Cemetech AnnouncementsCemetech LabsContests General Discussion----------------Technology & Calculator Open Topic-- Electronics/Hardware Development-- Calculator HardwareYour ProjectsGeneral Open Topic-- Politics & Rants-- Reviews-- Humour/Jokes Cemetech's Projects----------------Doors CSSourceCoderMember Features-- TI-Freak8x-- Merthsoft-- GrammerOther & Upcoming Projects-- The BASIC Elite-- mobileTunes-- CALCnet 2.2-- SuggestionsProgramming the TI-83 Plus/TI-84 PlusUsing the TI-83 Plus/TI-84 PlusWebsite Programming & Design----------------General Programmingz80 AssemblyTI-BASICCasio Prizm/FX Development & ProgrammingWebsite Markup & ScriptingGraphics1337 Programming Tips Building with Blocks----------------FreeBuild, LEGO, and Minecraft-- FreeBuild General-- Suggestions & Troubleshooting-- Content & Gallery-- Servers & Activities
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.040198 seconds.