core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPCG

func NewPCG(seed int64) *rand.Rand

Types

type Action

type Action interface {
	Vector() []float64
}

type Agent

type Agent interface {
	Act(s State) Action

	Observe(s State, a Action, r Reward, next State, done bool)

	EndEpisode(totalReward Reward)
}

type Camera

type Camera = view.Camera

Camera is the family's display-free 2D pan/zoom camera (crucible/view), with follow and fit-to-bounds framing.

func NewCamera

func NewCamera(viewW, viewH float64) *Camera

NewCamera returns a camera at unit zoom filling a viewW×viewH screen.

type Environment

type Environment interface {
	Reset(rng *rand.Rand) State

	Step(a Action) (State, Reward, bool)

	ActionSpec() Spec

	ObservationSpec() Spec

	Render(r Renderer)
}

type Individual

type Individual interface {
	Act(s State) Action

	Fitness() Reward

	SetFitness(r Reward)

	Genome() []float64
}

type MultiEnvironment

type MultiEnvironment interface {
	ResetAll(n int, rng *rand.Rand) []State

	StepAll(actions []Action) (states []State, rewards []Reward, dones []bool)

	ActionSpec() Spec

	ObservationSpec() Spec

	Alive() int

	Render(r Renderer)
}

type PopulationAgent

type PopulationAgent interface {
	Agent

	All() iter.Seq[Individual]

	Len() int

	Evolve()

	Generation() int
}

type Renderer

type Renderer interface {
	Line(x1, y1, x2, y2 float64, c color.Color)

	Circle(x, y, radius float64, c color.Color)

	Polygon(pts [][2]float64, c color.Color)

	Text(x, y float64, s string)

	Camera() *Camera
}

type Reward

type Reward float64

type Spec

type Spec struct {
	Dim      int
	Low      []float64
	High     []float64
	Discrete bool
}

func (Spec) Clamp

func (s Spec) Clamp(v []float64) []float64

func (Spec) Valid

func (s Spec) Valid() error

type State

type State interface {
	Observation() []float64
}

type Vec2

type Vec2 struct {
	X, Y float64
}

Jump to

Keyboard shortcuts

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