Skip to content

Instantly share code, notes, and snippets.

@joningold
Created September 25, 2018 18:38
Show Gist options
  • Save joningold/e0fce93d83a562798e4dd9c75f49d61f to your computer and use it in GitHub Desktop.
Save joningold/e0fce93d83a562798e4dd9c75f49d61f to your computer and use it in GitHub Desktop.
Shuffled choices example
LIST PossibleFruits = Apple, Banana, Satsuma, Melon, Pear
- (anotherquiz)
One fruit in the fruit-bowl is fake. Can you guess which one?
~ temp correctAnswer = LIST_RANDOM(LIST_ALL(PossibleFruits))
- (anothergo)
~ temp timesLooped = 0
- (loop)
~ temp opt = LIST_RANDOM(LIST_ALL(PossibleFruits))
{ offer_answer(opt):
+ Answer {opt}
{ opt == correctAnswer:
Correct!
-> anotherquiz
- else:
No, try again....
}
-> anothergo
}
{ timesLooped < 10 && CHOICE_COUNT() < 3:
~ timesLooped ++
-> loop
}
+ Give up!
The answer was {correctAnswer}.
- -> anotherquiz
==== function offer_answer(answerKey)
VAR answersOffered = ()
{ not came_from(-> note_answer):
~ answersOffered = ()
}
{ answersOffered ? answerKey:
~ return false
}
~ return note_answer(answerKey)
=== function note_answer(answerKey)
~ answersOffered += answerKey
~ return true
=== function came_from(-> target)
// has the flow been through "target" this turn already?
~ return (TURNS_SINCE(target) == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment