How many digits do you want to be in the game?(note: The more digits, the bigger the program)
Less than 50
 0%  [ 0 ]
50-99
 0%  [ 0 ]
100-149
 0%  [ 0 ]
150-199
 0%  [ 0 ]
200-500
 42%  [ 3 ]
501-999
 14%  [ 1 ]
1000-4999
 28%  [ 2 ]
5000+
 0%  [ 0 ]
So many it's ridiculous
 14%  [ 1 ]
Total Votes : 7

I just came up with the idea to make the game Pi runner for the calculator, using the getKey command. Here it goes:

Code:

[92,82,92,83,74,93,84,83,82]->L1 //getkey codes for 1,4,1,5,9,2,6,5, and 4//
1->B:0->C
Repeat C=1
If getKey!=0:Then
getKey->A
End
If A=L1(B):Then
B+1->B
Else:1->C
End
Disp "YOU KNOW",B,"DIGITS"


What do you guys think? Any code optimizations that you can think of?
It looks pretty good so far. Maybe you could add some graphics as well?

Code:
{92,82,92,83->L1
1->A
0->B
Repeat B
   getKey
   If Ans
   Then
      Ans!=L1(A->B
      A+1->A
   End
End
Disp "YOU KNOW",Ans,"DIGITS

I didn't test it, but I guess and hope this would work as well.

EDIT: this would work as well, I don't know if it's faster:

Code:
{1,4,1,5,9,2,6,5,3,5,8,9,7,9->L1
1->A
0->B
Repeat B
   getKey
   If Ans
   Then
      26-3int(.1Ans)+10fPart(.1Ans)!=L1(A->B
      A+1->A
   End
End
Disp "YOU KNOW",Ans-2,"DIGITS
Code so far:

Code:
{92,82,92,83,74,93,84,83,94,83,73,74,72,74,94,93,94,73,82,
84,93,84,82,94,94,73,94,93,72,74,83,102,93,73,73,82,92,74,72,92,
84,74,94,74,74,94,72,83,92,102,83,73,93,102,74,72,82,74,82,82,83,
74,93,94,102,72,73,92,84,82,102,84,93,73,84,93,102,73,74,74,73,
84,93,73,102,94,82,73,93,83,94,82,93,92,92,72,102,84,72,74}->L1
Menu("PI RUNNER","LEARN PI",1,"TIME MODE",2,"MARATHON",3)
Lbl 1
Input "HOW MANY DIGITS:",A
Repeat





1->A
0->B
Repeat B
   getKey
   If Ans
   Then
      Ans!=L1(A)->B
      A+1->A
   End
End
Disp "YOU KNOW",B,"DIGITS"



Feel free to work on this.
I feel like this program is going to need to compute the digits of pi rather than just storing a bunch of them... There are tons of different methods for calculating pi, which I'm sure would be a lot smaller size-wise than just storing a whole bunch of them, and would allow the player to actually go as far as he wants or at least, considerably farther. The digits computed would have to be turned back into key codes by reverse engineering the common numpad reader routine. However, I don't know if this would be fast enough to implement in a game...
The only problem with calculating them is that it would increase the size of the program. With calculating every digit.... it would take a while. So if you wanted to, say, go to 500 digits, that would take about a minute and a half... But I'll take a look at it. It would be a good alternative to storing hundreds of getKey codes, though.
You might consider a spigot algorithm and discard digits as you go: https://www.cs.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf
The equation gives me very quick answers.... But it only allows me to go to 34 digits. After that, I get a "Overflow" error.... And when I try to start at 20, and go to 40, the same thing happens. And I can't make my calc discard digits..... Unless there's something that I'm missing. Which I probably am... How can I make my calc discard digits as I go along, so it isn't giving me overflow errors?


Edit: I went and I found a BUNCH of different equations that can solve for pi. But it really doesn't matter, because I need a way to store multiple digits of pi. Maybe if Kerm finished his Doors for the CE, I would be able to store it into a appvar. But until then.. Any ideas, anyone?
What equation are you talking about? The paper describes two algorithms for computing sequential digits of pi.
What if you stored all the digits in a string, you could store a lot, and then you could just a sub command to see if it is right. In the loop you could up a value each time and then do: If sub([string with pi],[value for which digit you are on],1) = UserInput
DWMelon wrote:
What if you stored all the digits in a string, you could store a lot, and then you could just a sub command to see if it is right. In the loop you could up a value each time and then do: If sub([string with pi],[value for which digit you are on],1) = UserInput

Yes, but that would require having a whole lot of digits stored in the program, which would make the program quite large and inevitably create an end to the game... This being said, I think this is what might happen if calculating the digits turns out to be too slow Smile
elfprince: The one listed at the top of the page.

DWMelon: That was my first idea, but I still haven't figured out how to store results from and eq. to a string.
caleb1997 wrote:

DWMelon: That was my first idea, but I still haven't figured out how to store results from and eq. to a string.

Are you absolutely sure you have to have the equation? You could just copy and paste the first 2000-ish digits of pi, and see if the input matches that digit of pie with a If sub("digits-of-pi",(a number that goes up each time the loop is run (which digit of pi you are on)),1 = Input
EDIT: Oh, I somehow missed Mr. Womp-Womp post. I suppose this maybe searching through a string of that size would be a bit slow... However If you put in enough digits, you really don't have to worry about the game ending. Someone can only memorize so far!

Code:
 "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214
8086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933
4461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209
2096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179
3105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860
9437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249
5343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804
9951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617
1776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989
3809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245
4150695950829533116861727855889075098381754637464939319255060400927701671139009848824012858361603563707660104710
1819429555961989467678374494482553797747268471040475346462080466842590694912933136770289891521047521620569660240
5803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297
45557067498385054945885869269956909272107975093029553211653449872027559602364806654991198818347977535"->Str9
DelVar Str8
ClrHome
Menu("Pi Runner","Learn Digits",1,"Test Yourself",A2,"Quit",3)
Lbl 1
1->E
Goto 2
Lbl A2
0->E
Lbl 2
2->A:" "->Str8:0->theta
Repeat theta=1
Output(1,1,sub(Str9,1,A+E))
getKey->B
If B=92:Then
"1"->Str8
End
If B=93:Then
"2"->Str8
If B=94:Then
"3"->Str8
End
If B=82:Then
"4"->Str8
End
If B=83:Then
"5"->Str8
End
If B=84:Then
"6"->Str8
End
If B=72:Then
"7"->Str8
End
If B=73:Then
"8"->Str8
End
If B=74:Then
"9"->Str8
End
If B=102:Then
"0"->Str8
End
If Str8!=" ":Then
If Str8=sub(Str9,A+1,1):Then
A+1->A:" "->Str8
Else:1->theta
End
End
End
ClrHome
Disp "You know ",A," Digits","Next 25 digits are:"
Output(5,1,sub(Str9,A,25
Pause
Clrhome
Lbl 3
Stop
End

This is about 1781 bytes. Not bad.


What I plan to do with this is to add a mode that sets a storyline like so:

You are running from robbers. If you don't type pi in fast enough, they will capture you. But if you type in the wrong digit, you trip, and they get closer. type the wrong number 3 times, and it's game over.

What do you guys think? Good idea? Bad idea? Or should I wait for Doors CE so I can add Hybrid basic to it and make the gameplay faster?


And while I'm at it, I have a feeling that there is a way to optimize this:

Code:
getKey->B
If B=92:Then
"1"->Str8
End
If B=93:Then
"2"->Str8
If B=94:Then
"3"->Str8
End
If B=82:Then
"4"->Str8
End
If B=83:Then
"5"->Str8
End
If B=84:Then
"6"->Str8
End
If B=72:Then
"7"->Str8
End
If B=73:Then
"8"->Str8
End
If B=74:Then
"9"->Str8
End
If B=102:Then
"0"->Str8
End


Any ideas?
caleb1997 wrote:
(...)
What do you guys think? Good idea? Bad idea? Or should I wait for Doors CE so I can add Hybrid basic to it and make the gameplay faster?
That sounds like a good idea! I've no idea how long it takes before DoorsCE will come out, so I guess you're better off with normal textsprites or whatever.

EDIT: mr womp womp made a fast key->string method:

The code is

Code:
sub("7894561230.",B-22-7int(.1B),1
It's giving me a Domain Error at that line of code that you gave me. What should I do? I have no idea why it's giving me that error.

I have:

Code:
If getKey:Then
Ans->B
sub("7894561230.",B-22-7int(.1B),1)->Str7 //goto error brings me here, to the last parenthesis//
End
That is probably easy to fix. What is variable B?

EDIT: probably this helps?

Code:
getKey->B
If Ans
Then
sub(blablabla
End
  
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 1
» 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