pure random player:
(async function(punch, delay) {
async function sleep(ms) {
return new Promise((resolve, _) => {
setTimeout(resolve, ms)
})
}
for (let i = 0; i < 100; i++) {
punch(['L', 'R'][(Math.random() * 2) | 0])
await sleep(delay)
}
})(punch, 150)
"cheating" player: (async function(oracle, punch, delay) {
async function sleep(ms) {
return new Promise((resolve, _) => {
setTimeout(resolve, ms)
})
}
for (let i = 0; i < 100; i++) {
punch((i + 1) < oracle.minForPrediction ? ['L', 'R'][(Math.random() * 2) | 0] : oracle.predictNextPunch() === 'L' ? 'R' : 'L')
await sleep(delay)
}
})(oracle, punch, 150)
is it possible to do any better? i haven't fully read frog/oracle code