This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-06 18:13:06

Garretisawesome
New Scratcher
Registered: 2013-02-06
Posts: 1

Need help with probability?

I am trying to make a probability game where a random card is chosen and you bet on which card it will be with a certain amount of money. I am trying to figure out how i make the script of when a bet is chosen, it chooses a random card. I'm thinking it would do something like broadcast something to a variable. I really dont know! HELP!!!

Offline

 

#2 2013-02-06 19:18:37

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: Need help with probability?

Try this. You will need to make 10 costumes. Each will show a number card. So, you could make a costume with a card with a 1 on it. Call it 1, and add a 1 at the end (11). Do this with each costume. (Costume 1: 11, Costume 2: 21, Costume 3: 31, etc.)

ask [what number do you think I'll draw?] and wait
set [choice v] to (answer)
ask [what's your bet for the number?] and wait
set [bet v] to (answer)
set [card v] to (pick random (1) to (10)
switch to costume (join (card)[1])
if <(choice) = (card)>
say [You were right! You get the amount you betted on!]
change [the player's points v] by (choice)
else
say [You were wrong. You lose the amount you betted on.]
change [the player's points v] by ((choice) * (-1))
end
wait (2) secs
say []
Hope this helps!


http://i48.tinypic.com/2072ctw.gif

Offline

 

Board footer