Documentation ¶
Overview ¶
Package system provides general-purpose [model.System] implementations.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackTermination ¶ added in v0.0.2
type CallbackTermination struct { Callback func(t int64) bool // The callback. ends the simulation when it returns true. // contains filtered or unexported fields }
CallbackTermination system.
Terminates a model run according to the return value of a callback function.
Expects a resource of type [model.Termination].
Example ¶
package main import ( "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/system" ) func main() { m := model.New() m.AddSystem(&system.CallbackTermination{ Callback: func(t int64) bool { return t >= 99 }}, ) m.Run() }
Output:
func (*CallbackTermination) Finalize ¶ added in v0.0.2
func (s *CallbackTermination) Finalize(w *ecs.World)
Finalize the system
func (*CallbackTermination) Initialize ¶ added in v0.0.2
func (s *CallbackTermination) Initialize(w *ecs.World)
Initialize the system
func (*CallbackTermination) Update ¶ added in v0.0.2
func (s *CallbackTermination) Update(w *ecs.World)
Update the system
type FixedTermination ¶
type FixedTermination struct { Steps int64 // Number of simulation ticks to run. // contains filtered or unexported fields }
FixedTermination system.
Terminates a model run after a fixed number of ticks.
Expects a resource of type [model.Termination].
Example ¶
package main import ( "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/system" ) func main() { m := model.New() m.AddSystem(&system.FixedTermination{Steps: 100}) m.Run() }
Output:
func (*FixedTermination) Finalize ¶
func (s *FixedTermination) Finalize(w *ecs.World)
Finalize the system
func (*FixedTermination) Initialize ¶
func (s *FixedTermination) Initialize(w *ecs.World)
Initialize the system
type PerfTimer ¶
type PerfTimer struct { UpdateInterval int // Update/print interval in model ticks. Stats bool // Whether to print world stats. // contains filtered or unexported fields }
PerfTimer system for printing elapsed time per model step, and optional world statistics.
Example ¶
package main import ( "github.com/mlange-42/arche-model/model" "github.com/mlange-42/arche-model/system" ) func main() { m := model.New() m.AddSystem(&system.PerfTimer{UpdateInterval: 10}) m.AddSystem(&system.FixedTermination{Steps: 30}) // Uncomment the next line. // m.Run()
Output:
Click to show internal directories.
Click to hide internal directories.