public class

Area

extends Object
implements HasArea
java.lang.Object
   ↳ uk.ac.imperial.presage2.util.location.area.Area

Class Overview

Represents the simulation area.

Summary

Nested Classes
class Area.Bind Provides various AbstractModules to bind different types of Area
enum Area.Edge  
Fields
protected Map<Area.Edge, EdgeHandler> edgeHandlers
Public Constructors
Area(int x, int y, int z)
Public Methods
void addEdgeHandlers(Map<Area.Edge, EdgeHandler> edgeHandlers)
boolean contains(Location l)
Check if the given Location falls inside of this area.
Area getArea()
Move getValidMove(Location loc, Move m)

If the Move m from Location l results in a Location outside of this area we create and return a modified Move based on the edge-case rules defined for this Area.

[Expand]
Inherited Methods
From class java.lang.Object
From interface uk.ac.imperial.presage2.util.location.area.HasArea

Fields

protected Map<Area.Edge, EdgeHandler> edgeHandlers

Public Constructors

public Area (int x, int y, int z)

Public Methods

public void addEdgeHandlers (Map<Area.Edge, EdgeHandler> edgeHandlers)

public boolean contains (Location l)

Check if the given Location falls inside of this area.

Returns
  • True if l is within the area defined by this Area object, false otherwise.

public Area getArea ()

public Move getValidMove (Location loc, Move m)

If the Move m from Location l results in a Location outside of this area we create and return a modified Move based on the edge-case rules defined for this Area.

The edge rules are defined for all 6 possible edges of the area via EdgeHandlers. We determine which edge has been crossed then invoke the appropriate handler to give us the modified move. By default all edges have an ExceptionEdgeHandler.

Returns
  • if loc.add(m) returns a Location l such that this.contains(l) == false returns a m modified according to the EdgeHandler on the edge which has been crossed. otherwise returns m