logoalt Hacker News

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

43 pointsby AlexanderZlast Friday at 12:57 PM30 commentsview on HN

Comments

hash0yesterday at 11:21 AM

I got 50 hits in 100 tries. That being said, I did not particularly like hitting that poor frog :'( Yes, I am the kind of player who would never choose the rude option when talking to an NPC.

show 1 reply
mike_hocktoday at 6:54 AM

You should make one where you can play against the branch predictors of various processors.

show 1 reply
escanortoday at 7:42 AM

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
show 2 replies
user-today at 5:11 AM

I am briefly in the top ten after completely misunderstanding the rules nicee

show 1 reply
IdiotSavagetoday at 6:32 AM

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.
brtkwrtoday at 6:20 AM

Would be fairer if the frog occasionally got to throw a punch or two...

show 1 reply
sscaryterrylast Friday at 1:01 PM

That was fun, got up to 79 :)

show 1 reply
momoraullast Saturday at 3:33 AM

46 and that was my ceiling. frogs smarter than me.

jmpavlectoday at 6:39 AM

Looks like the leaderboard was hacked unfortunately. Fun little concept.

andailast Monday at 12:56 AM

Woah, neat. Is this like, a Markov chain?

show 1 reply
digitalWestielast Monday at 1:16 PM

Just wanted to give the little guy a hug

ramon156today at 7:53 AM

Leaderboard has been overtaken :(

jv22222last Monday at 2:35 AM

How many pixels wide is the hit zone?

show 1 reply
vyroteklast Monday at 6:55 AM

Bam! 50 on the first try. Fun.

show 1 reply
ozyschmozylast Monday at 2:37 PM

Why does a silly little online game need my email to send a one-time login code? What a strange experience

show 1 reply
uberexlast Saturday at 4:05 AM

Free?!. Is there a "call us" SSO enabled plan?