Skip to content

Instantly share code, notes, and snippets.

@oupo
Created April 5, 2010 08:07
Show Gist options
  • Save oupo/356136 to your computer and use it in GitHub Desktop.
Save oupo/356136 to your computer and use it in GitHub Desktop.
var timer_id;
(function() {
var i = 0;
loop();
function loop() {
var start_time = Date.now();
for (;;) {
if (judge_seed(i)) {
console.log(format_hex(i, 8));
}
i ++;
if ((i & 63) === 0 && Date.now() - start_time >= 100) {
document.title = format_hex(i, 8);
timer_id = setTimeout(loop);
return;
}
}
}
function judge_seed(seed) {
var prng = new TowerPRNG(seed);
prng.rand();
var trainers = calc_trainers(prng);
var entries = calc_entries(prng, trainers[0]);
var tid = prng.rand32();
var pids = calc_pids(prng, entries);
for (var i = 0; i < 3; i ++) {
var pid = pids[i];
if (((tid >>> 16) ^ (tid & 0xffff) ^ (pid >>> 16) ^ (pid & 0xffff)) < 8) {
console.log(map(pids, function(p){return format_hex(p,8)}).join(",")+":"+i);
return true;
}
}
return false;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment