Package org.baseagent.grid.textmap
Class TextMapProcessor
java.lang.Object
org.baseagent.grid.textmap.TextMapProcessor
The TextMapProcessor lets you specify layers of grid maps through a text file. You declare legends for those maps, and this TextMapProcessor
also lets you specify transitions from one state to another for elements on the grids.
Create a text file with the following specifications:
- Lines starting with a hash symbol are always considered a comment
- After some initial comments if desired, make sure the file starts by specifying the width and height of the map:
Width = 20
Height = 20
- Now you're ready to draw a map layer. Start by giving a name to the layer, like so:
Layer: GroundLayer
- The name of the layer is the same string that you can use in grid.getLayer(String name)
- Now make a pattern of width * height symbols. You can use spaces between the symbols and the spaces will be ignored,
which may help with visibility of your map.
- Each thing in the layer gets one unique character
- At the end, list your legend. Start a line that says Legend. On the next lines,
for each character that you used in your map, list the letter, followed by a colon, followed by a string representation of that thing's value.
. : empty
B : box
T : tree
- You can then define additional layers
- You can define a layer of double values. Just use space-separated double values instead of text symbols. There is no legend for a doubles layer.
- Conditionals: In your legend, you can list a set of possible values for your symbol based on the status of the same position in other layers:
+ : GroundLayer.water ? raft; GroundLayer.dirt, PheromoneLayer.red ? food
- Immediately after any object value that is meant to be drawn to the screen, you can add a space, a hash, and an RGB value to tell what color the thing should be:
T : SeasonLayer.summer ? leafy-tree #005555; SeasonLayer.autumn ? fall-tree #774400; SeasonLayer.winter ? bare-tree #666666; SeasonLayer.spring ? blossom-tree #997777
- Layers will be drawn to the screen in the order they are presented in the file
This file also contains the ability to create special objects from maps, such as a waypoint network.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDepends on there being a property in the SImulation called SIM_PROPERTY_ALL_GRIDSgenerateGridCanvas
(Simulation sim, boolean isSimulation, Grid grid, int cellWidth, int cellHeight) makeWaypointNetwork
(Grid groundTruthGrid, GridLayer waypointLayer, Predicate<GridPosition> barrierCondition) void
updateGrid
(Grid grid)
-
Field Details
-
COMMENT
- See Also:
-
LAYER
- See Also:
-
LEGEND
- See Also:
-
WIDTH
- See Also:
-
HEIGHT
- See Also:
-
SIM_PROPERTY_ALL_GRIDS
- See Also:
-
WAYPOINT
- See Also:
-
ROOT
- See Also:
-
-
Constructor Details
-
TextMapProcessor
- Throws:
IOException
-
-
Method Details
-
generateGrid
-
generateGridCanvas
public GridCanvas generateGridCanvas(Simulation sim, boolean isSimulation, Grid grid, int cellWidth, int cellHeight) throws IOException - Throws:
IOException
-
generateEnvironment
Depends on there being a property in the SImulation called SIM_PROPERTY_ALL_GRIDS- Throws:
IOException
-
updateGrid
-
makeWaypointNetwork
public Network<GridPosition,Double> makeWaypointNetwork(Grid groundTruthGrid, GridLayer waypointLayer, Predicate<GridPosition> barrierCondition)
-