evolution.actions
Class ActionKnowledgeCatalog

evolution.KnowledgeCatalog
  |
  +--evolution.actions.ActionKnowledgeCatalog

public class ActionKnowledgeCatalog
extends KnowledgeCatalog

The KnowledgeCatalog for evolution.actions.

Stereotype singleton

Field Summary
 protected static ActionKnowledgeCataloginstance
          Instance of the singleton.

Constructor Summary
 protected ActionKnowledgeCatalog(String fileName)
          Create a new KnowledgeCatalog from the given file.

Method Summary
 booleanactionExists(String actionName)
          Does the action with this name exist?
 booleancanBePerformedOn(String actionName, SquareOfLand sq)
          See if this action can be performed on the given square.
 InfoListgetActionsInfo()
          An info list with all possible actions in the game.
 ListgetActionTypes()
          Return a list of all possible actions.
 ActiongetDefaultAction()
          Return an instance of the default action type.
 StringgetDefaultActionType()
          Return the the name for the default action.
 ListgetEnergyBufferActionTypes()
          Return a list of all possible actions while using the energy buffer.
 static ActionKnowledgeCataloggetInst()
          Return the instance of this singleton.
 doublegetPriority(Action action)
          The normal priority for this action.
 ListinfluencedBy(String actionName)
          A list of resources by which this action is influenced.
 static voidinitialize(String fileName)
          Initialize this singleton from the given file.
 Actioninstantiate(String actionName)
          Instantiate the action with the given name on the given square.
 booleanisMaximizing(String actionName)
          See if this action can perform better when the needed landresources are high.
 booleanmustBeExplored(String actionName)
          Check whether the given action must be explored or not.
 protected voidparseActionTypes(String actionTypesString)
          Parse a actiontypes string.
 protected ListparseActionTypesInto(String actionTypesString, List retain)
          Parse a actiontypes string.
 protected voidparseDefaultActionType(String actionTypeString)
          Parse the default actiontype string.
 protected voidparseEnergyBufferActionTypes(String actionTypesString)
          Parse a energy buffer actiontypes string.
 DoubleproducesLandResource(String actionName, String resName)
          Returns the amount produced by the given action of the given land resource.
 MapproducesLandResources(String actionName)
          A map with as keys the landresource and as value the amount the action uses.
 MapproducesResources(String actionName)
          A map with as keys the resource and as value the amount the action uses.
 Mapreveals(Action action)
          A hash of resources/speeds for the given action.
 Object[]transformsLand(SquareOfLand sq, String actionName)
          Does the given action transform the landtype of the given square? Returns Object[] { Boolean transforms : does the action transform yes or no String toLand : the land type we transform to String detLandResource : the determening land resource Double limit : the limit the land resource should have to transform the land type Boolean lte : must the current value be less then equal than the limit Boolean gte : must the current value be greater then equal than the limit
 DoubleusesLandResource(String actionName, String resName)
          Returns the amount used by the given action of the given land resource.
 MapusesLandResources(String actionName)
          A map with as keys the landresource and as value the amount the action uses.
 MapusesResources(String actionName)
          A map with as keys the resource and as value the amount the action uses.

Methods inherited from class evolution.KnowledgeCatalog
dlClassForName, extractArgument, extractName, extractValue, getFileName, getProperty, getProperty, getResourcePath, isInitialized, makeStringDoubleMap, setResourcePath, split, stripPathFromClassName, stripPathFromClassName, stripPathFromClassName

Field Detail

instance

protected static ActionKnowledgeCatalog instance
Instance of the singleton.
Constructor Detail

ActionKnowledgeCatalog

protected ActionKnowledgeCatalog(String fileName)
throws java.io.FileNotFoundException,
java.io.IOException
Create a new KnowledgeCatalog from the given file.
Method Detail

actionExists

public boolean actionExists(String actionName)
Does the action with this name exist?

canBePerformedOn

public boolean canBePerformedOn(String actionName, SquareOfLand sq)
See if this action can be performed on the given square.
Parameters:
actionName - Something like Resting, Fishing, ...

getActionsInfo

public InfoList getActionsInfo()
An info list with all possible actions in the game.

getActionTypes

public List getActionTypes()
Return a list of all possible actions. This is a list of Strings.

getDefaultAction

public Action getDefaultAction()
Return an instance of the default action type. This is cached version.

getDefaultActionType

public String getDefaultActionType()
Return the the name for the default action.

getEnergyBufferActionTypes

public List getEnergyBufferActionTypes()
Return a list of all possible actions while using the energy buffer. This is a list of Strings.

getInst

public static ActionKnowledgeCatalog getInst()
Return the instance of this singleton.

getPriority

public double getPriority(Action action)
The normal priority for this action.

influencedBy

public List influencedBy(String actionName)
A list of resources by which this action is influenced.

initialize

public static void initialize(String fileName)
throws java.io.FileNotFoundException,
java.io.IOException
Initialize this singleton from the given file.

instantiate

public Action instantiate(String actionName)
Instantiate the action with the given name on the given square. precondition: the actionName must be valid

isMaximizing

public boolean isMaximizing(String actionName)
See if this action can perform better when the needed landresources are high.

mustBeExplored

public boolean mustBeExplored(String actionName)
Check whether the given action must be explored or not.

parseActionTypes

protected void parseActionTypes(String actionTypesString)
Parse a actiontypes string.

parseActionTypesInto

protected List parseActionTypesInto(String actionTypesString, List retain)
Parse a actiontypes string.
Parameters:
retain - A List of action names. If this is not null, only the specified actions will be extracted.

parseDefaultActionType

protected void parseDefaultActionType(String actionTypeString)
Parse the default actiontype string.

parseEnergyBufferActionTypes

protected void parseEnergyBufferActionTypes(String actionTypesString)
Parse a energy buffer actiontypes string.

producesLandResource

public Double producesLandResource(String actionName, String resName)
Returns the amount produced by the given action of the given land resource. Returns null if the land resource is not produced by this action.

producesLandResources

public Map producesLandResources(String actionName)
A map with as keys the landresource and as value the amount the action uses.

producesResources

public Map producesResources(String actionName)
A map with as keys the resource and as value the amount the action uses.

reveals

public Map reveals(Action action)
A hash of resources/speeds for the given action.

transformsLand

public Object[] transformsLand(SquareOfLand sq, String actionName)
Does the given action transform the landtype of the given square?
Returns Object[] {
Boolean transforms        : does the action transform yes or no
String toLand             : the land type we transform to
String detLandResource    : the determening land resource
Double limit              : the limit the land resource should have
to transform the land type
Boolean lte               : must the current value be less then equal
than the limit
Boolean gte               : must the current value be greater then equal
than the limit

usesLandResource

public Double usesLandResource(String actionName, String resName)
Returns the amount used by the given action of the given land resource. Returns null if the land resource is not used by this action.

usesLandResources

public Map usesLandResources(String actionName)
A map with as keys the landresource and as value the amount the action uses.

usesResources

public Map usesResources(String actionName)
A map with as keys the resource and as value the amount the action uses.

Association Links

to Class java.util.List

An array of all the loaded actions. These are extracted from the properties list at construction. This is a list of Strings.

to Class java.lang.String

The default actiontype. This is extracted from the properties list at construction.

to Class evolution.actions.Action

A cached version of an instantiated default action.

to Class java.util.List

The actiontypes that can be performed when using the EnergyBuffer. These are extracted from the properties list at construction. This is a list of Strings.

to Class evolution.actions.ActionKnowledgeCatalog

Instance of the singleton.

a gvijf production