Workaround to avoid repeat trivia questions in a table?

rabbigarfinkelrabbigarfinkel Member Posts: 39
edited January 2012 in Working with GS (Mac)
Hello,

I realize that in order to avoid repeat trivia questions, we would need writable tables. Having said that, has anyone thought of a workaround? ( I've been trying to mix TShirtBooth's trivia template and his video on "Random Numbers No Repeat" so that I would at least not have two repeats in a row, but I haven't figured that one out yet.) The ideal, of course, is to ask a question once and never again. Any idea would be appreciated.

Thanks (and kudos to TSB!)

Eli

Comments

  • JeffreyShimaneJeffreyShimane Member Posts: 372
    I would imagine something like this would work:

    1) Save the last question to an attribute (LastQuestion)

    2) Query the table for a random question.

    3) Compare the value of the new random question to LastQuestion. If they are the same, go back to step 2. If they are not the same, display the new random question.

    4) Repeat steps 1-3 until the game ends.

    Hope that helps.

    - Jeff
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879
    @rabbigarfinkel -- here is an example of how to generate random numbers w/o replacement. It does not use tables, but instead uses a text attribute as an array to hold old ("used") numbers. Perhaps it will give you an idea or two?
    http://www.mediafire.com/?j2vv9zv8joy1m4y

    Hope this helps!
    RThurman
  • rabbigarfinkelrabbigarfinkel Member Posts: 39
    Many thanks to all! Do we know how far down the road writable tables are? Are they weeks away or months away?

    Eli
  • ultimaultima Member, PRO Posts: 1,207
    probably month... but anyone who has any idea probably can't tell you under NDA =) unless the head chefs speaks up.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    I'd like to add to TSB's example. Say you have your selected row in a game attribute called game.SelectedQuestion
    To get another question that is not a repeat of the last question, you could just use a Change Attribute behavior to do:
    Change Attribute game.SelectedQuestion to ((game.SelectedQuestion-1+random(1,tableRowCount(yourTable)-1))%tableRowCount(yourTable))+1

    This should give you any other row from your table and also make sure that the selected number is not 0(since table rows and columns start at 1).
  • gamedivisiongamedivision Member Posts: 807
    It would be great to actually type the answer in without possible answers showing.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879
    edited January 2012
    @rabbigarfinkel said:
    The ideal, of course, is to ask a question once and never again. Any idea would be appreciated.
    I think I have a work around that uses tables and a text 'array'. The table holds the questions and answers, and the text attribute holds a list of 'used' questions. The idea is to randomly generate a new question number, then check if the question has already been asked. If yes, then randomly generate a new question number and check again. (And so on, until an unasked question gets identified.) When an unasked question is found, put it on the scene. So... it asks a question (at random) once and never asks it again.

    Here is a demo file:
    http://www.mediafire.com/?l61nenxflza2b1a

    The demo isn't pretty. But it is functional. (Its a demo, after all, and not a template.)

    This was interesting to figure out. Its my first foray into using a table in GS. Tables will help immensely when they are fully read/write capable.

    Hope this helps!
    RThurman
  • Fabri DamazioFabri Damazio Member Posts: 97
    I think RtThurman is right.

    Smething like:

    Pick a randon question
    Compare with all arrays positions
    If yes, back to begin and take another question
    If no, store question number in array and show question
Sign In or Register to comment.