Skip to content

Commit

Permalink
Merge pull request #952 from y-lohse/fix/prng-magic-number
Browse files Browse the repository at this point in the history
Fix PRNG magic number (improved)
  • Loading branch information
smwhr authored May 7, 2022
2 parents 61b5263 + a846051 commit 4788893
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/engine/PRNG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class PRNG {
if (this.seed <= 0) this.seed += 2147483646;
}
public next(): number {
return (this.seed = (this.seed * 16807) % 2147483647);
return (this.seed = (this.seed * 48271) % 2147483647);
}
public nextFloat(): number {
return (this.next() - 1) / 2147483646;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/specs/inkjs/engine/Logic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe("Logic", () => {
it("should generate random numbers", () => {
context.story.ChoosePathString("logic.random");

expect(context.story.Continue()).toEqual("15\n");
expect(context.story.Continue()).toEqual("-24\n");
expect(context.story.Continue()).toEqual("27\n");
expect(context.story.Continue()).toEqual("8\n");
});
});

0 comments on commit 4788893

Please sign in to comment.