I was on a long car trip so naturally I brought one of my calculators and computer. I was bored of Minecraft so I remembered a game my friend showed me called Petals Around the Rose. Not really a game.... more of a puzzle. Riddle type thing.

So the puzzle/riddle/game is that the one person knows the rule and anyone else playning doesn't. The people that don't know the rule take turns rolling dice and guess values according to what they think the rule is. Then the person who knows the rule says the actual value. The first to figure out the rule wins.

But on my calc version, I suppose you could pass the calc around, but I'm having trouble getting an input( command to not erase everything I real( ed on the screen. Is there a way to do that?

Screenie


So I want to know if there is a way to keep the dice on the screen when you're inputting the number. Thanks for all help in advance! Smile
Are you not able to StorePic before the input and RecallPic afterwards? Another option would be to write your own custom Input routine using getKey; since you're just accepting digits and positive integers (right?), it should be relatively straightforward.
Do you mean at the same time or do you need to store the dices, then input and then display the dices again?

If it is the first, you need to do a custom Input routine. Look at Ti-Basic developer, they have pretty nice solutions.
If you need to display the dices later, this is pretty easy:
:Input "whatever you need", somevar:DispGraph
and you get your dices back.
Botboy3000 wrote:
I was on a long car trip so naturally I brought one of my calculators and computer. I was bored of Minecraft so I remembered a game my friend showed me called Petals Around the Rose. Not really a game.... more of a puzzle. Riddle type thing.

So the puzzle/riddle/game is that the one person knows the rule and anyone else playning doesn't. The people that don't know the rule take turns rolling dice and guess values according to what they think the rule is. Then the person who knows the rule says the actual value. The first to figure out the rule wins.

But on my calc version, I suppose you could pass the calc around, but I'm having trouble getting an input( command to not erase everything I real( ed on the screen. Is there a way to do that?

Screenie


So I want to know if there is a way to keep the dice on the screen when you're inputting the number. Thanks for all help in advance! Smile

Well there is always the getkey loop with a numpad reader like this:

