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

brainfrog.lol

48 points by AlexanderZ 7 days ago


hash0 - 3 days ago

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.

escanor - 2 days ago

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
mike_hock - 2 days ago

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

user- - 2 days ago

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

AlexanderZ - 17 hours ago

By the way, there is an ios app: https://apps.apple.com/app/id6755528165

krussikas - a day ago

I once coded a rock-paper-scissors game that you can play against a tree based matcher/learner, with symmetry between the options accounted for. Pretty similar idea-wise. To be honest, it was pretty hard to get a better than random score.

IdiotSavage - 2 days ago

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.
subarctic - a day ago

Curious how a couple people got >100 hits on 100 punches

brtkwr - 2 days ago

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

sscaryterry - 7 days ago

That was fun, got up to 79 :)

momoraul - 7 days ago

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

andai - 5 days ago

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

digitalWestie - 4 days ago

Just wanted to give the little guy a hug

jmpavlec - 2 days ago

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

jv22222 - 5 days ago

How many pixels wide is the hit zone?

ramon156 - 2 days ago

Leaderboard has been overtaken :(

- 2 days ago
[deleted]
vyrotek - 5 days ago

Bam! 50 on the first try. Fun.

ozyschmozy - 4 days ago

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

uberex - 7 days ago

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