So, I want to make a program that teaches mathematical pi up to 255 digits.

A few features I came up with for it are:
    A training mode where it shows the digits up to 255, five digits at a time

    A challenge mode where you type in as many digits as possible, and if you type in a wrong digit, it records your score and

    if it's high enough, gets posted on the leader boards where it shows the top five scores. For a name you can type in eight characters.


I already have a title screen and opening menu, which I like to put in all my programs. Here's the programming for that:


Code:
:0->Xmin
:94->Xmax
:~62->Ymin
:0->Ymax
:AxesOff
:FnOff
:ClrDraw
:RecallPic 0 //The title screen image
:For(X,0,1000
:Ans->A
:End
:ClrDraw
:Menu("","Trainer mode",A,"Challenge mode",B,"Leaderboards",C,"Quit",Z


(Halfway through writing this my laptop lost charge and I lost half of my work, so here's an abridged version of the boatload of stuff I typed earlier)

Here's a list of things I need help with on my program.

    Graphics and pages. So what I imagine for the trainer mode is that it would show you five digits of pi at a time up to 255. Pressing the right arrow key would show you the next five digits, and pressing the left shows the previous five. I already know how to use getKey. What I want are nice-looking numbers. The Text( command wouldn't work because it outputs rather small characters. I want these characters to be large and nice looking. The only thing I have thought of so far would be using StorePic and RecallPic, but there's only room for ten of those, and five are already occupied on my calculator.

    Leader boards. I need a way to display the top five scores alongside the person's name. I think that a custom list, list LDB might work, but I need ways to display the contents of the list (which I believe I may be able to figure out on my own, but it would be helpful if it were posted here anyways) and a way to input the name of the user. I believe that SortD( can put the scores in descending order, so that isn't a problem.

    Challenge mode. So what challenge mode is, again, is that you would enter in as many digits as possible. When you type in an incorrect digit, it tells you how many you have gotten correct and determines whether or not it should be n the leader boards. Now, what I thought I would do is use a list to store all of the digits of pi, and if the digit entered isn't equal to the digit on the list, then it would give you a fail message and put your score on the leader board if it's high enough. But if I did it like that, then I would have to type in a line of code for every digit of pi up to 255. Is there a better way to do this?


If possible, please give me snippets of code I can use in my program. I'll be sure to credit anyone who helps!

EDIT:
Here's the current code in my test program:


Code:
:ClrHome
:"3.14159..."->Str1
:0->A
:Repeat Str2!=sub(Str1,A,1
:Repeat Ans
:getKey
:End
:Disp "Test
:sub("7894561230.",Ans-22-7int(.1Ans),1->Str2
:A+1->A
:If A>=length(Str1
:Then
:Disp "You win!
:Pause
:ClrHome
:End
:End


Thank you to PT_ for that. So how I have it now, every time you hit a correct key, it will display "Test".

I need it to do three things:
    Work on the graph screen, not the home screen

    Instead of displaying a single thing every time you hit a correct key, I instead need it to display text. So when you hit the 3 key, it will execute a text command pasting a 3 at 1,1. Then when you hit the . key, I need it to paste a . after that. Then a 1, then a 4, and so on.

    And finally, when you lose, I need it to store your score into a list, use SortD( to make the highest score the first on the list, and then send you to the leader boards.


So if anybody can help me with these things, please do.
thanks.
I remembered me that caleb1997 (?) was also busy with such as a pi runner, which looks like the Challenge Mode. Anyway, here is an algorithm for checking the key with the digit of pi:

Code:
"141592653589793238462643383279502884197169399375105820974944..."->Str1
0->A
Repeat Str2!=sub(Str1,A,1
  Repeat Ans
    getKey
  End
  sub("7894561230.",Ans-22-7int(.1Ans),1->Str2
  A+1->A
End

You could also 'optimize' it with not storing the key as a string, but as a value with this routine:

Code:
max(0,26-3int(.1K)+10fPart(.1K

Hope this helps! Smile
Thanks, PT_ and earthnite! I'll be sure to try this out.
I notice that in this code you gave me, PT_, it doesn't give any sort of sign that you have pressed a button when you do, and that typing in a wrong key just ends the program. In order to fit this into my program, I would need to have it highlight a number or something when you type in a number correctly, and I would need it to instead record your score and store it into a list whether you finish or not, and send you to the leader board screen as well.
See the following is to your liking:

Code:

"141592653589793238462643383279502884197169399375105820974944..."->Str1
"3." + Str1 -> Str3
0->A
Repeat Str2!=sub(Str1,A,1
  Repeat Ans
    getKey
  End
  ClrHome
  sub("7894561230.",Ans-22-7int(.1Ans),1->Str2
  A+3->B
  (B<=128)-(B-127)(B>128
  Output(1, 1, sub(Str3,Ans,128(B>=128)+B(B>128
  A+1->A
End


As for your second concern, why not use A as the score? After all, that is how many digits they got correct.
Making the leader board would be easy enough; I do this for my Rubik's Cube timer! Just compare A to the lowest value in your list; if it's greater, add it to the list, use SortD(), and then subtract one from the dimensions. Easy enough!
earthnite wrote:
If you want larger text you may want to look into text sprites or something similar

As much as I hate to disagree with people, I would veer you miles away from text sprites for two reasons
    1) They are slow and long to make, even with tools like a text sprite generator Wink Wink

    2) You initially wanted a 7 segment display, which I think would be challenging and a great way to learn some ti-basic, since I've never seen it done, you could also pave the way for future programmers by creating a generalized routine.
If you've however given up on the 7 segment display but would still like larger/nicer text, you could always use something like BatLib but this would require users having it installed on their calculator and would obviously not work on color calcs. Since the program would now require libs, you could go on to use the libs in DoorsCS to invert a rectangle around the characters on the screen when they are typed in correctly and maybe a square around them when they aren't, but I think at this point you would just be getting carried away into the vast ocean of libs Razz
Hmmm... you could, could, use Pt-On() and Lbl/Goto in some neat way to make your own text... Would probably be a bit tedious, and slow, but not too bad.
Oh wow, I didn't even see these posts! I'll make sure to put these to use.
Here is my implementation of a five digit 7 segment display. Each time you press a key, it displays the next five digits, unless that key is [CLEAR].



Code:
"141592653589793238462643383279502"->Str1  //pi fraction digits
{63,6,91,79,102,109,125,7,127,103->L1   //decimal representation of 7 seg disp states
0->A  //Current digit of pi
ClrDraw
~20->Ymin         //set up a friendly window
0->Xmin
1->DeltaY
1->DeltaX
AxesOff
Repeat Ans=45   //exit if the key was [clear]
   For([recursiven],2,74,18  //shift to the right for each of the five digits
      A+1->A
      int(2fPart(.5L1(inString("0123456789",sub(Str1,A,1)))/2^{0,1,2,3,4,5,6   //decimal to binary
      Line([recursiven]+1,35,[recursiven]+14,35,Ans(1         //Turn the segments on or off
      Line([recursiven]+15,34,[recursiven]+15,21,Ans(2
      Line([recursiven]+15,19,[recursiven]+15,6,Ans(3
      Line([recursiven]+14,5,[recursiven]+1,5,Ans(4
      Line([recursiven],6,[recursiven],19,Ans(5
      Line([recursiven],21,[recursiven],34,Ans(6
      Line([recursiven]+1,20,[recursiven]+14,20,Ans(7
   End
   Repeat Ans  //repeat until the user presses a key
      getKey
   End
End


You can change the window settings to shift the numbers around the screen. You might also want to limit A so that people can't go past the end of the string.
Oh my, that is amazing!

Awesome job on that, jonbush. I'll be sure to tweak it for my use!
Ah, so it seems like the "and" you said to enter in after :Repeat Ans=45 is actually an "or". Thanks to GTemples for figuring that out.
StrawberryFrostedPopTart wrote:
Ah, so it seems like the "and" you said to enter in after :Repeat Ans=45 is actually an "or". Thanks to GTemples for figuring that out.


I am glad you got this figured out, but if you look at the logs you will see that I corrected myself very shortly afterward:

Code:
<jonbush> Where it says Repeat Ans=45, change it to "Repeat Ans=45 and A>[max digits]"
<jonbush> Then put the Goto after the last End
<saxjax> [StrawberryFrostedPopTart] kk
<KInfinity> Geometry Dash would be easy, if it wasn't for all the effect
<KInfinity> s
<jonbush> Also make sure the number of digits is a multiple of 5
<saxjax> [StrawberryFrostedPopTart] It is, 255
<saxjax> [StrawberryFrostedPopTart] and is there anyway to display a 3.?
<saxjax> [StrawberryFrostedPopTart] I know that the . would give an error
<jonbush> Correction: Repeat Ans=45 or A>=[max digits]
GTemples27 wrote:

<snip>

Code:
"141592653589793238462643383279502884197169399375105820974944..."->Str1
"3." + Str1 -> Str3
0->A
Repeat Str2!=sub(Str1,A,1
  Repeat Ans
    getKey
  End
  ClrHome
  sub("7894561230.",Ans-22-7int(.1Ans),1->Str2
  A+3->B
  (B<=128)-(B-127)(B>128
  Output(1, 1, sub(Str3,Ans,128(B>=128)+B(B>128
  A+1->A
End

<snip>


I've been trying to use this in my program, but there are a few problems that I can't fix.

    First of all, entering in a wrong digit sends me to the home screen. I need it to store your score into a list and take you to Lbl M when you enter in a wrong digit.

    I also need it to send you to the menu without recording your score if you hit the CLEAR key.

    Finally, something I still can't do for some reason is wrapping text. I've tried a few things but none of them work.

    And something that doesn't really need fixing but would be cool if it could be is response time. It takes a noticeable amount of time after pressing a digit for it to appear on the screen.


If you can help with these that would be great. And once this is done, πTrain will be complete!
Here's my try Smile

Code:
"14159265......"->Str1
"3."+Str1->Str3
0->A
SetUpEditor |LPI
If not(dim(|LPI
{0->|LPI
Lbl MENU
{max(A,|LPI->|LPI
Menu("blaaaaaaaaaaaaaaaaaaaaaaahhhhhh","start",0,"stop",1
Lbl 1
Return
Lbl 0
Repeat Str2!=sub(Str1,A,1) or A>[length_str3] or [clear_pressed]
  Output(1,1,sub(Str3,max(1,A-24),min(A+2,26 // when A>24, don't display the first digits of pi
  Repeat Ans 
    getKey 
  End 
  sub("7894561230.",Ans-22-7int(.1Ans),1->Str2
  A+1->A
End
Goto MENU

Note: this is untested!

This will always send you to the menu, and it saves your highscore to list PI. Of course, this is a kind of pseudocode, you need to fix this yourself Smile

If you have still questions, ask us Very Happy
I can reiterate what we talked about before with regard to text wrapping with single characters:

Since you know which digit of pi you are on, you can use integer division and modulus to calculate the position to display that character at.

Code:
Text(7int(A/23),4round(23fPart(A/23),0),Str2


You can store the score into a custom list with some sort of identifier after exiting the loop. Using the routine above should be significantly faster than displaying the entire substring every time.
This is a bit confusing to me. That label in the middle and the menu, can I exclude that? I need it to send you to Lbl M, which already exists.

What I mean is this:


Code:
<snip>
:{0->|LPI
:{max(A,|LPI->|LPI
:Repeat Str2!=sub(Str1,A,1) or A>length(Str3) or Ans=45
:Text(1,1,sub(Str3,max(1,A-24),min(A+2,26
:Repeat Ans
:getKey
:End
:sub("7894561230.",Ans-22-7int(.1Ans),1->Str2
:A+1->A
:End
:Goto M


Just tested it. I seem to get a data type error at line:
:{max(A,|LPI->|LPI
StrawberryFrostedPopTart wrote:
Just tested it. I seem to get a data type error at line:
:{max(A,|LPI->|LPI

That should be this:

Code:
max(A,|LPI->|LPI
or
Code:
{max(A,}LPI(1->|LPI
  
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