Code:
Repeat Ans>71 and min(Ans≠{45,75,81,85
getKey
End
sub("789  456  123  0.",Ans-36-5int(.1Ans),1

That's what I used to input stuff without leaving half-res mode on the CSE, I believe the same trick would work on the monochrome calcs Smile
mr womp womp wrote:


Code:
Repeat Ans>71 and min(Ans≠{45,75,81,85
getKey
End
sub("789  456  123  0.",Ans-36-5int(.1Ans),1

That's what I used to input stuff without leaving half-res mode on the CSE, I believe the same trick would work on the monochrome calcs Smile


Where is the user inputted number after that?
Botboy3000 wrote:
mr womp womp wrote:


Code:
Repeat Ans>71 and min(Ans≠{45,75,81,85
getKey
End
sub("789  456  123  0.",Ans-36-5int(.1Ans),1

That's what I used to input stuff without leaving half-res mode on the CSE, I believe the same trick would work on the monochrome calcs Smile


Where is the user inputted number after that?

In Ans of course...
I just had an idea:
You can display your dices at the top half of the graphscreen.
Then do

Code:

:StorePic 1
:Horiz
:RecallPic 1
:Input    //whatever would stand here


And here you go, both at the same time on screen. To exit this mode to normal do ":Full" and its back.
mr womp womp: Oh, Razz I'm stupid. It was the last command in that thing. So you could toss a ->variable on the end of that and it would work. But it doesn't look like that code displays anything while it's inputting. Would it be better to use an arrow-key inputting method to let the user see what they're inputting? I think yours is still better though. I'll try it and see what happens.

EDIT:: So this code you gave me only does 1 digit... I can only enter 0-9 when I need to be able to answer two digit numbers. Does what I'm describing sound right?

Nik: Does the real( command do what it does on the graphscreen? I thought it did what it does wherever you were at the moment. Because I can use the real( command and Output( at the same time and it still works. That would mean that I am in the homescreen. Maybe Kerm knows more on this. Actually... Kerm knows more about this. Smile
Botboy3000 wrote:
mr womp womp: Oh, Razz I'm stupid. It was the last command in that thing. So you could toss a ->variable on the end of that and it would work. But it doesn't look like that code displays anything while it's inputting. Would it be better to use an arrow-key inputting method to let the user see what they're inputting? I think yours is still better though. I'll try it and see what happens.

EDIT:: So this code you gave me only does 1 digit... I can only enter 0-9 when I need to be able to answer two digit numbers. Does what I'm describing sound right?

Nik: Does the real( command do what it does on the graphscreen? I thought it did what it does wherever you were at the moment. Because I can use the real( command and Output( at the same time and it still works. That would mean that I am in the homescreen. Maybe Kerm knows more on this. Actually... Kerm knows more about this. Smile



Code:
DelVar K
" ->Str1
While K!=105
Repeat K>71 and min(K!={75,81,85,91,95,103,104
getKey->K
End
Str1+sub("789  456  123  0   ",Ans-36-5int(.1Ans),1->Str1
Output(1,1,Ans
End
sub(Str1,2,length(Str1)-2
expr(Ans->A

There you go m8, stores it to A, you press enter when you're finished entering your number Smile
Quote:

Code:

DelVar K
" ->Str1
While K!=105
Repeat K>71 and min(K!={75,81,85,91,95,103,104
getKey->K
End
Str1+sub("789  456  123  0   ",Ans-36-5int(.1Ans),1->Str1
Output(1,1,Ans
End
sub(Str1,2,length(Str1)-2
expr(Ans->A


There you go m8, stores it to A, you press enter when you're finished entering your number Smile


Thanks so much. I'll make sure to give you credit in the archives page for this. Very Happy

EDIT:: Here's the code in case lirtosiast (or anyone Razz) sees anything that can be optimized. I'll look too:


Code:
real(1,12,10,9,24,1,0,40,0,0,1
Output(6,5,"[ENTER]"
Pause
ClrHome
0->K
While K!=45
real(0,1
real(1,12,56,3,8,1,0,32,0,0,0
real(1,61,56,3,8,1,3,32,0,0,1

0->T
For(I,1,5,1
randInt(0,5)->A
real(1,17(I-1)+5,30,2,16,1,2A,16randInt(0,1),0,0,1
[[[TOP SECRET ANSWER TO THE RIDDLE HAS BEEN REMOVED]]]
End

Output(1,2,"ENTER TO ROLL"
Repeat Ans
getKey->K
End
If K=12:Then
real(0,1
Output(1,1,"THE NAME OF THE"
Output(2,1,"GAME IS THE KEY"
Output(3,1,"TO THE GAME, THE"
Output(4,1,"KEY TO THE GAME"
Output(5,1,"IS THE NAME OF"
Output(6,1,"THE GAME, AND"
Output(7,1,"THE NAME OF THE"
Output(8,1,"GAME IS PETALS"
Pause
ClrHome
Output(1,1,"AROUND THE ROSE."
Pause
End
If K=14:Then
Output(1,1,"                "
DelVar K
" ->Str1
While K!=105
Repeat K>71 and min(K!={75,81,85,91,103,104
getKey->K
End
Str1+sub("789  456  123  0   ",Ans-36-5int(.1Ans),1->Str1
Output(1,1,Ans
End
sub(Str1,2,length(Str1)-2
expr(Ans->U
If T=U:Then
Output(2,5,"CORRECT!"
Else
Output(2,4,"INCORRECT"
Output(3,8,T
End
Pause
ClrHome
End
End
Botboy3000 wrote:
Quote:

Code:

DelVar K
" ->Str1
While K!=105
Repeat K>71 and min(K!={75,81,85,91,95,103,104
getKey->K
End
Str1+sub("789  456  123  0   ",Ans-36-5int(.1Ans),1->Str1
Output(1,1,Ans
End
sub(Str1,2,length(Str1)-2
expr(Ans->A


There you go m8, stores it to A, you press enter when you're finished entering your number Smile


Thanks so much. I'll make sure to give you credit in the archives page for this. Very Happy

EDIT:: Here's the code in case lirtosiast (or anyone Razz) sees anything that can be optimized. I'll look too:


Code:
real(1,12,10,9,24,1,0,40,0,0,1
Output(6,5,"[ENTER]"
Pause
ClrHome
0->K
While K!=45
real(0,1
real(1,12,56,3,8,1,0,32,0,0,0
real(1,61,56,3,8,1,3,32,0,0,1

0->T
For(I,1,5,1
randInt(0,5)->A
real(1,17(I-1)+5,30,2,16,1,2A,16randInt(0,1),0,0,1
[[[TOP SECRET ANSWER TO THE RIDDLE HAS BEEN REMOVED]]]
End

Output(1,2,"ENTER TO ROLL"
Repeat Ans
getKey->K
End
If K=12:Then
real(0,1
Output(1,1,"THE NAME OF THE"
Output(2,1,"GAME IS THE KEY"
Output(3,1,"TO THE GAME, THE"
Output(4,1,"KEY TO THE GAME"
Output(5,1,"IS THE NAME OF"
Output(6,1,"THE GAME, AND"
Output(7,1,"THE NAME OF THE"
Output(8,1,"GAME IS PETALS"
Pause
ClrHome
Output(1,1,"AROUND THE ROSE."
Pause
End
If K=14:Then
Output(1,1,"                "
DelVar K
" ->Str1
While K!=105
Repeat K>71 and min(K!={75,81,85,91,103,104
getKey->K
End
Str1+sub("789  456  123  0   ",Ans-36-5int(.1Ans),1->Str1
Output(1,1,Ans
End
sub(Str1,2,length(Str1)-2
expr(Ans->U
If T=U:Then
Output(2,5,"CORRECT!"
Else
Output(2,4,"INCORRECT"
Output(3,8,T
End
Pause
ClrHome
End
End





Code:
For(I,1,5,1
randInt(0,5)->A
real(1,17(I-1)+5,30,2,16,1,2A,16randInt(0,1),0,0,1
[[[TOP SECRET ANSWER TO THE RIDDLE HAS BEEN REMOVED]]]
End

Well, in a for( loop, if the increment is 1, you don't need to put it, and since you're only using A for this loop, you could remove "A" all together from the program, making your program overwrite 1 less var (I value that Razz), and slightly (unrecognizably) faster. Here is the code once these tiny modifications have been made...

Code:
For(I,1,5
real(1,17I-12,30,2,16,1,2randInt(0,5),16randInt(0,1),0,0,1
[[[TOP SECRET ANSWER TO THE RIDDLE HAS BEEN REMOVED]]]
End


Code:
expr(Ans->U
If T=U:Then

Here, you could get rid of the U variable as well...

Code:
If T=expr(Ans:Then
Those are good optimizations. I won't use the first one because the top secret answer needs A.

But the second one. definitely will use.
That part with those many output commands...
Well, Output( Wraps text to a new line if it is too long to fit in one, so you only need to add enough spaces to make words wrap correctly and put it I an single line with a single "Output(1,1," command.
At the end that T=U if-statement to display if it is correct or incorrect becomes:

Code:

:"CORRECT!
:If T=U   //Edit: First, this is the completely wrong way. Do T!=U, I just mixed that up, haha.
:"IN"+Ans
:Output(2,5-(T=U),Ans  //Same edit as above: Put ":If T=U:Output(3,8,T" here, this will still save space and time I guess...


Thats all I see after the first scanning of your program.
I like where you went with that. I certainly wouldn't have thought of it, but when your answer is incorrect I made it display the correct answer and using this optimization you would end up using more code to get that to work.

As for the zillions of outputs.... I didn't know that the text wrapped. Thanks Smile
Ok, now the whole optimized chunk in all:

Code:
(T=expr(sub(Str1,2,length(Str1)-2->U
//This is caching whether the result is correct in U creating a flag: either 1 (true) or 0 (false)
"CORRECT!
//The string to display (correct or incorrect) is combined to save some bytes from the word "CORRECT"
If not(U
"IN"+Ans
//If the answer is false add "IN" to "CORRECT"
Output(2,4+U,Ans
//Output the now combined String and center it. The "4+U" is for centering it correctly
If not (U
Output(3,8,T
//If the answer is incorrect output the correct answer

56 bytes vs 65 bytes, mine wins! Razz
But well, in my first version I mixed quite a bit up...
If you really want to try that hard, you could go as far as the custom input routine to prevent having to strip the string... however, I think this is pretty extreme considering you only save a few bytes... Anyway, your's is 61 bytes since the Enters count as bytes Wink mine is 50, counting the Enters... SOOOOOO I WIN!! Razz (the custom input routine that I modified didn't change in size, but it would need to be modified for my new code to work Razz)

Code:
"0->Str1
While K!=105
Repeat K>71 and min(K!={75,81,85,91,103,104
getKey->K
End
Str1+sub("789  456  123  0  .",Ans-36-5int(.1Ans),1->Str1
Output(1,1,Ans
End
(T=expr(Str1->U
"CORRECT!
If not(U
"IN"+Ans
Output(2,4+U,Ans
If not (U
Output(3,8,T
  
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 GMT - 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