ai

package
v0.0.0-...-8b39f33 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NThinkGroups is the number of think groups.
	NThinkGroups = 6 // At 60 fps, this gives us thinking at 10Hz.
)

Variables

This section is empty.

Functions

func UpdateBoids

func UpdateBoids(nframes uint, boids Boids, p *phys.Body, w *world.World)

UpdateBoids updates the velocity of the boids.

Types

type Boid

type Boid struct {
	*phys.Body

	// ThinkGroup is the number of the group with which this boid
	// considers its local neighbors when updating.
	ThinkGroup uint
}

A Boid is a bird-like (cow-like, or fish-like) object.

type BoidInfo

type BoidInfo struct {
	// MaxVelocity is the fastest that a boid can move.
	MaxVelocity float64

	// LocalDist is the distance determining when two boids
	// are flocking together.
	LocalDist float64

	// MatchBias is multiplied by the velocity matching
	// velocity.
	MatchBias float64

	// CenterDist is the minimum distance a boid must be
	// away from the center before they try to center
	// themselves.
	CenterDist float64

	// CenterBias is multiplied by the centering velocity.
	CenterBias float64

	// AvoidDist is the distance at which boids will avoid
	// eachother.
	AvoidDist float64

	// AvoidBias is multiplied by the avoid velocity.
	AvoidBias float64

	// PlayerDist is the distance at which boids will avoid
	// the player.
	PlayerDist float64

	// PlayerBias is the weight applied to avoiding the player.
	PlayerBias float64

	// TerrainDist is the distance at which terrain is avoided.
	TerrainDist float64

	// TerrainBias is the weight applied to avoiding terrain.
	TerrainBias float64

	// AvoidTerrain is a string of terrain types that are avoided.
	AvoidTerrain string

	// MaxDepth is the maximum water depth before this boid
	// attempts to avoid.
	MaxDepth int
}

BoidInfo contains behavior information about boids. The XxxBias terms are fairly arbitrary weights that are applied to boid rules in order to prioritize them. Unfortunately, the only good way to set them seems to be painful trial-and-error.

type Boids

type Boids interface {
	Len() int
	Boid(int) Boid
	BoidInfo() BoidInfo
}

Boids is a list of boids that may flock together.

Jump to

Keyboard shortcuts

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