Steering evaluate fitness
- by Vodemki
I've made a simple game with a steering model that manage a crowd of agents. I use an genetic algorithm to find the best parameters to use in my system but I need to determine a fitness for each simulation.
I know it's something like that:
number of collisions * time to reach goal * effort
But I don't know how to calculate the effort, is there a special way to do that ?
Here is what I've done so far:
// Evaluate the distance from agents to goal
Real totalDistance(0.0);
for (unsigned i=0; i<_agents.size(); i++)
{
totalDistance += _agents[i]->position().distance(_agents[i]->_goal->position());
}
Real totalWallsCollision(0.0);
for (unsigned i=0; i<_agents.size(); i++)
{
for (unsigned j=0; j<walls.size(); j++)
{
if ( walls[j]->inside(_agents[i]->position()) )
{
totalCollision += 1.0;
}
}
}
return totalDistance + totalWallsCollision;
Thanks for your help.