gamestate

package
v0.0.0-...-95be186 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package gamestate contains information about the current game state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientGameState

type ClientGameState struct {
	// Season represents the current (1-index) season of the game.
	Season uint

	// Turn represents the current (1-index) Turn of the game.
	Turn uint

	// ClientInfo
	ClientInfo ClientInfo

	// AliveStatuses is whether each of the other clients is alive
	ClientLifeStatuses map[shared.ClientID]shared.ClientLifeStatus

	// CommonPool
	CommonPool shared.Resources

	// Island Locations
	Geography disasters.ArchipelagoGeography

	// Islands holding IIGO roles
	SpeakerID   shared.ClientID
	JudgeID     shared.ClientID
	PresidentID shared.ClientID

	// IIGO roles budget (initialised in orchestration.go)
	IIGORolesBudget map[shared.Role]shared.Resources

	// IIGO turns in power (incremented and set by monitoring)
	IIGOTurnsInPower map[shared.Role]uint

	// RuleInfo contains the global rules information for clients to access
	RulesInfo RulesContext
}

ClientGameState contains game state only for a specific client.

type ClientInfo

type ClientInfo struct {
	// Resources contains the amount of resources owned by the client.
	Resources shared.Resources // nice

	LifeStatus shared.ClientLifeStatus
	// CriticalConsecutiveTurnsCounter is the number of consecutive turns the client is in critical state.
	// Client will die if this Counter reaches config.MaxCriticalConsecutiveTurns
	CriticalConsecutiveTurnsCounter uint
}

ClientInfo contains the client struct as well as the client's attributes

func (ClientInfo) Copy

func (c ClientInfo) Copy() ClientInfo

Copy returns a deep copy of the ClientInfo.

type GameState

type GameState struct {
	// Season represents the current (1-index) season of the game.
	Season uint

	// Turn represents the current (1-index) Turn of the game.
	Turn uint

	// CommonPool represents the amount of resources in the common pool.
	CommonPool shared.Resources

	// ClientInfos map from the shared.ClientID to ClientInfo.
	ClientInfos    map[shared.ClientID]ClientInfo
	Environment    disasters.Environment
	DeerPopulation foraging.DeerPopulationModel

	// Foraging History
	ForagingHistory map[shared.ForageType][]foraging.ForagingReport

	// All global rules information
	RulesInfo RulesContext

	// IIGO History: indexed by turn
	IIGOHistory map[uint][]shared.Accountability

	// IIGO roles budget (initialised in orchestration.go)
	IIGORolesBudget map[shared.Role]shared.Resources

	// IIGO turns in power (incremented and set by monitoring)
	IIGOTurnsInPower map[shared.Role]uint

	// IIGO Tax Amount Map
	IIGOTaxAmount map[shared.ClientID]shared.Resources

	// IIGO Allocation Amount Map
	IIGOAllocationMap map[shared.ClientID]shared.Resources

	// IIGO Allocation Made
	IIGOAllocationMade bool

	// IIGO Sanction Amount Map
	IIGOSanctionMap map[shared.ClientID]shared.Resources

	// IIGO Sanction Cache is a record of all sanctions
	IIGOSanctionCache map[int][]shared.Sanction

	// IIGO History Cache is a record of all transgressions for historical retribution
	IIGOHistoryCache map[int][]shared.Accountability

	// IIGO Role Monitoring Cache is used in the IIGO accountability cycle
	IIGORoleMonitoringCache []shared.Accountability

	// Rules broken by islands in this turn
	RulesBrokenByIslands map[shared.ClientID][]string

	// Internal IIGO rules broken by IIGO roles in this turn
	IIGORulesBrokenByRoles map[shared.Role][]string

	// IIGO Role Voting
	IIGOElection []VotingInfo

	// IIGO Run Status
	IIGORunStatus string

	// IITO Transactions
	IITOTransactions map[shared.ClientID]shared.GiftResponseDict

	// Orchestration
	SpeakerID   shared.ClientID
	JudgeID     shared.ClientID
	PresidentID shared.ClientID
}

GameState represents the game's state.

func (GameState) Copy

func (g GameState) Copy() GameState

Copy returns a deep copy of the GameState.

func (*GameState) GetClientGameStateCopy

func (g *GameState) GetClientGameStateCopy(id shared.ClientID) ClientGameState

GetClientGameStateCopy returns the ClientGameState for the client having the id.

func (*GameState) ModifyRule

func (g *GameState) ModifyRule(rulename string, newMatrix mat.Dense, newAuxiliary mat.VecDense) error

func (*GameState) PullRuleIntoPlay

func (g *GameState) PullRuleIntoPlay(rulename string) error

func (*GameState) PullRuleOutOfPlay

func (g *GameState) PullRuleOutOfPlay(rulename string) error

func (*GameState) RegisterNewRule

func (g *GameState) RegisterNewRule(ruleName string, requiredVariables []rules.VariableFieldName, applicableMatrix mat.Dense, auxiliaryVector mat.VecDense, mutable bool, link rules.RuleLink) (constructedMatrix *rules.RuleMatrix, Error error)

func (*GameState) RegisterNewVariable

func (g *GameState) RegisterNewVariable(pair rules.VariableValuePair) error

func (*GameState) UpdateVariable

func (g *GameState) UpdateVariable(variableName rules.VariableFieldName, newValue rules.VariableValuePair) bool

type RulesContext

type RulesContext struct {
	// Map of global variable values
	VariableMap map[rules.VariableFieldName]rules.VariableValuePair

	//Map of All available rules
	AvailableRules map[string]rules.RuleMatrix

	// Rules Currently In Play
	CurrentRulesInPlay map[string]rules.RuleMatrix
}

RulesContext contains the global rules information at any given time

type VotingInfo

type VotingInfo struct {
	RoleToElect  shared.Role
	VotingMethod shared.ElectionVotingMethod
	VoterList    []shared.ClientID
	Votes        [][]shared.ClientID
}

VotingInfo contains all the information necessary to visualise voting

Jump to

Keyboard shortcuts

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