ink
ink copied to clipboard
Succinct non repetitive shuffle
Sounds like a cool new dance hunh.
More seriously, I understand about shuffle as randomization of a list. I understand about choices being trackable as having been chosen so they do not appear again. My issue is I would like to have a long list of variable barks via shuffle. I would like a given bark to be chosen only once. Then once the list of barks is exhausted I reset. Is there a succinct way to 'pick only once' from a shuffle?
Please advise. Thank you.
Something like this...?
-> loop
== loop ==
You're in the loop.
<- random_choice
== random_choice ==
{shuffle:
- + one[] -> loop
- + two[] -> loop
- + three[] -> loop
- + four[] -> loop
- + five[] -> loop
- + six[] -> loop
}
Thanks for taking to reply! Let me mull.
Is there a way to, in the above programming, set random_choice to unseen (or 0 or false or whatever) to make the program think that it has never been visited by the player?
We did some testing of the loop above (thanks!) and it seems to repeat rather then shuffle and only say a given line once. So this appears to be a shuffle but not a non repeating shuffle. Am I confused?
Here's what I got from running it in Quill (http://jeejah.xyz/quill/). Did you forget the "shuffle" keyword..?
You're in the loop.
three
You're in the loop.
one
You're in the loop.
two
You're in the loop.
four
You're in the loop.
five
You're in the loop.
one
You're in the loop.
two
You're in the loop.
three
You're in the loop.
four
You're in the loop.
five
You're in the loop.
On Wed, Oct 19, 2016 at 7:39 PM lhughes41 [email protected] wrote:
We did some testing of the loop above (thanks!) and it seems to repeat rather then shuffle and only say a given line once. So this appears to be a shuffle but not a non repeating shuffle. Am I confused?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/inkle/ink/issues/213#issuecomment-254903071, or mute the thread https://github.com/notifications/unsubscribe-auth/AA40o4K9gqfcg-boRsghq13DwyKVfTegks5q1mPVgaJpZM4KZVWe .
I am being unclear. We get random pick but once a pick occurs we never want to see that pick again. The above repeats choices.
So we want random order but no repeats
Right. So I sometimes a pattern like:
-> loop
== loop ==
You're in the loop.
<- random_choice
== random_choice ==
~ temp sanity = 0
-(top)
{ sanity > 20:
Run out of options. -> END
}
{shuffle:
- {-> one|}
- {-> two|}
- {-> three|}
...
}
~ sanity++
-> top
= one
* one -> loop
= two
* two -> loop
= three
* three -> loop
That's looks right ( just tested). Let me confirm with my more knowledgeable Ink writers (I am a mere coder) but thanks!
The further question we had btw is whether there is a way to 'refresh.' That is have it forget the choice it has made (they are integers so resetting to them to zero? Can one say things like "three = 0"?) (I know this can be done with declared vars).
Nope, sorry!
... but you could adapt the above pattern to allow for a reset by adding more variables / logic to the branches of the shuffle. The copy/paste gets a bit more tedious but it's doable.
Cheers Jon On Thu, 20 Oct 2016 at 9:42 am, Joseph Humfrey [email protected] wrote:
Nope, sorry!
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/inkle/ink/issues/213#issuecomment-255045055, or mute the thread https://github.com/notifications/unsubscribe-auth/AA40o6VRAAc_t7mM07O3Ld43im_hyy0_ks5q1ylggaJpZM4KZVWe .
Late to the party, but in case someone else comes here looking for the same thing, I've come up with another pattern, using lists. (because you cannot reset diverts, but you can reset lists !)
I needed a thing similar to @lhughes41 : a conversation with follow ups presented in random order that are reset when a new conversation begin (because it can occurs multiple time).
LIST FollowUps = FolKids, FolPets, FolWeather //, FolChess, FolSport
-> begin
=== begin ===
~ FollowUps = LIST_ALL(FollowUps)
-> conversation_hub
=== conversation_hub ===
{LIST_COUNT(FollowUps) == 0 :
You have nothing more to talk about
-> conversation_end
}
{LIST_COUNT(LIST_INVERT(FollowUps)) >= 2:
You have talked enough
-> conversation_end
}
Topics remaining : {FollowUps}
~ temp chosen = LIST_RANDOM(FollowUps)
~ FollowUps -= chosen
{chosen:
- FolKids :
-> fol_kids ->
- FolPets :
-> fol_pets ->
- FolWeather :
-> fol_weather ->
}
-> conversation_hub
=== fol_kids ===
Oh, so you have kids ?
+ Yes
Wonderful ->->
+ No
So sad ! ->->
=== fol_pets ===
Oh, so you have pets ?
+ Yes
Aren't you allergic ? ->->
+ No
Don't you get lonely ->->
=== fol_weather ===
Nice weather today, isn't it ?
+ Yes
But maybe too hot ->->
+ No
You don't like the sun ->->
=== conversation_end ===
+ [I'm done] -> END
+ [Let's talk again] ->begin
I also use {LIST_COUNT(LIST_INVERT(FollowUps))}
to count the number of topic covered in the current conversation (so I can limit) and have some more logic in the begin
to govern the reset process.
~~A question to @joethephish maybe : I know you can store a divert in a VAR
but can you make a LIST
of diverts ?~~