statetools

package
v0.0.0-...-0810b70 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Overview

Package statetools implements costfunctions, and tools necessary to replicate some of the globalstate's functionality offline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CostFunction

func CostFunction(s globalstate.State, floor int, dir string) string

CostFunction calculates the best elevator to handle a given order based on the provided state.

func ShouldStopAndPickup

func ShouldStopAndPickup(s globalstate.State, currentFloor int, currentDir string) bool

ShouldStopAndPickup returns true if there are an opportunity to pick up someone in the provided floor.

Types

type LocalState

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

LocalState is a thread safe data structure almost identical to the global state.

func NewLocalState

func NewLocalState() *LocalState

NewLocalState instantiate a new local state ready for use.

func (*LocalState) CloneGlobalstate

func (ls *LocalState) CloneGlobalstate(gs globalstate.State)

CloneGlobalstate clone the entire provided globalstate onto the local state such that the local state is now an exact copy of the global one.

func (*LocalState) GetNextOrder

func (ls *LocalState) GetNextOrder() (floor int, dir string)

GetNextOrder returns the oldest of any buttons on the state that are not in the state "done".

func (*LocalState) GetShareworthyUpdates

func (ls *LocalState) GetShareworthyUpdates() []globalstate.ButtonStatusUpdate

GetShareworthyUpdates dumps all orders in the local state that aren't currently marked as done. For convenience they are returned as an array of button status updates.

func (*LocalState) UpdateButtonStatus

func (ls *LocalState) UpdateButtonStatus(bsu globalstate.ButtonStatusUpdate) error

UpdateButtonStatus is analogous to its counterpart in the globalstate package.

Jump to

Keyboard shortcuts

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