Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: FLASH: Random Questions Without Repeating
From: Damien Morton
Date: Tue, 25 Jul 2000 23:45:00 +0100

The trick is to use a string as a list, with each character in the string
representing one question, and removing that character from the string after
the question is asked. By picking a character position at random, and then
removing the charactre from that position, you are assured of never
repeating the same question twice.


question_A = "what is the flight velocity of a sparrow?"
question_B = "what is the areal size of equador?"
question_C = "what is your favorite colour?"
...
question_Z = "is this the last question?"
questions = "ABCD...Z"

loop while (length(questions) > 0)
// pick a random position in the list
r = random(length(questions))+1
// figure out which question code is represented at that position in the
list/string
q = substring(questions, r, 1)
// get the question string corresponding to the question code
current_question = eval("question_" & q)
// do the asking thing
call "ask_the_question"
// remove the question from the list/string of available questions
questions = substring(questions, 1, r-1) & substring(questions, r+1, 999)


If you have a lot of questions, ie. more than there are chracters and
numbers, then you can use pairs or triples of characters in a string. The
math for this is a little more tricky - let me have a go at it....

question_001 = "what is the flight velocity of a sparrow?"
question_002 = "what is the areal size of equador?"
question_003 = "what is your favorite colour?"
...
question_999 = "is this the last question?"
questions = "001002003004005...997998999"

loop while (length(questions) > 0)
// pick a random position in the list - note: each group of 3 characters is
one position
r = (random(length(questions)/3)*3)+1
// figure out which question code is represented at that position in the
list/string
q = substring(questions, r, 1)
// get the question string corresponding to the question code
current_question = eval("question_" & q)
// do the asking thing
call "ask_the_question"
// remove the question from the list/string of available questions
questions = substring(questions, 1, r-1) & substring(questions, r+3, 999)



> -----Original Message-----
> From: owneratchinwag [dot] com [owneratchinwag [dot] com]On">mailto:owneratchinwag [dot] com]On Behalf Of Paul
> Steven
> Sent: Tuesday, July 25, 2000 2:39 PM
> To: flasheratchinwag [dot] com
> Subject: FLASH: Random Questions Without Repeating
>
>
> Hi all
>
> I am making a quiz where there are 30 questions. I want to
> randomly choose a
> question and ask it then remove it from the question pool. I normally have
> no problem doing this sort of stuff in Director - I simply create
> a list of
> the question numbers and remove the question number from the list after
> asking the question - but I can't figure out how do do it in Flash - am I
> being really dumb?! The only way I can think of is have 30 variables i.e
> Question1_Asked=False, Question2_Asked=False etc and set the
> boolean to True
> if asked.
>
> Anyone suggest a better way please.
>
> Thanks In Advance
>
> Paul
>
>
> flasher is generously supported by...
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> flashforward2000 and the Flash(tm) Film Festival
> July 24-26, 2000, NEW YORK CITY, Hammerstein Ballroom
> www.flashforward2000.com
> Produced by United Digital Artists and lynda.com
> Sponsored by Macromedia, Adobe Systems, Fusion, Inc, AtomFilms,
> shockwave.com and Electric Rain.
> 1.877.4.FLASH.4 or (1.805.640.6679 outside the US and Canada)
> Register before June 30 and save $200!!-- www.flashforward2000.com
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> To unsubscribe or change your list settings go to
> http://www.chinwag.com/flasher or email helpatchinwag [dot] com
>


flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and the Flash(tm) Film Festival
July 24-26, 2000, NEW YORK CITY, Hammerstein Ballroom
www.flashforward2000.com
Produced by United Digital Artists and lynda.com
Sponsored by Macromedia, Adobe Systems, Fusion, Inc, AtomFilms,
shockwave.com and Electric Rain.
1.877.4.FLASH.4 or (1.805.640.6679 outside the US and Canada)
Register before June 30 and save $200!!-- www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


Replies
  RE: FLASH: Random Questions Without Repe, Damien Morton

Replies
  FLASH: Random Questions Without Repeatin, Paul Steven

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]