playMaker

Author Topic: Random String Assignment  (Read 1111 times)

DefKron

  • Playmaker Newbie
  • *
  • Posts: 3
Random String Assignment
« on: November 28, 2023, 12:14:45 AM »
Hi All!
I was hoping to get some more expert feedback on what I'm trying to accomplish.
I'm trying to set up a "quiz show" mechanic and I have a set of four answers to choose from on each question.
What's the most efficient way to set up an FSM that randomly assigns the set of four answers in a different/random order each time? (More specifically, four different UI buttons.)
For example, "Button A" might say "Red" but the next time you encounter this question "Button A" will have the choice of "Blue". (But ultimately, always the same four answers in each set.)
My brain immediately went to creating all 24 unique possible answer combinations as individual states, but I realize that can't be the most ideal way.
I know the answer has something to do with arrays but I can't figure out how to handle the "assign all four of these items randomly, with no duplicates" part.
Thank you in advance for any help!

Jbag

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Random String Assignment
« Reply #1 on: November 28, 2023, 11:58:34 AM »
'Array shuffle' action before assigning the values to each answer position would work I think.

DefKron

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Random String Assignment
« Reply #2 on: November 28, 2023, 10:01:49 PM »
Ah! I think this was the exact action I was hoping for! Thank you!