I'm using the gloss library to picture a simulation. Is there a function, which stops the simulation
function when a condition is true. Just the last drawn picture should remain in the window.
Thanks in advance
I'm using the gloss library to picture a simulation. Is there a function, which stops the simulation
function when a condition is true. Just the last drawn picture should remain in the window.
Thanks in advance
As @ErikR suggested, what you're describing amounts to not updating the model anymore once you've reached the state you are looking for. You can define a combinator acting on stepping functions doing precisely this:
untilModel
:: (ViewPort -> Float -> model -> model)
-> (model -> Bool)
-> (ViewPort -> Float -> model -> model)
untilModel step isFrozen v f m =
if isFrozen m then m
else step v f m
When you have a step
function and you want to stop the simulation when isFrozen
becomes true of the model, you can simply pass simulate
the altered step function step `untilModel` isFrozen
.