Live data from Hacker News

Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?

brainfrog.lol

31–40 of 48 posts

Re: Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?

#31
post #29

pure random player: (async function(punch, delay) { async function sleep(ms) { return new Promise((resolve, _) => { setTimeout(resolve, ms) }) } for (let i = 0; i "cheating" player: (async function(oracle, punch, delay) { async function sleep(ms) { return new Promise((resolve, _) => { setTimeout(resolve, ms) }) } for (let i = 0; i is it possible to do any better? i haven't fully read frog/oracle code

it is:

  (async function(oracle, punch, delay) {
    async function sleep(ms) {
      return new Promise((resolve, _) => {
        setTimeout(resolve, ms)
      })
    }
    
    for (let i = 0; i 

Re: Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?

#34
post #29

pure random player: (async function(punch, delay) { async function sleep(ms) { return new Promise((resolve, _) => { setTimeout(resolve, ms) }) } for (let i = 0; i "cheating" player: (async function(oracle, punch, delay) { async function sleep(ms) { return new Promise((resolve, _) => { setTimeout(resolve, ms) }) } for (let i = 0; i is it possible to do any better? i haven't fully read frog/oracle code

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);
};

Re: Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?

#39

If you want to see what a random distribution looks like: 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.

With Brain Frog I went even further - it doesn't actually check L/R. Instead, it checks what you do after a landed/blocked punch (some people tend to switch after a block, others insist on hitting the same side until they land a hit).
Post reply on HN