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

#1 2012-09-17 20:39:47

Danieltatis
New Scratcher
Registered: 2012-09-17
Posts: 2

Hi! Need a random chooser!

Hi everyone, this is my first post, so i want to say thanks to MIT and YOU, Reader, for this!

Well, i need the following. I am writing a code for a "parody" of WWTBAM (Who Wants to be a Millionaire), and i can't do the 50/50 Lifeline...

I need a code that takes four numbers (answers) and chooses two of them to dissapear (they can't be the correct answer, which i added as a TruthFactor variable). So, i need the computer to choose two of 1-2-3-4 numbers, NEVER choosing the TruthFactor.

Thanks for your help,

Danieltatis (Daniel Charry)

Offline

 

#2 2012-09-17 21:53:45

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Hi! Need a random chooser!

repeat until <not < (myPick) = (TruthFactor) >>
  set [myPick v] to (pick random (1) to (4) )
end
repeat until <not < (myOtherPick) = (TruthFactor) >>
  set [myOtherPick v] to (pick random (1) to (4) )
end
You'll need to fix the second repeat to also reject where myPick = myOtherPick. I'd show that but the scratch blocks code doesn't work.

Last edited by BoltBait (2012-09-17 22:01:12)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#3 2012-09-17 21:56:14

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Hi! Need a random chooser!

Danieltatis wrote:

Hi everyone, this is my first post, so i want to say thanks to MIT and YOU, Reader, for this!

Well, i need the following. I am writing a code for a "parody" of WWTBAM (Who Wants to be a Millionaire), and i can't do the 50/50 Lifeline...

I need a code that takes four numbers (answers) and chooses two of them to dissapear (they can't be the correct answer, which i added as a TruthFactor variable). So, i need the computer to choose two of 1-2-3-4 numbers, NEVER choosing the TruthFactor.

Thanks for your help,

Danieltatis (Daniel Charry)

Well instead of storing the correct answer in a variable, store the wrong answers in the variable like this: Answer 2 is correct.  Variable = 134; Answer 4 is correct.  Variable = 123

etc.

Then use this:

set [wrong1 v] to (letter (pick random (1) to (3) ) of (Variable))
set [wrong2 v] to (letter (pick random (1) to (3) ) of (Variable))
repeat until <not <(wrong1) = (wrong2)>>
set [wrong1 v] to (letter (pick random (1) to (3) ) of (Variable))
end
Then delete the choices wrong1 and wrong2.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2012-09-18 08:19:08

TPAL125
Scratcher
Registered: 2012-06-09
Posts: 18

Re: Hi! Need a random chooser!

Put your answers (1 to 4) in a list, then delete the correct answer. Pick two random items from the list and delete them as well. Take the correct answer and the one left in the list and those are your two answers.

Offline

 

#5 2012-09-18 18:01:22

Danieltatis
New Scratcher
Registered: 2012-09-17
Posts: 2

Re: Hi! Need a random chooser!

Thanks everyone for helping me!  smile

Danieltatis

Offline

 

Board footer