[reactive] Can we do without delayed switching?

Daniel Bünzli daniel.buenzli at erratique.ch
Wed Mar 4 17:07:21 EST 2009


I don't think you can do this without a form of recursive behaviour  
and hence a way to introduce infinitesimal delay to fix recursive  
definitions. Assuming you don't deal with acceleration at a given time  
t you have :

collisions depends on position
position depends on velocity
velocity depends on collisions

This has no least fixed point at time t. To break the tight loop you  
must introduce an infinitesimal delay in one of the dependencies.

Note that doing the same as you do (see the p.s. below) made me doubt  
a little bit on the appropriateness of frp for physics simulations.  
The problem is that physics simulations are dirty with respect to time  
(at least as implemented traditionnaly). Dirty in the sense that you  
update positions according to your time step and once you realize that  
you went to far (i.e. across a collider) you come back in the past  
until the point of contact, invoke collision response, and start this  
again until your system stabilizes at the end of the time step. In my  
breakout game the system is ad-hoc, I tried to factor out a more  
general system where collision detection and collision response would  
be nicely separated, as is usual in physics engines, but didn't really  
succeed; at least not without introducing a lot of intermediary  
behaviours. This lead me to think that maybe implementing the  
simulation more traditionnaly and give it an frp interface to  
implement the game logic to be feedback in the simulation would be a  
better approach.

As I said elsewhere I'd love to be proven wrong i.e. that implementing  
physics simulation in frp itself is feasible and worthwhile. Maybe my  
lack of experience with frp is just showing, as is my experience with  
physics engines, and I'd be interested to know if anybody comes with  
interesting and non-contrived frp solutions to these problems.

Best,

Daniel

P.S. There's an ANSI terminal breakout [1] in the examples of my own  
OCaml frp library. It uses infinitesimally delayed behaviours to break  
the loop mentionned above.

[1] http://erratique.ch/software/react/repo/test/breakout.ml




More information about the Reactive mailing list