avi

package module
v0.0.0-...-1563aef Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2017 License: MIT Imports: 10 Imported by: 0

README

Avi

##How to install

$ mkdir ~/gocode
$ export GOPATH=~/gocode
$ go get github.com/nathanielc/avi

How to run a simulation

$ cd $GOPATH/src/github.com/nathanielc/avi/
$ make build
$ go run avi/avi.go  -logtostderr -ticks 50000 nathanielc/*.yaml

How to view the simulation

The head program needs two packages.

  • protobuf-python
  • panda3d runtime
$ python head/main.py save.avi

Documentation

Index

Constants

View Source
const NilID = math.MaxUint32
View Source
const SecondsPerTick = 1e-3

Variables

View Source
var ErrOutOfEnergy = errors.New("out of energy")
View Source
var NoScanAvalaible = errors.New("No scan available")
View Source
var OutOfAmmoError = errors.New("Out of ammunition")

Functions

func LengthSq

func LengthSq(v mgl64.Vec3) float64

func NewAsteroid

func NewAsteroid(id ID, conf AsteroidConf) (*asteroid, error)

func NewControlPoint

func NewControlPoint(id ID, conf ControlPointConf) (*controlPoint, error)

func PartNotAvailable

func PartNotAvailable(name string) error

func RegisterPilot

func RegisterPilot(pilot string, pf pilotFactory)

Register a ship to make it available

Types

type AsteroidConf

type AsteroidConf struct {
	Mass     float64   `yaml:"mass" json:"mass"`
	Radius   float64   `yaml:"radius" json:"radius"`
	Position []float64 `yaml:"position" json:"position"`
	Texture  string    `yaml:"texture" json:"texture"`
}

type Condition

type Condition struct {
	// Winners reports the names of the winning fleets.
	Winners []string
	Score   float64
	// Reason contains the reason for game end.
	Reason string
}

type ControlPointConf

type ControlPointConf struct {
	Mass      float64   `yaml:"mass" json:"mass"`
	Radius    float64   `yaml:"radius" json:"radius"`
	Position  []float64 `yaml:"position" json:"position"`
	Points    float64   `yaml:"points" json:"points"`
	Influence float64   `yaml:"influence" json:"influence"`
}

type CtlPSR

type CtlPSR struct {
	Position  mgl64.Vec3
	Velocity  mgl64.Vec3
	Radius    float64
	Points    float64
	Influence float64
}

type Drawable

type Drawable interface {
	ID() ID
	Position() mgl64.Vec3
	Radius() float64
	Texture() string
}

type Drawer

type Drawer interface {
	Draw(
		t float64,
		scores map[string]float64,
		new,
		existing []Drawable,
		deleted []ID,
	)
}

type DudPilot

type DudPilot struct {
	GenericPilot
}

func (*DudPilot) Tick

func (*DudPilot) Tick(tick int64)

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine001

func NewEngine001(pos mgl64.Vec3) *Engine

func NewEngineFromConf

func NewEngineFromConf(pos mgl64.Vec3, conf EngineConf) *Engine

func (*Engine) PowerOn

func (self *Engine) PowerOn(power float64) error

type EngineConf

type EngineConf struct {
	Mass   float64 `yaml:"mass" json:"mass"`
	Radius float64 `yaml:"radius" json:"radius"`
	Energy float64 `yaml:"energy" json:"energy"`
}

Conf format for loading engines from a file

type FleetConf

type FleetConf struct {
	Name  string     `yaml:"name" json:"name"`
	Ships []ShipConf `yaml:"ships" json:"ships"`
}

type GenericPilot

type GenericPilot struct {
	Fleet     string
	Engines   []*Engine
	Thrusters []*Thruster
	Weapons   []*Weapon
	Sensors   []*Sensor
}

func (*GenericPilot) JoinFleet

func (self *GenericPilot) JoinFleet(fleet string)

func (*GenericPilot) LinkParts

func (self *GenericPilot) LinkParts(shipParts []ShipPartConf, availableParts PartSetConf) ([]Part, error)

type ID

type ID uint32

type MapConf

type MapConf struct {
	Radius         int64              `yaml:"radius" json:"radius"`
	Asteroids      []AsteroidConf     `yaml:"asteroids" json:"asteroids"`
	ControlPoints  []ControlPointConf `yaml:"control_points" json:"control_points"`
	StartingPoints [][]float64        `yaml:"starting_points" json:"starting_points"`
	Rules          RulesConf          `yaml:"rules" json:"rules"`
}

type Object

type Object interface {
	ID() ID

	Position() mgl64.Vec3

	Velocity() mgl64.Vec3

	Radius() float64
	Mass() float64
	Health() float64
	// contains filtered or unexported methods
}

type Part

type Part interface {
	Object
	// contains filtered or unexported methods
}

type PartSetConf

type PartSetConf struct {
	Engines   map[string]EngineConf   `yaml:"engines" json:"engines"`
	Thrusters map[string]ThrusterConf `yaml:"thrusters" json:"thrusters"`
	Weapons   map[string]WeaponConf   `yaml:"weapons" json:"weapons"`
	Sensors   map[string]SensorConf   `yaml:"sensors" json:"sensors"`
}

type Pilot

type Pilot interface {
	JoinFleet(fleet string)
	LinkParts([]ShipPartConf, PartSetConf) ([]Part, error)
	Tick(int64)
}

func NewDud

func NewDud() Pilot

type RulesConf

type RulesConf struct {
	Score        float64 `yaml:"score" json:"score"`
	MaxFleetMass float64 `yaml:"max_fleet_mass" json:"max_fleet_mass"`
}

type ScanResult

type ScanResult struct {
	Position      mgl64.Vec3
	Velocity      mgl64.Vec3
	Mass          float64
	Radius        float64
	Health        float64
	Ships         map[ID]ShipSR
	ControlPoints map[ID]CtlPSR
	// contains filtered or unexported fields
}

func (ScanResult) Done

func (sr ScanResult) Done()

type Sensor

type Sensor struct {
	// contains filtered or unexported fields
}

func NewSensor001

func NewSensor001(pos mgl64.Vec3) *Sensor

func NewSensorFromConf

func NewSensorFromConf(pos mgl64.Vec3, conf SensorConf) *Sensor

func (*Sensor) Scan

func (self *Sensor) Scan() (ScanResult, error)

type SensorConf

type SensorConf struct {
	Mass   float64 `yaml:"mass" json:"mass"`
	Radius float64 `yaml:"radius" json:"radius"`
	Energy float64 `yaml:"energy" json:"energy"`
	Power  float64 `yaml:"power" json:"power"`
}

Conf format for loading engines from a file

type ShipConf

type ShipConf struct {
	Pilot        string         `yaml:"pilot" json:"pilot"`
	Texture      string         `yaml:"texture" json:"texture"`
	HullStrength float64        `yaml:"hull_strength" json:"hull_strength"`
	Position     []float64      `yaml:"position" json:"position"`
	Parts        []ShipPartConf `yaml:"parts" json:"parts"`
}

type ShipPartConf

type ShipPartConf struct {
	Name     string    `yaml:"name" json:"name"`
	Position []float64 `yaml:"position" json:"position"`
	Type     string    `yaml:"type" json:"type"`
}

type ShipSR

type ShipSR struct {
	Position mgl64.Vec3
	Velocity mgl64.Vec3
	Radius   float64
	Fleet    string
}

type Simulation

type Simulation struct {
	// contains filtered or unexported fields
}

func NewSimulation

func NewSimulation(
	mp MapConf,
	parts PartSetConf,
	fleets []FleetConf,
	stream Drawer,
	maxTime time.Duration,
	fps int64,
) (*Simulation, error)

func (*Simulation) AddShip

func (sim *Simulation) AddShip(fleet string, pos mgl64.Vec3, pilot Pilot, conf ShipConf) (*shipT, error)

func (*Simulation) CorrectedFPS

func (sim *Simulation) CorrectedFPS() float64

func (*Simulation) Start

func (sim *Simulation) Start()

type Thruster

type Thruster struct {
	// contains filtered or unexported fields
}

func NewThruster001

func NewThruster001(pos mgl64.Vec3) *Thruster

func NewThrusterFromConf

func NewThrusterFromConf(pos mgl64.Vec3, conf ThrusterConf) *Thruster

func (*Thruster) GetForce

func (self *Thruster) GetForce() float64

func (*Thruster) Thrust

func (self *Thruster) Thrust(dir mgl64.Vec3) error

Fire the thruster the length of dir indicates how hard to fire the thruster. The length should equal to the accerlation to apply to the ship.

type ThrusterConf

type ThrusterConf struct {
	Mass   float64 `yaml:"mass" json:"mass"`
	Radius float64 `yaml:"radius" json:"radius"`
	Force  float64 `yaml:"force" json:"force"`
	Energy float64 `yaml:"energy" json:"energy"`
}

Conf format for loading thrusters from a file

type Weapon

type Weapon struct {
	// contains filtered or unexported fields
}

func NewWeapon001

func NewWeapon001(pos mgl64.Vec3) *Weapon

func NewWeaponFromConf

func NewWeaponFromConf(pos mgl64.Vec3, conf WeaponConf) *Weapon

func (*Weapon) Fire

func (self *Weapon) Fire(dir mgl64.Vec3) error

func (*Weapon) GetAmmoVel

func (self *Weapon) GetAmmoVel() float64

func (*Weapon) GetCoolDownTicks

func (self *Weapon) GetCoolDownTicks() int64

func (*Weapon) Mass

func (self *Weapon) Mass() float64

type WeaponConf

type WeaponConf struct {
	Mass         float64 `yaml:"mass" json:"mass"`
	Radius       float64 `yaml:"radius" json:"radius"`
	Energy       float64 `yaml:"energy" json:"energy"`
	AmmoVelocity float64 `yaml:"ammo_velocity" json:"ammo_velocity"`
	AmmoMass     float64 `yaml:"ammo_mass" json:"ammo_mass"`
	AmmoCapacity int64   `yaml:"ammo_capacity" json:"ammo_capacity"`
	AmmoRadius   float64 `yaml:"ammo_radius" json:"ammo_radius"`
	Cooldown     float64 `yaml:"cooldown" json:"cooldown"`
}

Conf format for loading weapons from a file

Directories

Path Synopsis
cmd
avi

Jump to

Keyboard shortcuts

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