infra

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	Run()
	IsAlive() bool
	BaseAgent() *Base
	HandleAskHP(msg messages.AskHPMessage)
	HandleAskFoodTaken(msg messages.AskFoodTakenMessage)
	HandleAskIntendedFoodTaken(msg messages.AskIntendedFoodIntakeMessage)
	HandleRequestLeaveFood(msg messages.RequestLeaveFoodMessage)
	HandleRequestTakeFood(msg messages.RequestTakeFoodMessage)
	HandleResponse(msg messages.BoolResponseMessage)
	HandleStateFoodTaken(msg messages.StateFoodTakenMessage)
	HandleStateHP(msg messages.StateHPMessage)
	HandleStateIntendedFoodTaken(msg messages.StateIntendedFoodIntakeMessage)
}

type Base

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

func NewBaseAgent

func NewBaseAgent(world world.World, agentType int, agentHP int, agentFloor int, id string) (*Base, error)

func (*Base) AgentType

func (a *Base) AgentType() int

func (*Base) BaseAgent

func (a *Base) BaseAgent() *Base

func (*Base) CurrPlatFood

func (a *Base) CurrPlatFood() food.FoodType

only show the food on the platform if the platform is on the same floor as the agent or directly below

func (*Base) DaysAtCritical

func (a *Base) DaysAtCritical() int

func (*Base) Floor

func (a *Base) Floor() int

func (*Base) HP

func (a *Base) HP() int

func (*Base) HandleAskFoodTaken

func (a *Base) HandleAskFoodTaken(msg messages.AskFoodTakenMessage)

func (*Base) HandleAskHP

func (a *Base) HandleAskHP(msg messages.AskHPMessage)

func (*Base) HandleAskIntendedFoodTaken

func (a *Base) HandleAskIntendedFoodTaken(msg messages.AskIntendedFoodIntakeMessage)

func (*Base) HandleRequestLeaveFood

func (a *Base) HandleRequestLeaveFood(msg messages.RequestLeaveFoodMessage)

func (*Base) HandleRequestTakeFood

func (a *Base) HandleRequestTakeFood(msg messages.RequestTakeFoodMessage)

func (*Base) HandleResponse

func (a *Base) HandleResponse(msg messages.BoolResponseMessage)

func (*Base) HandleStateFoodTaken

func (a *Base) HandleStateFoodTaken(msg messages.StateFoodTakenMessage)

func (*Base) HandleStateHP

func (a *Base) HandleStateHP(msg messages.StateHPMessage)

func (*Base) HandleStateIntendedFoodTaken

func (a *Base) HandleStateIntendedFoodTaken(msg messages.StateIntendedFoodIntakeMessage)

func (*Base) HasEaten

func (a *Base) HasEaten() bool

func (*Base) HealthInfo

func (a *Base) HealthInfo() *health.HealthInfo

func (*Base) ID

func (a *Base) ID() string

func (*Base) IsAlive

func (a *Base) IsAlive() bool

func (*Base) Log

func (a *Base) Log(message string, fields ...Fields)

func (*Base) ReceiveMessage

func (a *Base) ReceiveMessage() messages.Message

func (*Base) Run

func (a *Base) Run()

func (*Base) SendMessage

func (a *Base) SendMessage(direction int, msg messages.Message)

func (*Base) TakeFood

func (a *Base) TakeFood(amountOfFood food.FoodType) food.FoodType

type Fields

type Fields = log.Fields

type Tower

type Tower struct {
	Agents map[string]Agent
	// contains filtered or unexported fields
}

func NewTower

func NewTower(maxPlatFood food.FoodType, agentCount,
	agentsPerFloor int, dayInfo *day.DayInfo, healthInfo *health.HealthInfo) *Tower

func (*Tower) AddAgent

func (t *Tower) AddAgent(agent Agent)

func (*Tower) DeadAgents

func (t *Tower) DeadAgents() map[int]int

func (*Tower) Log

func (t *Tower) Log(message string, fields ...Fields)

func (*Tower) ResetTower

func (t *Tower) ResetTower()

func (*Tower) Reshuffle

func (t *Tower) Reshuffle()

This function shuffles the agents by generating a random permutation of agentCount intgers, and maps the integers into floors by dividing each integer by the number of agents per floor. This function does not guarantee that an agent will be moved to a different floor.

func (*Tower) SendMessage

func (t *Tower) SendMessage(direction int, senderFloor int, msg messages.Message)

func (*Tower) Tick

func (t *Tower) Tick()

func (*Tower) TotalAgents

func (t *Tower) TotalAgents() int

func (*Tower) TowerStateLog

func (t *Tower) TowerStateLog(timeOfTick string)

func (*Tower) UpdateDeadAgents

func (t *Tower) UpdateDeadAgents(agentType int)

Jump to

Keyboard shortcuts

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