Class TextMapProcessor

java.lang.Object
org.baseagent.grid.textmap.TextMapProcessor

public class TextMapProcessor extends Object
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.