Skip to content

Commit

Permalink
Update zvm with new xorshift generator
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Jul 21, 2016
1 parent 71fc32c commit f458c45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Binary file modified lib/parchment-for-inform7.zip
Binary file not shown.
17 changes: 8 additions & 9 deletions lib/zvm.debug.js
Expand Up @@ -3,9 +3,9 @@
ZVM - the ifvms.js Z-Machine (versions 5 and 8)
===============================================
Built: 2015-09-06
Built: 2016-07-21
Copyright (c) 2011-2015 The ifvms.js team
Copyright (c) 2011-2016 The ifvms.js team
BSD licenced
http://github.com/curiousdannii/ifvms.js
Expand Down Expand Up @@ -1742,7 +1742,7 @@ var VM = Class.subClass({
Z-Machine runtime functions
===========================
Copyright (c) 2015 The ifvms.js team
Copyright (c) 2016 The ifvms.js team
BSD licenced
http://github.com/curiousdannii/ifvms.js
Expand Down Expand Up @@ -2190,12 +2190,11 @@ TODO:
// Based on the discussions in this forum topic, we will not implement the sequential mode recommended in the standard
// http://www.intfiction.org/forum/viewtopic.php?f=38&t=16023

// Instead implement a 16 bit Xorshift generator taken from
// http://b2d-f9r.blogspot.com.au/2010/08/16-bit-xorshift-rng.html
seed ^= ( seed << 4 ) & 0xFFFF;
seed ^= ( seed >> 3 ) & 0xFFFF;
this.xorshift_seed = ( seed ^= ( seed << 7 ) & 0xFFFF );
return 1 + ( seed % range );
// Instead implement a 32 bit Xorshift generator
seed ^= ( seed << 13 );
seed ^= ( seed >> 17 );
this.xorshift_seed = ( seed ^= ( seed << 5 ) );
return 1 + ( ( seed & 0x7FFF ) % range );
},

// Request line input
Expand Down

0 comments on commit f458c45

Please sign in to comment.