studio
studio copied to clipboard
Random option will never pick last option on Lunii
Describe the bug I wrote a story with a couple of random paths. While this works fine when previewing the story in STUdio, I only get the first option all of the time on the Lunii. I've tried the two ways to implement that (with a menu node and with an action node) but I have the same issue.
To Reproduce
- Create a simple story with a menu node with two random options.
- Deploy to Lunii and try it
Expected behavior 50% of the time you should get option A and 50% of the time option B.
Actual behavior You only get 100% A across multiple plays.
Update 2020-11-20: it turns out that the random feature works partially but it will never pick the last option on the Lunii.
@pozil Thanks for the feedback ! I've not used this feature that much, I'll need to have a look now that I downgraded my device. When you say you always get the same option, does it mean your story pack gets through that node multiple times, or do you need to exit and reopen your pack? I don't know how the Lunii implements the randomness, but it could be that it is somewhat predictable and always "randomizes" the same way every time you run a story pack.
I've tried several things including turning off the Lunii in between plays but that doesn't work, it always runs the first node. Looking at your source code, I can't see where the random flag is persisted in the story pack's metadata. I worry that this "random" feature only exists in the web player. Can you check?
@pozil The random option is persisted here as -1
, which, to the best of my understanding, the Lunii plays as a random(-ish) option. However it's possible that the randomness is not that random, or uses a fixed seed. Have you tried to make multiple random choices on a single story? What if you run your story pack after playing another one?
Sorry, I thought that you were serializing the story pack in Java. I was looking at BinaryStoryPackWriter.java and ActionNode.java and couldn't find references to a "random" flag.
I tried the two test scenarii you suggested:
- multiple random choices within a story
- playing other stories in between my story tests
No luck so far. It could be a random seed problem as you suggested but what I find surprising is that it's always the first option that gets played.
Thanks for helping.
@pozil I'll need to try this. Can you share the story.json
file of your test packs?
The editor creates the "archive" story pack and uploads it to the library. When you transfer from the library to the device, the pack is read in-memory (ArchiveStoryPackReader), assets are uncompressed (if needed), and the story pack is written in binary format using BinaryStoryPackWriter. You can see this mechanics here and here.
Here's a test story with two tests: one with expert nodes followed by one with a question node: Test_aléatoire-9cb21abf-5c97-417f-8437-f19df625aaf4-v1.zip
Thanks for the explanations, I'll take a closer look at the code.
You'll see that you'll get a "1" displayed on the Lunii screen when it picks the first option (all of the time) or a "2" if it picks the second option (I've never seen it so far).
@pozil You story pack looks good to me, although I cannot test on the device right now. I'm wondering, did you try with more than two options?
Great idea @marian-m12l, I ran a lot of tests on the Lunii with 4 options and I found out that it never picks the last option. In my original test I had only options so it would only pick the first one. Now that I have 4, it will randomly pick 1,2,3 but never 4.
Could this be a bug on the Lunii firmware?
@pozil Good to know. I'd say it looks like a n
/n-1
bug in the Lunii firmware, indeed.
Hello,
I can confirm. I encounter the same bug as @pozil .
With a diagram like this one, you should get 50% of the time option 1 and 50% option 2. But you get 100% of the time option 1. If you try with more options, you notice that actually the Lunii never picks the last option.
@ex23 @pozil Thanks. Which versions of the lunii are you using? If the behaviour is consistent across devices, I could implement a workaround.
Thanks for looking into this. Mine is a lunii 1.
@pozil Thanks. I don't have a way to check the behaviour on the new device. though.
Hello. For me it's a Lunii 2. Thank you @marian-m12l for looking at this problem.
@ex23 Thanks.
Unfortunately now that I think of it I'm not sure this can be worked around. Adding a "dummy" n+1 option would allow the randomization algorithm to pick the nth option, but then this would break the navigation through all options with the wheel button...
I agree @marian-m12l and I think that it's not a critical issue. We should probably keep the issue open so that others don't waste too much time on this.
As a workaround, I ended up asking the user to roll a dice and select the result with wheel.
@pozil Indeed this is not critical, and I'll leave the issue open.
OK, I agree it's not critical. It's just annoying in some specific situations. But with a little bit of creativity you can live with it.
It looks indeed like a bug in the Lunii firmware itself.
Maybe adding a empty option at the end of the list but going to a short silent track, then after one second autoplay return to the node to select another random track.
French for better search engine results : La dernière option d'un nœud en mode aléatoire n'est pas sélectionnée, possibilités de solutions ajouter une option factice à la fin de la liste, pointant sur une piste de silence d'une seconde, puis un autoplay permettant de retourner au menu.
marian-m12l https://github.com/marian-m12l/studio/issues/142#issuecomment-789678657