(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 codepunch = function(myMove) {
oracle.predictNextPunch = function() {
return myMove === 'L' ? 'R' : 'L';
};
realPunch(myMove);
}; (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) jot -r 100 0 1 | rs -t 10
I noticed my "fake randomness" is lacking long sequences of the same key. I feel like I'm "predictable" when I press the same key 5 times in a row, yet that happens a lot in a truly random distribution.Username+password. There is zero reason to require e-mail for account creation.