edu.udo.cs.ie.cowbots.util
Class GridMap

Package class diagram package GridMap
java.lang.Object
  extended by edu.udo.cs.ie.cowbots.util.GridMap
Type Parameters:
T - content type

public class GridMap
extends java.lang.Object

basic class to model a two dimensional map. class is preliminary and subject to change!


Nested Class Summary
private  class GridMap.Coordinate
           
 
Field Summary
(package private)  java.util.ArrayList<java.util.ArrayList<GridCell<ELPLiteral>>> gridmap
           
(package private)  int h
           
(package private)  IdentTable idents
           
(package private)  java.util.List<GridMap.Coordinate> movers
           
(package private)  int w
           
 
Constructor Summary
GridMap()
           
 
Method Summary
 ELPLiteral getBgnd(int x, int y)
          returns the type of a cell, or a null pointer.
 GridCell<ELPLiteral> getCell(int x, int y)
           
 ELPLiteral getContent(int x, int y)
          returns the "ison" predicate at a given (x,y) coordinate index
 DistanceMap getDistanceMap(boolean agentsAsObstacles)
          returns the distance map associated with this grid map, and all obstacles are put on the map initially. you may optionally enable other things as obstacles.
 DistanceMap getDistanceMap(boolean agentsAsObstacles, boolean closedFences)
          returns a distance map, but closed fences are treated as obstacles (if 2nd argument set to true).
 int getFenceOpenTime(int x, int y)
           
 ELPLiteral getFlag(int x, int y)
          returns the "isopen" literal at a given location (x,y)
 java.util.List<ELPLiteral> getMoversByType(java.lang.String identPredicate)
          returns a list of all moving objects by a given type
 int height()
          returns the height, in tiles, of this map
 boolean isCorner(int x, int y)
          returns true if a cell has at least two adjacent obstacle or switch cells. used in the contest to prevent clustering cows that are in a corner.
 boolean isFence(int x, int y)
           
 void resetMovers()
          resets all moving entities (removed from map)
 void saveAs(java.lang.String filename)
           
 ELPLiteral setContent(int x, int y, ELPLiteral data)
           
 void setDimension(int x, int y)
           
 void setDimensionContest(int x, int y, int minCX, int minCY, int maxCX, int maxCY)
           
 void setFlag(int x, int y, ELPLiteral data)
           
 void setFlagNewer(int x, int y, ELPLiteral data, int timeTerm)
          this method updates a fence state depending the given data has a greater time value than the present one.
 void setGateState(java.util.List<java.awt.Point> fenceCells, int fenceTimeMax, java.lang.String fenceState)
           
 void setIdentTable(IdentTable it)
           
 void updateMovers(java.util.Collection<ELPLiteral> movingObjects)
          updates cell content with moving entities
 int width()
          returns the width, in tiles, of this map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gridmap

java.util.ArrayList<java.util.ArrayList<GridCell<ELPLiteral>>> gridmap

w

int w

h

int h

movers

java.util.List<GridMap.Coordinate> movers

idents

IdentTable idents
Constructor Detail

GridMap

public GridMap()
Method Detail

setIdentTable

public void setIdentTable(IdentTable it)

setDimension

public void setDimension(int x,
                         int y)

setDimensionContest

public void setDimensionContest(int x,
                                int y,
                                int minCX,
                                int minCY,
                                int maxCX,
                                int maxCY)

setFlag

public void setFlag(int x,
                    int y,
                    ELPLiteral data)

setFlagNewer

public void setFlagNewer(int x,
                         int y,
                         ELPLiteral data,
                         int timeTerm)
this method updates a fence state depending the given data has a greater time value than the present one.

Parameters:
x -
y -
data -
timeTerm -

setContent

public ELPLiteral setContent(int x,
                             int y,
                             ELPLiteral data)

getContent

public ELPLiteral getContent(int x,
                             int y)
returns the "ison" predicate at a given (x,y) coordinate index

Parameters:
x - x-coordinate
y - y-coordinate
Returns:

getBgnd

public ELPLiteral getBgnd(int x,
                          int y)
returns the type of a cell, or a null pointer. returns usefull information only if getContent returned a cow or an agent

Parameters:
x - cell coordinate
y - cell coordinate
Returns:
null or an ELPLiteral describing a cell type (fence, corral)

getFlag

public ELPLiteral getFlag(int x,
                          int y)
returns the "isopen" literal at a given location (x,y)

Parameters:
x - x-coordinate
y - y-coordinate
Returns:
null or isopen-literal

width

public int width()
returns the width, in tiles, of this map

Returns:
width of map

height

public int height()
returns the height, in tiles, of this map

Returns:
height of map

resetMovers

public void resetMovers()
resets all moving entities (removed from map)


updateMovers

public void updateMovers(java.util.Collection<ELPLiteral> movingObjects)
updates cell content with moving entities

Parameters:
movingObjects - collection of moving entities

getCell

public GridCell<ELPLiteral> getCell(int x,
                                    int y)

saveAs

public void saveAs(java.lang.String filename)

getMoversByType

public java.util.List<ELPLiteral> getMoversByType(java.lang.String identPredicate)
returns a list of all moving objects by a given type

Parameters:
identPredicate -
Returns:

getDistanceMap

public DistanceMap getDistanceMap(boolean agentsAsObstacles)
returns the distance map associated with this grid map, and all obstacles are put on the map initially. you may optionally enable other things as obstacles.

Returns:

getDistanceMap

public DistanceMap getDistanceMap(boolean agentsAsObstacles,
                                  boolean closedFences)
returns a distance map, but closed fences are treated as obstacles (if 2nd argument set to true).

Parameters:
agentsAsObstacles -
closedFences -
Returns:

isFence

public boolean isFence(int x,
                       int y)

isCorner

public boolean isCorner(int x,
                        int y)
returns true if a cell has at least two adjacent obstacle or switch cells. used in the contest to prevent clustering cows that are in a corner.

Parameters:
x -
y -
Returns:

getFenceOpenTime

public int getFenceOpenTime(int x,
                            int y)

setGateState

public void setGateState(java.util.List<java.awt.Point> fenceCells,
                         int fenceTimeMax,
                         java.lang.String fenceState)