public class NavigationGraphBuilder extends SensorModule<UT2004Bot>
Note that NavigationGraphBuilder is automatically prefixing all navpoint ids with "mapName.", which means, that you do not
need to specify the id of navpoints as (e.g.) "DM-1on1-Albatross.PathNode2", "PathNode2" suffices. If you want to change this behavior
call setAutoPrefix(boolean)
with "false". Autoprefixing is good as it solves the problem with case-sensitivity
of navpoint ids (i.e., you may run map dm-1on1-albatross as well as DM-1on1-Albatross!), it also makes the work faster as you do not have to repeat
yourself.
Note that even if auto-prefixing enabled you may prefix ids of navpoints with map name, the auto-prefixing implemented by autoPrefix(String)
will detects that and auto-correct upper/lower case of this existing prefix if needed. Also you may use it as a validation feature because
the autoPrefix(String)
will raise an exception if the prefix does not match the current map name.
As all SensorModule
it should be initialized in IUT2004BotController.prepareBot(UT2004Bot)
. Note
that UT2004BotModuleController
has it auto-initialized inside UT2004BotModuleController.initializeModules(UT2004Bot)
.
Modifier and Type | Class and Description |
---|---|
class |
NavigationGraphBuilder.ExistingNavPointEdgeBuilder |
class |
NavigationGraphBuilder.ExistingNavPointModifier
Builder that allows you to modify edges of existing navpoint using
NavigationGraphBuilder.ExistingNavPointModifier.createEdge() ,
NavigationGraphBuilder.ExistingNavPointModifier.createEdgeTo(String) , NavigationGraphBuilder.ExistingNavPointModifier.modifyEdgeTo(String) methods. |
class |
NavigationGraphBuilder.NewNavPointBuilder
Builder encloses the creation of the new navpoint.
|
class |
NavigationGraphBuilder.NewNavPointEdgeBuilder<OWNER>
Represents the edge of the navpoint you're newly creating.
|
worldView
agent, controller, eventBus, log
Constructor and Description |
---|
NavigationGraphBuilder(UT2004Bot bot) |
NavigationGraphBuilder(UT2004Bot bot,
Logger log) |
NavigationGraphBuilder(UT2004Bot bot,
Logger log,
ComponentDependencies dependencies) |
Modifier and Type | Method and Description |
---|---|
void |
apply(MapExport export) |
String |
autoPrefix(String navPointId)
If
isAutoPrefix() is on (== true), it returns 'navPointId' prefixed with "getMapName() .". |
protected void |
cleanUp() |
void |
createSimpleEdge(String fromNavPointId,
String toNavPointId)
Creates simple (non-altered == no flags == no needed jump, etc.) leading 'fromNavPointId' to 'toNavPointId' (only one edge is created).
|
void |
createSimpleEdgesBetween(String firstNavPointId,
String secondNavPointId)
Creates simple (non-altered == no flags == no needed jump, etc.) edges between specified navpoints (in both directions).
|
void |
exportAsXML(File targetXMLFile)
Export full navigation graph into XML into Target File ...
|
String |
getMapName()
Returns name of the map the UT2004 is currently running.
|
String |
getPrefixed(String navPointId)
It returns 'navPointId' prefixed with "
getMapName() .". |
MapExport |
importFromXML(File sourceXMLFile)
Loads navigation graph data ...
|
boolean |
isAutoPrefix()
Whether
NavigationGraphBuilder is auto prefixing all navpoint ids with current map name. |
boolean |
isMapName(String name)
Tells, whether the UT2004 is currently running map with name 'name'.
|
boolean |
isUsed()
Whether this instance has been used to alter navigation graph.
|
NavigationGraphBuilder.ExistingNavPointModifier |
modifyNavPoint(String navPointId)
Creates a modifier for already existing
NavPoint instance, if navpoint of specified id is not found, an exception is thrown. |
NavigationGraphBuilder.NewNavPointBuilder |
newNavPoint()
Creates a builder for the specification of the new navpoint you want to create and insert into the worldview.
|
NavigationGraphBuilder.NewNavPointBuilder |
newNavPoint(String navPointId)
Creates a builder for the specification of the new navpoint you want to create and insert into the worldview.
|
void |
removeEdge(String fromNavPointId,
String toNavPointId)
Deletes edge that is leading from 'fromNavPointId' to 'toNavPointId'.
|
void |
removeEdgesBetween(String firstNavPointId,
String secondNavPointId)
Removes both edges between two specified navpoints.
|
void |
setAutoPrefix(boolean autoPrefix)
Enables (== true), disables (== false) navpoint ids auto prefixing feature.
|
void |
setUsed(boolean used)
Raises / drops "used" flag, see
isUsed() . |
getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString
public NavigationGraphBuilder(UT2004Bot bot)
public NavigationGraphBuilder(UT2004Bot bot, Logger log, ComponentDependencies dependencies)
protected void cleanUp()
cleanUp
in class AgentModule<UT2004Bot>
public String getMapName()
The name is used as a prefix to all IDs in the game. IDs in the world view are case-sensitive!
Note that NavigationGraphBuilder is automatically prefixing all navpoint ids with "mapName.", which means, that you do not
need to specify the id of navpoints as (e.g.) "DM-1on1-Albatross.PathNode2", "PathNode2" suffices. If you want to change this behavior
call setAutoPrefix(boolean)
with "false".
public boolean isMapName(String name)
name
- public boolean isAutoPrefix()
NavigationGraphBuilder
is auto prefixing all navpoint ids with current map name.
As default, auto-prefixing is enabled.
Note that even if auto-prefixing enabled you may prefix ids of navpoints with map name, the auto-prefixing implemented by autoPrefix(String)
will detects that and auto-correct upper/lower case of this existing prefix if needed. Also you may use it as a validation feature because
the autoPrefix(String)
will raise an exception if the prefix does not match the current map name.
public void setAutoPrefix(boolean autoPrefix)
As default, auto-prefixing is enabled.
Note that even if auto-prefixing enabled you may prefix ids of navpoints with map name, the auto-prefixing implemented by autoPrefix(String)
will detects that and auto-correct upper/lower case of this existing prefix if needed. Also you may use it as a validation feature because
the autoPrefix(String)
will raise an exception if the prefix does not match the current map name.
autoPrefix
- public String getPrefixed(String navPointId)
getMapName()
.".
Note that you may pass prefixed navPointId into this method, it will detect it that and auto-correct upper/lower case of this existing prefix if needed.
Also you may use it as a validation feature because
the autoPrefix(String)
will raise an exception if the prefix does not match the current map name.
navPointId
- will be auto-prefixed (if enabled, which is default)public String autoPrefix(String navPointId)
isAutoPrefix()
is on (== true), it returns 'navPointId' prefixed with "getMapName()
.".
Otherwise it just returns 'navPointId' as is.
Uses getPrefixed(String)
for prefixing.
navPointId
- will be auto-prefixed (if enabled, which is default)public NavigationGraphBuilder.NewNavPointBuilder newNavPoint()
Use NavigationGraphBuilder.NewNavPointBuilder.createNavPoint()
when done specifying the navpoint.
public NavigationGraphBuilder.NewNavPointBuilder newNavPoint(String navPointId)
NavigationGraphBuilder.NewNavPointBuilder.setId(String)
for you.
Use NavigationGraphBuilder.NewNavPointBuilder.createNavPoint()
when done specifying the navpoint.
navPointId
- will be auto-prefixed (if enabled, which is default)public NavigationGraphBuilder.ExistingNavPointModifier modifyNavPoint(String navPointId)
NavPoint
instance, if navpoint of specified id is not found, an exception is thrown.
The modifier allows you to change existing edges or add new ones.
navPointId
- will be auto-prefixed (if enabled, which is default)public void createSimpleEdge(String fromNavPointId, String toNavPointId)
If uses NavigationGraphBuilder.ExistingNavPointModifier.modifyEdgeTo(String)
for creation of new edge, so it won't replace an existing edge if such exist.
fromNavPointId
- will be auto-prefixed (if enabled, which is default)toNavPointId
- will be auto-prefixed (if enabled, which is default)public void createSimpleEdgesBetween(String firstNavPointId, String secondNavPointId)
If uses NavigationGraphBuilder.ExistingNavPointModifier.modifyEdgeTo(String)
for creation of new edge, so it won't replace an existing edge if such exist.
firstNavPointId
- will be auto-prefixed (if enabled, which is default)secondNavPointId
- will be auto-prefixed (if enabled, which is default)public void removeEdge(String fromNavPointId, String toNavPointId)
fromNavPointId
- will be auto-prefixed (if enabled, which is default)toNavPointId
- will be auto-prefixed (if enabled, which is default)public void removeEdgesBetween(String firstNavPointId, String secondNavPointId)
firstNavPointId
- will be auto-prefixed (if enabled, which is default)secondNavPointId
- will be auto-prefixed (if enabled, which is default)public boolean isUsed()
FloydWarshallMap
as you will need to FloydWarshallMap.refreshPathMatrix()
after all changes done to the navigation graph.public void setUsed(boolean used)
isUsed()
.used
- public void exportAsXML(File targetXMLFile)
MapExport
where you can use MapExport.getXStream()
.targetXMLFile
- public MapExport importFromXML(File sourceXMLFile)
apply(MapExport)
.sourceXMLFile
- public void apply(MapExport export)
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.