Remix.run Logo
Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?(brainfrog.lol)
33 points by AlexanderZ 6 days ago | 28 comments
mike_hock 2 hours ago | parent | next [-]

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

rllj an hour ago | parent [-]

I was just about to comment the same! Sadly, branch predictors are incredibly well guarded secrets, mostly.

escanor an hour ago | parent | prev | next [-]

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
escanor 37 minutes ago | parent [-]

it is:

  (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)
hash0 21 hours ago | parent | prev | next [-]

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.

IdiotSavage 2 hours ago | parent | prev | next [-]

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.
user- 3 hours ago | parent | prev | next [-]

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

brtkwr 2 hours ago | parent | prev | next [-]

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

pjio an hour ago | parent [-]

In the first round I struggled to notice if I missed. The frog punching back would be a good indicator. And I wouldn't feel so guilty for punching a pacifist frog.

ramon156 44 minutes ago | parent | prev | next [-]

Leaderboard has been overtaken :(

jmpavlec 2 hours ago | parent | prev | next [-]

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

momoraul 5 days ago | parent | prev | next [-]

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

sscaryterry 6 days ago | parent | prev | next [-]

That was fun, got up to 79 :)

AlexanderZ 6 days ago | parent [-]

practice mode? the record for ranked matches is 64

sscaryterry 6 days ago | parent [-]

Yes

andai 3 days ago | parent | prev | next [-]

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

AlexanderZ 2 days ago | parent [-]

a variation of Aaronson Oracle

digitalWestie 3 days ago | parent | prev | next [-]

Just wanted to give the little guy a hug

jv22222 3 days ago | parent | prev | next [-]

How many pixels wide is the hit zone?

AlexanderZ 2 days ago | parent [-]

you don't have to aim

vyrotek 3 days ago | parent | prev | next [-]

Bam! 50 on the first try. Fun.

AlexanderZ 2 days ago | parent [-]

nice! try playing it the first thing every morning, it really wakes up your brain

ozyschmozy 3 days ago | parent | prev | next [-]

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

AlexanderZ 2 days ago | parent [-]

because it doesn't? practice mode requires no login. if you want to play a ranked match then you'll need an account, how else could it work?

applfanboysbgon 4 hours ago | parent | next [-]

> how else could it work?

Username+password. There is zero reason to require e-mail for account creation.

ozyschmozy 2 days ago | parent | prev [-]

Practice mode also has a popup telling you what to do which seems to negate the point of the game?

AlexanderZ a day ago | parent [-]

it's the coach mode telling you which biases you have so you can fix them in a ranked match

uberex 5 days ago | parent | prev [-]

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