Show HN: Brain Frog – Can you be random enough for 11 lines of JavaScript?
43 points
5 days ago
| 16 comments
| brainfrog.lol
| HN
hash0
1 day 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.
reply
escanor
4 hours 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
reply
emrtnn
1 hour ago
[-]
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);
};
reply
escanor
4 hours ago
[-]
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)
reply
mike_hock
5 hours ago
[-]
You should make one where you can play against the branch predictors of various processors.
reply
rllj
5 hours ago
[-]
I was just about to comment the same! Sadly, branch predictors are incredibly well guarded secrets, mostly.
reply
user-
7 hours ago
[-]
I am briefly in the top ten after completely misunderstanding the rules nicee
reply
thih9
1 hour ago
[-]
The ultimate unpredictability.
reply
IdiotSavage
5 hours 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.
reply
brtkwr
6 hours ago
[-]
Would be fairer if the frog occasionally got to throw a punch or two...
reply
pjio
4 hours ago
[-]
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.
reply
sscaryterry
5 days ago
[-]
That was fun, got up to 79 :)
reply
AlexanderZ
5 days ago
[-]
practice mode? the record for ranked matches is 64
reply
sscaryterry
5 days ago
[-]
Yes
reply
momoraul
5 days ago
[-]
46 and that was my ceiling. frogs smarter than me.
reply
andai
3 days ago
[-]
Woah, neat. Is this like, a Markov chain?
reply
AlexanderZ
1 day ago
[-]
a variation of Aaronson Oracle
reply
jmpavlec
5 hours ago
[-]
Looks like the leaderboard was hacked unfortunately. Fun little concept.
reply
digitalWestie
2 days ago
[-]
Just wanted to give the little guy a hug
reply
ramon156
4 hours ago
[-]
Leaderboard has been overtaken :(
reply
jv22222
3 days ago
[-]
How many pixels wide is the hit zone?
reply
AlexanderZ
1 day ago
[-]
you don't have to aim
reply
vyrotek
3 days ago
[-]
Bam! 50 on the first try. Fun.
reply
AlexanderZ
1 day ago
[-]
nice! try playing it the first thing every morning, it really wakes up your brain
reply
ozyschmozy
2 days ago
[-]
Why does a silly little online game need my email to send a one-time login code? What a strange experience
reply
AlexanderZ
1 day ago
[-]
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?
reply
applfanboysbgon
7 hours ago
[-]
> how else could it work?

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

reply
ozyschmozy
1 day ago
[-]
Practice mode also has a popup telling you what to do which seems to negate the point of the game?
reply
AlexanderZ
1 day ago
[-]
it's the coach mode telling you which biases you have so you can fix them in a ranked match
reply
uberex
5 days ago
[-]
Free?!. Is there a "call us" SSO enabled plan?
reply