z = 3;
        var w = seed|0;
        this.random = function random() {
            var t = x;
            t ^= t << 11;
            t ^= t >> 8;
            x = y; y = z; z = w;
            w ^= w >> 19;
            w ^= t;
            return (w%1024)/1024;
        }
    }

    var rndGen = new XorshiftMath(seed);
    function rnd(x) {
        return x > rndGen.random();
    }
    function pickInList(list) {
        var i = list.length; while(i>1 && rnd(1/i)) { i--; }
        return list[i-1];
    }

    