Skip to content

Commit 960a850

Browse files
committed
Update RNG logic
Keep the PRNG object in the state instead of previousRandom. The shuffle logic is kept as is.
1 parent e2d9cae commit 960a850

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/engine/Story.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1189,15 +1189,15 @@ export class Story extends InkObject {
11891189
". The maximum must be larger"
11901190
);
11911191

1192-
let resultSeed = this.state.storySeed + this.state.previousRandom;
1192+
let resultSeed = this.state.previousRandom;
11931193
let random = new PRNG(resultSeed);
11941194

11951195
let nextRandom = random.next();
11961196
let chosenValue = (nextRandom % randomRange) + minInt.value;
11971197
this.state.PushEvaluationStack(new IntValue(chosenValue));
11981198

11991199
// Next random number (rather than keeping the Random object around)
1200-
this.state.previousRandom = nextRandom;
1200+
this.state.previousRandom = random.nextSeed();
12011201
break;
12021202
}
12031203

@@ -1349,7 +1349,7 @@ export class Story extends InkObject {
13491349
newList = new InkList();
13501350
} else {
13511351
// Generate a random index for the element to take
1352-
let resultSeed = this.state.storySeed + this.state.previousRandom;
1352+
let resultSeed = this.state.previousRandom;
13531353
let random = new PRNG(resultSeed);
13541354

13551355
let nextRandom = random.next();
@@ -1377,7 +1377,7 @@ export class Story extends InkObject {
13771377
newList = new InkList(randomItem.Key.originName, this);
13781378
newList.Add(randomItem.Key, randomItem.Value);
13791379

1380-
this.state.previousRandom = nextRandom;
1380+
this.state.previousRandom = random.nextSeed();
13811381
}
13821382

13831383
this.state.PushEvaluationStack(new ListValue(newList));

0 commit comments

Comments
 (0)