having troubles :/
Author |
Message |
jamesbragg3
|
Posted: Wed Jun 17, 2015 11:40 pm Post subject: having troubles :/ |
|
|
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
What is the problem you are having?
I am trying to add a percentage to a randomize code.. i am using the "randint" code to pick a random number between 2 and 12 but id like it to be a bit more predictable like a dice if you will... i would very much like some help please and thanks.
Describe what you have tried to solve this problem
i have tried to add the percentage to the number but when doing so the entire code just stops
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
var hidden: int
var reply : string (1)
put"do you wish to roll the dice?"
put "7 or 11 is a win, 2,3, and 12 are loses"
put "everything else is a free roll"
loop
put"do you wish to play? Enter y or n " ..
get reply
exit when reply = "n"
% Chooses a random number for dice roll
put " you rolled dice"
randint (hidden, 2, 12)
cls
%makes turing tell you if you win
if hidden = 7 then
put"the dice landed on ", hidden, " you win!"
elsif hidden = 11 then
put "the dice landed on ", hidden, " you win!"
%makes turing tell you if you lose
elsif hidden = 2 then
put "the dice landed on ", hidden, " you lose"
elsif hidden = 3 then
put "the dice landed on ", hidden, " you lose"
elsif hidden = 12 then
put "the dice landed on ", hidden, " you lose"
%makes turing tell you to try again
else put "the dice landed on ", hidden, " try again"
end if
end loop
|
Please specify what version of Turing you are using
I am using Turing 4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DemonWasp
|
Posted: Thu Jun 18, 2015 8:20 am Post subject: RE:having troubles :/ |
|
|
Dice are essentially unpredictable. I assume by "id like it to be a bit more predictable like a dice", you mean "I would like it to have the same probability distribution as rolling two 6-sided dice".
If that's the case, then...make your program do that. Hint: you can call randint as many times as you need to. |
|
|
|
|
|
|
|