You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-> conversation_loop
=== conversation_loop
+ [Test Shuffle] -> test_shuffle
+ [Done] -> test_done
=== test_shuffle
{first()} and {second()}
-> conversation_loop
=== test_done
Bye :)
-> END
== function first ==
{~
- A
- B
- C
- D
- E
}
== function second ==
{~
- A
- B
- C
- D
- E
}
When playing this ink in inky or inklecrate you get the expected
A and E
B and C
...
Playing with inkjs you get
E and E
B and B
A and A
...
I traced this down to NextSequenceShuffleIndex()
For both shuffle lists this function gets called with exactly the same state/values, and so returns the same choice. This problem only occurs with lists of the same length, because the length is part of the random seed calculation (so don't use lists of the same length in the same place and you are fine).
I do not understand, why the c# implementation behaves differently. The code nearly looks the same. But I can't debug the c# code.
My problem could be fixed with something like
NextSequenceShuffleIndex(){
var numElementsIntVal = this.state.PopEvaluationStack();
if (!(numElementsIntVal instanceof IntValue)) {
this.Error("expected number of elements in sequence for shuffle index");
return 0;
}
var numElements = numElementsIntVal.value;
let min = 0
let max = Math.floor(numElements);
// exclusive MAX
let chosen= Math.floor(Math.random() * (max - min)) + min;
return chosen
}
which works fine for me, but because you are losing the seedable random number and the 'sequence' functionality, this isn't really a patch.
The text was updated successfully, but these errors were encountered:
We try to keep the C# and JS codebases as close as possible, so as you guessed we can't take that patch as it is :). I'll have to look at the C# code again, there's probably a minor difference somewhere.
I've fixed it! @y-lohse I see that by trying to update the ink.js files in the two templates I inadvertently introduced way more changes in my PR than expected, so let me know if that's a problem.
Hi,
was playing around with procedural text generation in ink (like https://www.patreon.com/posts/tips-and-tricks-18636280 or https://gist.github.com/joethephish/2b0a291806b3100390fdddd56defd169)
which is a lot of fun, but got a weird problem with inkjs and shuffle lists.
When playing this ink in inky or inklecrate you get the expected
A and E
B and C
...
Playing with inkjs you get
E and E
B and B
A and A
...
I traced this down to
NextSequenceShuffleIndex()
For both shuffle lists this function gets called with exactly the same state/values, and so returns the same choice. This problem only occurs with lists of the same length, because the length is part of the random seed calculation (so don't use lists of the same length in the same place and you are fine).
I do not understand, why the c# implementation behaves differently. The code nearly looks the same. But I can't debug the c# code.
My problem could be fixed with something like
which works fine for me, but because you are losing the seedable random number and the 'sequence' functionality, this isn't really a patch.
The text was updated successfully, but these errors were encountered: