Crate moonlander_gp

Source
Expand description

Generic Genetic Programming framework routines

This crate supplies a generic framework for solving GP programs. As a consumer, you’ll need to supply the following:

  • Enums to encode the various AST node types.
  • Implementations of AstNode, Mutatable and RandNode traits (which can usually be autogenerated using impl_astnode!()).
  • A fitness function evaluating the success of a given program.

Create random_population from your types, then call evolve repeatedly to improve the fitness of the population.

For a working example, see the santa_fe_ant in the examples/ directory.

Re-exports§

Modules§

Macros§

  • Implement AstNode and RandNode trait for a node type.
  • Randomly pick from a weighted list of alternatives.

Structs§

Traits§

  • Main trait to be implemented for AST node types
  • Mutation trait for nodes
  • Implement trait to generate random subtrees of a given type.

Functions§

  • Helper function for use inside replace_children().
  • Return the depth of an AST tree.
  • Generate a random population of size N.
  • Take the best fraction of the population and fill back up to N with random programs.