Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Created July 15, 2020 18:00
Show Gist options
  • Save dsetzer/cafbc71be93d1925678b8dd30f0f5745 to your computer and use it in GitHub Desktop.
Save dsetzer/cafbc71be93d1925678b8dd30f0f5745 to your computer and use it in GitHub Desktop.
Generates previous games from within the script.
var config = {
span: { label: 'Previous Games', type: 'number', value: '100' },
outh: { label: 'Print Hashes', type: 'checkbox', value: false }
};
Object.entries(config).forEach((c) => window[c[0]] = c[1].value);
let hashes = new Map(), lastGame = engine.history.first();
let currentId = lastGame.id, currentHash = lastGame.hash;
for(let i = currentId, result, len = currentId - span; i >= len; i--){
hashes.set(i, String(currentHash));
currentHash = SHA256((currentHash));
}
let logGame = (hash, id) => log(`Game: ${id}, Bust: ${gameResultFromHash(hash)}${outh?', Hash: '+hash:''}`);
hashes.forEach(logGame);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment