I’m making something similar to Polyworld, which means I will be simulating virtual worlds where little creepers run around, eat, and evolve. I’m making that with Node.js, and I plan to use physics and neural networks, but I’m not sure what’s the best way to update the world, more specifically, should the update functions be recieving delta time as an argument, or do the same thing each time, independent of when they were last called? What are the benefits of both ways?
Edit:
A point that I have against continous updates is that I want to implement some kind of intervals, for example, each 20 simulation seconds a food block spawns. If the dt gets different than 1 (or a fraction of 1), this will never work precisely.
Then again, if I go with discrete updates, where updates don’t care about how much time has passed, I won’t be able to “slow time down”. As I made this to work on a powerful server and render in the browser, I figure that the updates will happen pretty often, and I need a way of slowing time down without affecting the simulation, so I can see what’s happening.
If your don’t have multiple agents (each with its own thread) that have to collaborate and that you dont have to deal with synchronization/events of process flow problems I recomend you to use continuous simulation. Using fixed time step and change the state of your world in each step.
Each world piece change its state using a funcion like:
newState = f(oldState, deltaSteps)
About the speed problem you mention, do not directly map your iterations to time. Define a intermediate time unit (step), and them map this unit time to ms, iterations or what you prefer. So if you what to increase or reduce your simulation speed, just change the factor used to conver from step to time/iterations. If you need to change speed just change your constant.
Check this page with some insight about simulation techniques.