Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How hard would it be to solve this deterministically?

Can someone comment on the game's physics? I am assuming:

  - constant horizontal velocity
  - gravity
  - flapping implemented via impulse
  - collisions are handled with bounding boxes
Maybe someone who knows something about optimal control (ODE) say whether this is analytically solvable? Of course there's still the practical stuff (numerical integration, I/O lag) to deal with but I'm optimistic.


If you play the game, it's actually quite trivial to program deterministically. :-) Flapping is not implemented as an impulse. It's more like jumping in Mario - it instantaneously fires a canned "flap" movement that is always the same.

Set flap_height = bottom of next pipe + constant.

If bird height < flap_height, flap.

Done!


It also looks like you'd want to avoid flapping into the top of the pipe.


Perhaps I should have said "threshold_height".

    threshold_height = bottom_of_pipe_height + 10 pixels; // or something

    if (current_height < threshold_height)
      flap
    else
      don't flap
If you never flap when above the threshold, you will not hit the top.


In another Flappy Bird thread (the MMO one), somebody posted this formula:

    Let distance between ground and top of screen=100. 
    Bird position after a flap at y=y0, time=t0:
    y(t) = y0 + 13.8 - 147 * (t - t0 - 0.288)^2
(https://news.ycombinator.com/item?id=7229018 -- note the original comment had "+ 0.288", but if you plot the graph this was obviously a mistake)

I tried it out in my own HTML5/JS Flappy clone (mine's not at all interesting or even done, but I felt I had to give it a try), and the movement seems really accurate.

I have no idea how they got to those numbers, however.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: