Skip to content

A simple path finding artificial intelligence with a genetic algorithm.

License

Notifications You must be signed in to change notification settings

josephkerkhof/path-finding-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dot Path Finding AI

A simple path finding artificial intelligence with a genetic algorithm. Each generation improves on the last generation by taking best and mutating it a little for the following generation.

Details

Dots "die" when they run into the edge of the screen or when they hit an obstacle. Dots "succeed" when they run into the red goal dot at the top of the screen. See an example in the screenshot below.

Path-finding Genetic Algorithm on generation 5

Fitness function

public void calculateFitness(Pair<Integer, Integer> goalPosition){
    if(goalReached){
        fitness = 1.0 / 16.0 + 10000.0 / Math.pow(brainStep, 2);
    } else {
        double distanceToGoal = calcDistanceToGoal(goalPosition);
        fitness = 1.0 / Math.pow(distanceToGoal, 2);
    }
    if(fitness == Double.POSITIVE_INFINITY) {
        fitness = 1;
    }
}

Credits

A simple path finding artificial intelligence with genetic algorithm based on the tutorial originally written in Processing by CodeBullet.

About

A simple path finding artificial intelligence with a genetic algorithm.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages