dev

package
v0.0.0-...-b9e61c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BaseActionTypes = []ActionType{
		mut.Add,
		mut.DropOut,
		mut.Div,
		mut.LinearRange,
		mut.Scale,
	}
	BaseActionWeights = []float64{
		0.5,
		0.3,
		0.05,
		0.1,
		0.1,
	}
	BaseActionStrength = []floatrange.Range{
		floatrange.NewLinear(-15, 15),
		floatrange.NewLinear(-30, 30),
		floatrange.NewLinear(5, 9),
		floatrange.NewLinear(1, 10),
		floatrange.NewLinear(-5, 5),
	}
)
View Source
var (
	MechanicNames = map[int]*Mechanic{}

	MechanicLookup  = map[*Mechanic]*render.Composite{}
	MechanicIndexes = map[*Mechanic]int{}
)

Functions

func NextMechanicName

func NextMechanicName() int

Types

type ActionModCrossover

type ActionModCrossover struct {
	TypeLengthMod intrange.Range
	TypeWeightMod floatrange.Range
	TypeWeightDef floatrange.Range
	StrengthMod   frange.Mutator
}

func (*ActionModCrossover) Crossover

func (amc *ActionModCrossover) Crossover(a, b *Base) ([]ActionType, []float64, []floatrange.Range)

type ActionMut

type ActionMut func(mut.FloatMutator, *float64) func()

type ActionType

type ActionType func(strength float64) mut.FloatMutator

type ActionTypeCrossover

type ActionTypeCrossover interface {
	Crossover(a, b *Base) ([]ActionType, []float64, []floatrange.Range)
}

type Base

type Base struct {
	InitSize          intrange.Range
	GoalSize          intrange.Range
	GoalDistance      intrange.Range
	EnvSize           intrange.Range
	EnvVal            floatrange.Range
	ActionCount       intrange.Range
	ActionTypes       []ActionType
	ActionTypeWeights []float64
	ActionStrengths   []floatrange.Range

	// Crossover and Mutation methods set by generators
	DevMutation
	Cross Crossover
	// contains filtered or unexported fields
}

func Default

func Default() *Base

func (*Base) CanCrossover

func (d *Base) CanCrossover(other pop.Individual) bool

func (*Base) Crossover

func (d *Base) Crossover(other pop.Individual) pop.Individual

func (*Base) Fitness

func (d *Base) Fitness(input, expected [][]float64) int

func (*Base) Mechanic

func (d *Base) Mechanic() *Mechanic

func (*Base) Mutate

func (d *Base) Mutate()

func (*Base) Print

func (d *Base) Print()

func (*Base) SetFitness

func (d *Base) SetFitness(f int)

func (*Base) String

func (d *Base) String() string

type BasicDevMutation

type BasicDevMutation struct {
	InitSize          irange.Mutator
	GoalSize          irange.Mutator
	GoalDistance      irange.Mutator
	EnvSize           irange.Mutator
	EnvVal            frange.Mutator
	ActionCount       irange.Mutator
	ActionTypeWeights mut.FloatMutator
	ActionStrengths   frange.Mutator
}

func (BasicDevMutation) Mutate

func (bdv BasicDevMutation) Mutate(d *Base)

type Creator

type Creator interface {
	NewDev() Dev
}

type Crossover

type Crossover interface {
	Crossover(a, b *Base) *Base
}

type Dev

type Dev interface {
	Mechanic() *Mechanic
	SetFitness(int)
	pop.Individual
}

type DevMutation

type DevMutation interface {
	Mutate(*Base)
}

type LinearCreator

type LinearCreator struct {
	InitSizeBottom       floatrange.Range
	InitSizeTop          floatrange.Range
	GoalSizeBottom       floatrange.Range
	GoalSizeTop          floatrange.Range
	GoalDistanceBottom   floatrange.Range
	GoalDistanceTop      floatrange.Range
	EnvSizeBottom        floatrange.Range
	EnvSizeTop           floatrange.Range
	EnvValBottom         floatrange.Range
	EnvValTop            floatrange.Range
	ActionCountBottom    floatrange.Range
	ActionCountTop       floatrange.Range
	ActionTypeCount      intrange.Range
	ActionTypeChoices    []ActionType
	ActionTypeWeights    floatrange.Range
	ActionStrengthBottom floatrange.Range
	ActionStrengthTop    floatrange.Range
	CrossoverOptions     []Crossover
	MutationOptions      []DevMutation
}

func (*LinearCreator) NewDev

func (ldc *LinearCreator) NewDev() Dev

type LinearDevCrossover

type LinearDevCrossover struct {
	ActionTypeCrossover
}

func (*LinearDevCrossover) Crossover

func (ldc *LinearDevCrossover) Crossover(a, b *Base) *Base

type MechFitness

type MechFitness func(*Mechanic) int

type MechNode

type MechNode interface {
	MechanicDistance(*Mechanic) float64
}

type Mechanic

type Mechanic struct {
	Actions []func()
	//Passives []func()
	//Continuous bool
	//PassiveTypes     []ActionType
	//PassiveStrengths []float64
	//
	Environment *env.F
	Init        map[int]float64
	Goal        map[int]float64
	MechFitness
}

func (*Mechanic) Distance

func (mch *Mechanic) Distance(n unique.Node) (float64, bool)

func (*Mechanic) FitnessAbs

func (mch *Mechanic) FitnessAbs() int

func (*Mechanic) FitnessElems

func (mch *Mechanic) FitnessElems() int

func (*Mechanic) MechanicDistance

func (mch *Mechanic) MechanicDistance(mch2 *Mechanic) float64

func (*Mechanic) Reset

func (mch *Mechanic) Reset()

func (*Mechanic) String

func (mch *Mechanic) String() string

type RenderMechanic

type RenderMechanic struct {
	*render.Composite
	*Mechanic
}

func NewRenderMechanic

func NewRenderMechanic(mch *Mechanic) *RenderMechanic

func (*RenderMechanic) GetR

func (rmch *RenderMechanic) GetR() render.Renderable

func (*RenderMechanic) String

func (rmch *RenderMechanic) String() string

type SpreadCreator

type SpreadCreator struct {
	*LinearCreator
}

SpreadDevCreators just use the same fields as Linear but with bottom=base and top=spread

func (*SpreadCreator) NewDev

func (bsdc *SpreadCreator) NewDev() Dev

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL