Discuss Scratch

KreepyKreeper01
Scratcher
4 posts

How do I make a random question generator that can choose between multiple questions

I tried doing ‘pick random number 1-30’ for each question so it will randomly choose a question, but that seems to sometimes make it so either nothing shows up or multiple show up, any help?


Alright, that works amazingly, now I just need to figure out how to sense which question was picked so I can have the appropriate answer for that question, otherwise the answers could just be used over and over again.

Last edited by KreepyKreeper01 (April 30, 2016 15:17:37)

footsocktoe
Scratcher
1000+ posts

How do I make a random question generator that can choose between multiple questions

KreepyKreeper01 wrote:

I tried doing ‘pick random number 1-30’ for each question so it will randomly choose a question, but that seems to sometimes make it so either nothing shows up or multiple show up, any help?

If the questions are in a list variable then there should be no problem. (30 questions = 30 items in list) Is that the way you are doing it?

(item (pick random (1) to (30)) of [ list of 30 questions v])
Falconmist
Scratcher
100+ posts

How do I make a random question generator that can choose between multiple questions

You can, like was said before, use these blocks:
when green flag clicked
ask (item (pick random (0) to (10)) of [ v]) and wait
Or, you can replace the
when green flag clicked
with whatever black you need.

Last edited by Falconmist (April 30, 2016 07:29:52)

Scratch-Minion
Scratcher
1000+ posts

How do I make a random question generator that can choose between multiple questions

If you don't want questions repeated, put the numbers 1 to 30 in a list, then shuffle the list randomly.
Then take the numbers out of the list as needed.

If you need a random shuffle algorithm for the 30 numbers, see “Randomly Shuffle a List” by jgatcomb at https://scratch.mit.edu/projects/11888022/
KreepyKreeper01
Scratcher
4 posts

How do I make a random question generator that can choose between multiple questions

footsocktoe wrote:

KreepyKreeper01 wrote:

I tried doing ‘pick random number 1-30’ for each question so it will randomly choose a question, but that seems to sometimes make it so either nothing shows up or multiple show up, any help?

If the questions are in a list variable then there should be no problem. (30 questions = 30 items in list) Is that the way you are doing it?

(item (pick random (1) to (30)) of [ list of 30 questions v])
I've been doing it by making a
if <(pick random (1) to (30)) = [7]> then
ask [stuff] and wait

end
for each one, but each individual one was choosing its own number and that was the problem, I needed one that it chose one number and that number would correspond to a question that the game would ask
footsocktoe
Scratcher
1000+ posts

How do I make a random question generator that can choose between multiple questions

KreepyKreeper01 wrote:

footsocktoe wrote:

KreepyKreeper01 wrote:

I tried doing ‘pick random number 1-30’ for each question so it will randomly choose a question, but that seems to sometimes make it so either nothing shows up or multiple show up, any help?

If the questions are in a list variable then there should be no problem. (30 questions = 30 items in list) Is that the way you are doing it?

(item (pick random (1) to (30)) of [ list of 30 questions v])
I've been doing it by making a
if <(pick random (1) to (30)) = [7]> then
ask [stuff] and wait

end
for each one, but each individual one was choosing its own number and that was the problem, I needed one that it chose one number and that number would correspond to a question that the game would ask

So it's resolved now? Or you still have a question?
KreepyKreeper01
Scratcher
4 posts

How do I make a random question generator that can choose between multiple questions

footsocktoe wrote:

KreepyKreeper01 wrote:

footsocktoe wrote:

KreepyKreeper01 wrote:

I tried doing ‘pick random number 1-30’ for each question so it will randomly choose a question, but that seems to sometimes make it so either nothing shows up or multiple show up, any help?

If the questions are in a list variable then there should be no problem. (30 questions = 30 items in list) Is that the way you are doing it?

(item (pick random (1) to (30)) of [ list of 30 questions v])
I've been doing it by making a
if <(pick random (1) to (30)) = [7]> then
ask [stuff] and wait

end
for each one, but each individual one was choosing its own number and that was the problem, I needed one that it chose one number and that number would correspond to a question that the game would ask

So it's resolved now? Or you still have a question?
yeah, its all good.
asivi
Scratcher
1000+ posts

How do I make a random question generator that can choose between multiple questions

KreepyKreeper01 wrote:

yeah, its all good.
Fine, so you might to close this topic and prevent users spamming like this of mine.


Levo-Films
Scratcher
100+ posts

How do I make a random question generator that can choose between multiple questions

If you don't like FootSockToe's method, you could make this (But it is longer)
when green flag clicked
set [ number] to [(pick random (1) to (10)) ]
if <(number) = [1 ]> then
ask [Is Levo Awesome?] and wait

end
asivi
Scratcher
1000+ posts

How do I make a random question generator that can choose between multiple questions

Levo-Films wrote:

If you don't like FootSockToe's method, you could make this (But it is longer)
when green flag clicked
set [ number] to [(pick random (1) to (10)) ]
if <(number) = [1 ]> then
ask [Is Levo Awesome?] and wait

end
Do you see it?
This was my advice:

asivi wrote:

KreepyKreeper01 wrote:

yeah, its all good.
Fine, so you might to close this topic and prevent users spamming like this of mine.



Pls, close this topic when you can.

Powered by DjangoBB