us.asciiroth.client.agents
Class AgentUtils

java.lang.Object
  extended by us.asciiroth.client.agents.AgentUtils

public class AgentUtils
extends java.lang.Object

Function library for various movement and related algorithms.


Constructor Summary
AgentUtils()
           
 
Method Summary
static Item assessAmmo(Event event, Item weaponType, Item returnType)
           
static Direction findPathInDirection(Cell agentLoc, Agent agent, Cell targetCell, Direction direction, Targeting targeting)
          Given targeting information and a desired direction to move in, return a direction that is the closest the agent can get to moving in the desired direction.
static Direction findPathToTarget(Cell agentLoc, Agent agent, Targeting targeting)
          Given targeting information, devise the best possible direction to move.
static Agent getAgentOtherState(Agent agent, State state)
          Convert the agent to the opposite state of the state that is provided to this method.
static Direction getDirectionToCell(Cell origin, Cell target)
          Given two cells, determine the direction that will take you from the origin closer to the target cell.
static Direction getDirectionToCellRangeLimited(Cell origin, Cell target, Targeting targeting)
          Determine a direction toward the provided target cell from the origin cell, accounting for the range specified in the targeting parameter.
static double getDistance(Cell cell1, Cell cell2)
           
static void turnToStone(Cell agentLoc, Agent agent, Color color)
          Turn the agent to stone.
static void updateAdjacent(Context context, int range)
          The player has done something that will change perception of the adjacent cells.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentUtils

public AgentUtils()
Method Detail

assessAmmo

public static Item assessAmmo(Event event,
                              Item weaponType,
                              Item returnType)

findPathInDirection

public static Direction findPathInDirection(Cell agentLoc,
                                            Agent agent,
                                            Cell targetCell,
                                            Direction direction,
                                            Targeting targeting)
Given targeting information and a desired direction to move in, return a direction that is the closest the agent can get to moving in the desired direction.

Parameters:
agentLoc -
agent -
targetCell -
direction -
targeting -
Returns:
the closest direction to the indicated direction that the agent is able to move

findPathToTarget

public static Direction findPathToTarget(Cell agentLoc,
                                         Agent agent,
                                         Targeting targeting)
Given targeting information, devise the best possible direction to move. The targeting parameter object contains many flags for altering both the target and the strategy for alternate targets, etc.

Parameters:
agentLoc -
agent -
targeting -
Returns:
best possible direction (can return null if no direction is appropriate given the targeting strategy of the agent)

getAgentOtherState

public static Agent getAgentOtherState(Agent agent,
                                       State state)
Convert the agent to the opposite state of the state that is provided to this method.

Parameters:
agent -
state -
Returns:
the new agent instance (cached)

getDirectionToCell

public static Direction getDirectionToCell(Cell origin,
                                           Cell target)
Given two cells, determine the direction that will take you from the origin closer to the target cell.

Parameters:
origin -
target -
Returns:
direction from origin to target cell

getDirectionToCellRangeLimited

public static Direction getDirectionToCellRangeLimited(Cell origin,
                                                       Cell target,
                                                       Targeting targeting)
Determine a direction toward the provided target cell from the origin cell, accounting for the range specified in the targeting parameter. This method does adjust direction if there is an obstacle in the way.

Parameters:
origin -
target -
targeting -
Returns:
the direction toward the target cell, or null if the target cell is too far away to target

getDistance

public static double getDistance(Cell cell1,
                                 Cell cell2)

turnToStone

public static void turnToStone(Cell agentLoc,
                               Agent agent,
                               Color color)
Turn the agent to stone. Player resistances may prevent this from occurring (currently both paralysis and stoning resistance apply). The statue generated will use the provided color, which indicates the color event that would cause the statue to revert to a living agent.

Parameters:
agentLoc -
agent -
color -

updateAdjacent

public static void updateAdjacent(Context context,
                                  int range)
The player has done something that will change perception of the adjacent cells. This is essentially like "moving in place".

Parameters:
context -

0.7

2009 Alx Dark