Thanks for your reply, @cybereality .
I'm really not an expert, so I might be using this the wrong way. I'll add some detailed explanation below, but if you have other ideas/directions of how to introduce a simulation speed I'd be glad to hear.
Essentially, it's a simple simulation.
At the beginning, 150 "creatures" are created. They are KinematicBody2D
nodes, with a sprite, a collision shape and some attributes.
The creatures start with a random Vector2D
velocity, and move with move_and_collide(velocity * speed * delta)
in the _physics_process
function.
If the movement yields a collision, the "creature" interacts with the other creature it collided with, based on some attributes.
It might attack the other creature, reducing its health, or it might reproduce, adding a new creature to the world.
Both the attack and the reproduce have a Timer
, that gets fired right before the action is executed, i.e:
if can_reproduce:
reproduce_timer.start()
reproduce_with(other)
The timeout function of each of the timers sets the can_do_action
flag to true
.
In addition to that, there's a HealthTimer
that reduces the creature's health every X seconds.
Lastly, when creatures collide (with another creature or the screen border), they pick a new direction at random.
Here's where thing sdon't work as expected:
With the current configuration of the creatures and the world, the population slowly declines (due to the health drop, and the attacking creatures), to extinction.
If I raise the speed, using Engine.time_scale
, the opposite happens. The creatures reproduce faster than dying, and the world explodes with creatures, to the point that everything stalls.
If I then set the speed back to "normal", the population might continue to grow, as they are continuously colliding.
I was expecting the behaviour to be the same. With faster speed I would've expected the population to decline faster, not to grow.
Why is the faster speed causing this baby boom?