How much can anyone optimize this code?
Code:
Full
AxesOff
LabelOff
GridOff
FnOff
ClrDraw
ZStandard
Horizontal -8
DelVar SRepeat S=50
sub("0123456789",randInt(1,10),1)+sub("0123456789",randInt(1,10),1)+"+"+sub("0123456789",randInt(1,10),1)+sub("0123456789",randInt(1,10),1 -> Str1
"0 -> Str2
DelVar RrandInt(0,74 -> B
Repeat expr(Str1)=expr(Str2
Text(R,B,Str1
R+1 -> R
If R=51
Then
Output(1,1,"YOU LOSE!:(
Stop
End
getKey -> K
If max(K={23,72,73,74,82,83,84,92,93,94,102
Then
If K =/= 23
Then
Str2+sub("789       456       123       0",K-71,1 -> Str2
Else
sub(Str2,1,length(Str2)-(length(Str2)>1 -> Str2
End
Text(57,0,Str2+"   
End
rand(51-S
End
ClrDraw
Horizontal -8
S+1 -> S
Text(57,48,"SCORE: ",S
End
"YOU WON! :)
Graphing Calculator ?
what is the point of the game?
Without going into fancy algorithms (which I don't think could be put in here anywhere), this is as good as it gets (with the first look through).
Did you try running it through SourceCoder 2?
Knowing what it is supposed to do would be nice...
Aye, agreed. Look like a game of some sort.
Sorry about the lack of explanation, here's one:

*Two random numbers that you must add fall down the graphscreen.
*You press number keys (0-9) to answer, DEL to backspace.
*The numbers fall faster as your score increases.
*You win at score of 50.

Playing the game it makes a lot more sense. Smile

And the last time I tryed SourceCoder I was banned. Is that bug fixed now?
Yeaaaah, that happens to everyone. I have no idea why, either, although I'm working on trying to resolve it.
Can someone explain these lines?

Radical Pi wrote:

GridOff
Repeat expr(Str1)=expr(Str2
If max(K={23,72,73,74,82,83,84,92,93,94,102


And instead of using srings for numbers, wouldn't it just be easier to use RandInt( and store it to some variable?
something1990 wrote:
And instead of using srings for numbers, wouldn't it just be easier to use RandInt( and store it to some variable?


easier, probably, but RandInt() is very slow, and by making a string of random ints at the beginning, there is a large speed improvement
The usual number to string routine would be to big in this case.
Code:
Full
AxesOff
LabelOff
GridOff
FnOff
ClrDraw
ZStandard
Do I need all these?
Quote:
Can someone explain these lines?

GridOff
Repeat expr(Str1)=expr(Str2
If max(K={23,72,73,74,82,83,84,92,93,94,102
Gridoff turns the grid off if it's on. If you haven't seen it before I suggest you do a GridOn.

Repeat expr(Str1)=expr(Str2
Str1 is the random expression falling down. Str2 is your answer that is controlled by pressing number keys. The loop repeats until (in simplified real form instead of string) your answer is the same as the random number.

If max(K={23,72,73,74,82,83,84,92,93,94,102
Easy way of saying "If you pressed a number key or Del,..." I'm very sure that can be optimized.
Radical Pi wrote:
The usual number to string routine would be to big in this case.
Code:
Full
AxesOff
LabelOff
GridOff
FnOff
ClrDraw
ZStandard
Do I need all these?


if you are working on the graph screen, yes, as then it makes sure the user has a blank graph screen.
Radical Pi wrote:

Repeat expr(Str1)=expr(Str2
Str1 is the random expression falling down. Str2 is your answer that is controlled by pressing number keys. The loop repeats until (in simplified real form instead of string) your answer is the same as the random number.



Ok. So let's say I want to change from string to number. expr( does this for you? So far I've been doing it by storing a string to Y1...
expr() process a string. So, for example, if Str1 = '1', then yes, expr(Str1) will return 1, or if Str1 = '1+1', then expr(Str1) will return 2 (as far as i understand it anyway)
Ok. So let's say I want to change from string to number. expr( does this for you? So far I've been doing it by storing a string to Y1...[/quote]How do you convert from equation to number?
Radical Pi wrote:
Quote:
Ok. So let's say I want to change from string to number. expr( does this for you? So far I've been doing it by storing a string to Y1...
How do you convert from equation to number?


Str>Equ use that to change Str1 to Y1, then its just Y1->X (if i remember right anyway - been awile since i've had to change a string to a number...)
Quote:
Ok. So let's say I want to change from string to number. expr( does this for you? So far I've been doing it by storing a string to Y1...
How do you convert from equation to number?
Radical Pi wrote:
Quote:
Ok. So let's say I want to change from string to number. expr( does this for you? So far I've been doing it by storing a string to Y1...
How do you convert from equation to number?


....read the post right about yours. I answered that Rolling Eyes
Kllrnohj wrote:
expr() process a string. So, for example, if Str1 = '1', then yes, expr(Str1) will return 1, or if Str1 = '1+1', then expr(Str1) will return 2 (as far as I understand it anyway)

Great. It's easier to use than storing Str1 to Y1, then storing Y1 to A. I planned on using such a method for a base conversion program. My friends, who are in precalc, needer to convert from different bases, so I gave them Omnicalc. But they aren't calculator savvy and Omnicalc only converts from base 10 to base x, and not from base x to base 10 (well as far as I know). A simple program is MUCH smaller and more user friendly. And probably nobody cares... Hey there are those two MSN bots again, and they brought a Googlebot. Why are there two MSN bots? Isn't one enough?
I can extract the Base Converter from MathStuf...or they could just use it with the whole program...
  
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
Page 1 of 2
» All times are UTC - 5 Hours
 
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

 

Advertisement