ai

package
v0.0.0-...-1af4f67 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ai

type Ai struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Ai is a component that represents AI actor. One instance is for one user enemy. This component is independent.

func NewAi

func NewAi(xyFunc func() byte, bewareFunc func(byte) bool) *Ai

NewAi creates a new Ai. Please do not create a Ai directly. "xyFunc" - function to locate an AI actor on the battle field in case of reset "bewareFunc" - function to determine if AI should be scared of a cell with given coordinates

func (*Ai) Init

func (ai *Ai) Init(graph *Graph)

Init initializes AI with a given graph

func (*Ai) Reset

func (ai *Ai) Reset()

Reset clears current path of the AI

func (*Ai) SetCurTool

func (ai *Ai) SetCurTool(value byte)

SetCurTool assigns current tool for the AI "value" - tool ID

func (*Ai) SetDelayedPauseSteps

func (ai *Ai) SetDelayedPauseSteps(steps uint8)

SetDelayedPauseSteps is the same as SetPauseSteps, except that the AI will get paused only AFTER he finishes his current path

func (*Ai) SetPauseSteps

func (ai *Ai) SetPauseSteps(steps uint8)

SetPauseSteps sets delay for the AI in "steps". The AI will do nothing during this time (by default 5 steps stand for 1 sec)

func (*Ai) SetResource

func (ai *Ai) SetResource(idx byte, value bool)

SetResource sets or unsets the resource in a given graph node "idx" - graph node number "value" - TRUE to set the resourse, and FALSE to unset one

func (*Ai) SetTool

func (ai *Ai) SetTool(idx byte, value byte)

SetTool sets or unsets the tool in a given graph node "idx" - graph node number "value" - TRUE to set the tool, and FALSE to unset one

func (*Ai) Step

func (ai *Ai) Step() (idxFrom, idxTo byte, useTool bool, err *Error)

Step performs a single step of AI nolint: gocyclo

type Graph

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

Graph structure represents a graph: set of nodes connected with set of arcs

func (*Graph) AddArc

func (graph *Graph) AddArc(n, direction, pointsTo byte)

AddArc connects a node number "n" with a node number "pointsTo". "direction" means the following: 0 = left 1 = right 2 = up 3 = down

func (*Graph) AddNode

func (graph *Graph) AddNode(n byte, danger byte)

AddNode adds a node with number "n" to the graph. "danger" parameter indicates what resource should be used to eliminate the danger. Pass 0 if the node is not dangerous

func (Graph) GetNode

func (graph Graph) GetNode(n byte) *NodeT

GetNode returns a node by its number

func (Graph) String

func (graph Graph) String() string

String represents a graph in details

type NodeT

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

NodeT represents a single graph node

func (NodeT) GetNext

func (node NodeT) GetNext(direction byte) *NodeT

GetNext returns the next node according to "direction". Directions are the following: 0 = left 1 = right 2 = up 3 = down

func (NodeT) String

func (node NodeT) String() string

String represents a node as a string

Jump to

Keyboard shortcuts

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