Darwin Neuroevolution Framework
Public Member Functions | List of all members
harvester::Harvester Class Reference

Domain: A simple 2D map navigation and resource gathering. More...

#include <harvester.h>

Inheritance diagram for harvester::Harvester:
darwin::Domain core::NonCopyable

Public Member Functions

bool evaluatePopulation (darwin::Population *population) const override
 Assigns fitness values to every genotype. More...
 
size_t inputs () const override
 Number of inputs to a Brain.
 
size_t outputs () const override
 Number of outputs from a Brain.
 
- Public Member Functions inherited from darwin::Domain
virtual unique_ptr< core::PropertySetcalibrateGenotype ([[maybe_unused]] const Genotype *genotype) const
 Optional: additional fitness metrics (normally not used in the population evaluation, ie a test set)
 

Detailed Description

Domain: A simple 2D map navigation and resource gathering.

The robot navigates a randomly generated 2D map, represented as a grid where a cell can be one of the following:

harvester_sandbox.png

The robot starts with an initial health value, then at each step it can perform an action. Each action has a health "cost", and once the health drops to zero the experiment is terminated.

Inputs

The robot's vision is constructed from a number of rays (Config::vision_resolution) fanned within a field of view (Config::vision_fov). For each ray, two input values are calculated (distance and color)

Input Value
2i distance
2i+1 color

Outputs

Output Value
0 move (magnitude determines the movement distance)
1 rotate (magnitude determines the rotation angle)

Member Function Documentation

◆ evaluatePopulation()

bool harvester::Harvester::evaluatePopulation ( darwin::Population population) const
overridevirtual

Assigns fitness values to every genotype.

Having a good fitness function is a key part of evolutionary algorithms:

  • Perhaps obvious, the fitness value should accurately estimate the quality of a particular solution
  • A "smooth" distribution is preferable since it provides a gradient which can guide the incremental search in the solutions space. (ex. if most fitness values are 1.0 or 0.0 it's hard to know which genotypes are good candidates for reproduction)
Returns
true if the evolution goal was reached

Implements darwin::Domain.


The documentation for this class was generated from the following files: