Steering evaluate fitness

Posted by Vodemki on Game Development See other posts from Game Development or by Vodemki
Published on 2012-12-12T16:05:36Z Indexed on 2012/12/12 17:20 UTC
Read the original article Hit count: 264

Filed under:

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.

© Game Development or respective owner

Related posts about steering-behaviors