# Forces on entities: remove all each update step, or remove on demand?

Following the answer to my question here, the way I apply forces on an entity, is each entity has a Map of forces (Vectors) and their IDs. Every update step, the acceleration vector is set to the sum of all the forces. Forces can be removed by using their unique ID.

In psuedocode:

class Monster extends MovingEntity{
Vector position, acceleration, velocity;
Map<String, Vector> forces;
// .. stuff omitted

public void update(){
acceleration = new Vector(0,0); // zeroing the accleration
foreach force in forces{
}
}

public void applyForce(Vector force, String id){
forces.put(id, force);
}

public void removeForce(String id){
forces.remove(id);
}
}


This works fine, but here is my dilemma:

Currently, after adding a force I have to remember to remove it. For example, psuedocode to demonstrate the way player input is handled:

if(playerInput.leftPressed()) player.applyForce(new Vector(2,0), "left");
// applyForce() internally deletes the previous force with the same name.
else player.removeForce("left");
// have to remember to remove the force. sometimes a little complicated


This can also be annoying e.g. when using steering behaviors. An AI agent may want to Seek somewhere, which applies a force on itself. But when it's done Seeking, it must remove the force.

I'm wondering if it would be a good idea to empty the forces Map at the end of each update step. In the update() method from before:

    public void update(){
acceleration = new Vector(0,0);
forces.empty(); // emptying the forces list
}


Returning to the steering behaviors example, this way an agent doesn't need to remove the Seek force when it's done seeking. Each update step, as long as it calls applyForce(..), it will Seek. But the first update step that it doesn't apply a force, there will be no force. All forces are deleted automatically. And since in games forces are constantly deleted and replaced with new ones, I think this seems natural.

What is your opinion? Reset all forces each update step? Or have entities and their environment manually remove forces when it's needed?