Re:Show HN: Brain Frog – Can you be random enough for 11 lin...
by escanor on Thursday June 25, 2026 @03:42AM
(#48670211)
pure random player:
"cheating" player:
is it possible to do any better? i haven't fully read frog/oracle code
[ Parent
| on HN ]
Re:Show HN: Brain Frog – Can you be random enough for 11 lin...
by escanor on Thursday June 25, 2026 @04:00AM
(#48670359)
it is:
(async function(oracle, punch, delay) {
async function sleep(ms) {
return new Promise((resolve, _) => {
setTimeout(resolve, ms)
})
}
for (let i = 0; i < 100; i++) {
const state = oracle._state
const block = oracle.predictNextPunch()
oracle._state = state
punch(block === 'L' ? 'R' : 'L')
await sleep(delay)
}
})(oracle, punch, 150)
Re:Show HN: Brain Frog – Can you be random enough for 11 lin...
by emrtnn on Thursday June 25, 2026 @07:16AM
(#48671797)
Less fancy hack here, intercept the prediction function on every punch and force the frog to take the opposite side.
const realPunch = punch;
punch = function(myMove) {
oracle.predictNextPunch = function() {
return myMove === 'L' ? 'R' : 'L';
};
realPunch(myMove);
};