Documentation ¶
Overview ¶
Package bees provides a stylized model of bee foraging and scouting.
Index ¶
- func Run()
- type ActFollow
- type ActForage
- type ActInHive
- type ActReturn
- type ActScout
- type ActWaggleDance
- type Colors
- type Direction
- type FlowerPatch
- type Hive
- type HomeHive
- type Params
- type Patches
- type Position
- type Random256
- type SysFleeing
- type SysFollowing
- type SysForaging
- type SysHiveDecisions
- type SysInitBees
- type SysInitHives
- type SysManagePatches
- type SysReturning
- type SysScouting
- type SysWaggleDance
- type UISysClearFrame
- type UISysDrawBees
- type UISysDrawHives
- type UISysDrawPatches
- type UISysManagePause
- type UISysRepaint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActFollow ¶
type ActFollow struct { // Position of the target patch. Target Position }
ActFollow component indicating "following a waggle dance" activity.
type ActForage ¶
type ActForage struct { // Starting tick of the activity. Start int64 // Resource load collected so far. Load float64 }
ActForage activity component indicating foraging activity.
type ActInHive ¶
type ActInHive struct{}
ActInHive activity component indicating idle/in-hive activity.
type ActReturn ¶
type ActReturn struct { // Target position for return movement. Target Position // Source position of the return. Source Position // Resource load carried. Load float64 }
ActReturn activity component indicating return to hive activity.
type ActScout ¶
type ActScout struct { // Starting tick of the activity. Start int64 }
ActScout component indicating scouting activity.
type ActWaggleDance ¶
type ActWaggleDance struct { // End tick of the activity. End int64 // Target position the dance is pointing at. Target Position // Load the bee brought home. Load float64 // Expected benefit, being load brought, divided by distance. Benefit float64 }
ActWaggleDance activity component indicating waggle dance activity.
type Colors ¶
type Colors struct { Scout color.RGBA Forage color.RGBA Return color.RGBA Waggle color.RGBA InHive color.RGBA Follow color.RGBA }
Colors resource, holding colors for drawing bee activities.
type HomeHive ¶
HomeHive component. This is an ecs.Relation component, associating each bee with it's home hive.
type Params ¶
type Params struct {
MaxBeeSpeed float64
}
Params resource for parameters that are used by multiple systems.
type Patches ¶
Patches resource holding a grid of potential flower patches.
func NewPatches ¶
NewPatches creates a new Patches resource from world dimensions and grid cell size.
type Random256 ¶
type Random256 struct {
Value uint8
}
Random256 component, contains an uint8 value for scheduling things in intervals, but randomized over entities.
type SysFleeing ¶
type SysFleeing struct { FleeDistance float64 // contains filtered or unexported fields }
SysFleeing is a system that makes bees switch to the ActReturn activity when the mouse is near. Affects activities ActScout, ActFollow and ActForage. Actual fleeing is implemented in system SysReturning.
func (*SysFleeing) Initialize ¶
func (s *SysFleeing) Initialize(world *ecs.World)
Initialize the system
type SysFollowing ¶
type SysFollowing struct { MaxRotation float64 ScoutProbability float64 // contains filtered or unexported fields }
SysFollowing is a system that handles the movement of bees that currently fly to a patch that was indicated by them by a waggle dance (ActFollow).
Switches activity to ActForage or ActReturn on arrival.
func (*SysFollowing) Finalize ¶
func (s *SysFollowing) Finalize(world *ecs.World)
Finalize the system
func (*SysFollowing) Initialize ¶
func (s *SysFollowing) Initialize(world *ecs.World)
Initialize the system
type SysForaging ¶
type SysForaging struct { MaxForagingTime int64 MaxCollect float64 // contains filtered or unexported fields }
SysForaging is a system that handles resource extraction of foraging bees (ActForage) from patches.
Switches activity to ActReturn after a certain foraging time.
func (*SysForaging) Initialize ¶
func (s *SysForaging) Initialize(world *ecs.World)
Initialize the system
type SysHiveDecisions ¶
type SysHiveDecisions struct { ReleaseInterval int64 ReleaseCount int ScoutProbability float64 DanceSamples int // contains filtered or unexported fields }
SysHiveDecisions is a system that performs bee decisions in the hive.
Particularly, it decides whether bees go for scouting, or whether they follow a waggle dance, and which one.
func (*SysHiveDecisions) Finalize ¶
func (s *SysHiveDecisions) Finalize(world *ecs.World)
Finalize the system
func (*SysHiveDecisions) Initialize ¶
func (s *SysHiveDecisions) Initialize(world *ecs.World)
Initialize the system
func (*SysHiveDecisions) Update ¶
func (s *SysHiveDecisions) Update(world *ecs.World)
Update the system
type SysInitBees ¶
type SysInitBees struct { // Target number of bees per hive. CountPerHive int }
SysInitBees is a system that creates a number of bee entities per hive.
func (*SysInitBees) Initialize ¶
func (s *SysInitBees) Initialize(world *ecs.World)
Initialize the system
type SysInitHives ¶
type SysInitHives struct { // Target number of hives. Count int }
SysInitHives is a system that creates a number of randomly places hives.
func (*SysInitHives) Finalize ¶
func (s *SysInitHives) Finalize(world *ecs.World)
Finalize the system
func (*SysInitHives) Initialize ¶
func (s *SysInitHives) Initialize(world *ecs.World)
Initialize the system
type SysManagePatches ¶
type SysManagePatches struct { // Target number of patches. Count int // contains filtered or unexported fields }
SysManagePatches is a system that creates a number of randomly placed flower patches. Further, it removes patches that are depleted, and creates new patches if the number of patches falls below Count.
func (*SysManagePatches) Finalize ¶
func (s *SysManagePatches) Finalize(world *ecs.World)
Finalize the system
func (*SysManagePatches) Initialize ¶
func (s *SysManagePatches) Initialize(world *ecs.World)
Initialize the system
func (*SysManagePatches) Update ¶
func (s *SysManagePatches) Update(world *ecs.World)
Update the system
type SysReturning ¶
type SysReturning struct { MaxRotation float64 FleeDistance float64 MaxDanceProbability float64 // contains filtered or unexported fields }
SysReturning is a system that handles movement of bees returning to their hive (ActReturn).
Switches activity to ActInHive or ActWaggleDance on arrival. The probability of dancing depends on the resource load the bee brought back.
func (*SysReturning) Finalize ¶
func (s *SysReturning) Finalize(world *ecs.World)
Finalize the system
func (*SysReturning) Initialize ¶
func (s *SysReturning) Initialize(world *ecs.World)
Initialize the system
type SysScouting ¶
type SysScouting struct { MaxRotation float64 MaxScoutTime int64 // contains filtered or unexported fields }
SysScouting is a system that handles movement of scouting bees (ActScout).
Switches activity to ActReturn after a certain time of scouting.
func (*SysScouting) Initialize ¶
func (s *SysScouting) Initialize(world *ecs.World)
Initialize the system
type SysWaggleDance ¶
type SysWaggleDance struct { MinDanceDuration int64 MaxDanceDuration int64 // contains filtered or unexported fields }
SysWaggleDance is a system that handles bees doing a waggle dance at the hive (ActWaggleDance).
Switches activity to ActInHive after a certain time of dancing. Duration of dancing depends on the resource load the bee brought back.
func (*SysWaggleDance) Finalize ¶
func (s *SysWaggleDance) Finalize(world *ecs.World)
Finalize the system
func (*SysWaggleDance) Initialize ¶
func (s *SysWaggleDance) Initialize(world *ecs.World)
Initialize the system
type UISysClearFrame ¶
type UISysClearFrame struct {
// contains filtered or unexported fields
}
UISysClearFrame is a simple system that clears the [Image] resource before other systems draw on it.
func (*UISysClearFrame) FinalizeUI ¶
func (s *UISysClearFrame) FinalizeUI(world *ecs.World)
FinalizeUI the system
func (*UISysClearFrame) InitializeUI ¶
func (s *UISysClearFrame) InitializeUI(world *ecs.World)
InitializeUI the system
func (*UISysClearFrame) PostUpdateUI ¶
func (s *UISysClearFrame) PostUpdateUI(world *ecs.World)
PostUpdateUI the system
func (*UISysClearFrame) UpdateUI ¶
func (s *UISysClearFrame) UpdateUI(world *ecs.World)
UpdateUI the system
type UISysDrawBees ¶
type UISysDrawBees struct {
// contains filtered or unexported fields
}
UISysDrawBees is a system for drawing bees as colored pixels.
func (*UISysDrawBees) FinalizeUI ¶
func (s *UISysDrawBees) FinalizeUI(world *ecs.World)
FinalizeUI the system
func (*UISysDrawBees) InitializeUI ¶
func (s *UISysDrawBees) InitializeUI(world *ecs.World)
InitializeUI the system
func (*UISysDrawBees) PostUpdateUI ¶
func (s *UISysDrawBees) PostUpdateUI(world *ecs.World)
PostUpdateUI the system
func (*UISysDrawBees) UpdateUI ¶
func (s *UISysDrawBees) UpdateUI(world *ecs.World)
UpdateUI the system
type UISysDrawHives ¶
type UISysDrawHives struct {
// contains filtered or unexported fields
}
UISysDrawHives is a system for drawing hives as pie charts over the activities of related bees.
func (*UISysDrawHives) FinalizeUI ¶
func (s *UISysDrawHives) FinalizeUI(world *ecs.World)
FinalizeUI the system
func (*UISysDrawHives) InitializeUI ¶
func (s *UISysDrawHives) InitializeUI(world *ecs.World)
InitializeUI the system
func (*UISysDrawHives) PostUpdateUI ¶
func (s *UISysDrawHives) PostUpdateUI(world *ecs.World)
PostUpdateUI the system
func (*UISysDrawHives) UpdateUI ¶
func (s *UISysDrawHives) UpdateUI(world *ecs.World)
UpdateUI the system
type UISysDrawPatches ¶
type UISysDrawPatches struct {
// contains filtered or unexported fields
}
UISysDrawPatches is a system for drawing flower patches as squares with fading green color as they become depleted.
func (*UISysDrawPatches) FinalizeUI ¶
func (s *UISysDrawPatches) FinalizeUI(world *ecs.World)
FinalizeUI the system
func (*UISysDrawPatches) InitializeUI ¶
func (s *UISysDrawPatches) InitializeUI(world *ecs.World)
InitializeUI the system
func (*UISysDrawPatches) PostUpdateUI ¶
func (s *UISysDrawPatches) PostUpdateUI(world *ecs.World)
PostUpdateUI the system
func (*UISysDrawPatches) UpdateUI ¶
func (s *UISysDrawPatches) UpdateUI(world *ecs.World)
UpdateUI the system
type UISysManagePause ¶
type UISysManagePause struct {
// contains filtered or unexported fields
}
UISysManagePause is a simple system that listens to clicks and pauses the simulation..
func (*UISysManagePause) FinalizeUI ¶
func (s *UISysManagePause) FinalizeUI(world *ecs.World)
FinalizeUI the system
func (*UISysManagePause) InitializeUI ¶
func (s *UISysManagePause) InitializeUI(world *ecs.World)
InitializeUI the system
func (*UISysManagePause) PostUpdateUI ¶
func (s *UISysManagePause) PostUpdateUI(world *ecs.World)
PostUpdateUI the system
func (*UISysManagePause) UpdateUI ¶
func (s *UISysManagePause) UpdateUI(world *ecs.World)
UpdateUI the system
type UISysRepaint ¶
type UISysRepaint struct {
// contains filtered or unexported fields
}
UISysRepaint is a simple system that paints an [Image] resource to a common.Canvas.
func (*UISysRepaint) FinalizeUI ¶
func (s *UISysRepaint) FinalizeUI(world *ecs.World)
FinalizeUI the system
func (*UISysRepaint) InitializeUI ¶
func (s *UISysRepaint) InitializeUI(world *ecs.World)
InitializeUI the system
func (*UISysRepaint) PostUpdateUI ¶
func (s *UISysRepaint) PostUpdateUI(world *ecs.World)
PostUpdateUI the system
func (*UISysRepaint) UpdateUI ¶
func (s *UISysRepaint) UpdateUI(world *ecs.World)
UpdateUI the system
Source Files ¶
- activity_comps.go
- components.go
- doc.go
- resources.go
- run.go
- sys_clear_frame.go
- sys_draw_bees.go
- sys_draw_hives.go
- sys_draw_patches.go
- sys_fleeing.go
- sys_following.go
- sys_foraging.go
- sys_hive_decisions.go
- sys_init_bees.go
- sys_init_hives.go
- sys_patches.go
- sys_pause.go
- sys_repaint.go
- sys_returning.go
- sys_scouting.go
- sys_waggle_dance.go