cz.cuni.amis.pogamut.ut2004.agent.navigation
Class UT2004PathAutoFixer

Package class diagram package UT2004PathAutoFixer
java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004PathAutoFixer

public class UT2004PathAutoFixer
extends Object

Use with care! This class automatically watching for PATH-STUCKs removing bad-edges directly from navigation graph. Works ONLY IF YOU'RE using FloydWarshallMap ... does not alter map inside UT2004. The class will use UT2004PathExecutor to sense PathExecutorState.STUCKs, if the bot stucks and UT2004PathExecutor.getCurrentLink() is available, this class will assume that this link is causing problems to bot's navigation and will start to count failures when navigating through this link. When number of failures for some link exceeds configured number (removeBadEdgeAfterNFailures, default is: REAMOVE_EDGE_AFTER_N_FAILURES_DEFAULT), it will removeLink(NavPointNeighbourLink) remove it from bot's internal navigation graph. Note that removal of some links requires recomputation of FloydWarshallMap, so you can pass some FloydWarshallMap instance into it to perform auto FloydWarshallMap.refreshPathMatrix() upon link removal.

Author:
Jimmy

Nested Class Summary
static interface UT2004PathAutoFixer.ILinkRemovalListener
           
 
Field Summary
 NavPointNeighbourLink listenerLink
           
 boolean listenersLinkCanRemove
           
static int REAMOVE_EDGE_AFTER_N_FAILURES_DEFAULT
           
 
Constructor Summary
UT2004PathAutoFixer(UT2004Bot bot, IUT2004PathExecutor<? extends ILocated> pathExecutor, FloydWarshallMap fwMap, UT2004AStar aStar, NavigationGraphBuilder navBuilder)
          UT2004PathAutoFixer will remove edge whenever bot fails REAMOVE_EDGE_AFTER_N_FAILURES_DEFAULT times to walk through it.
UT2004PathAutoFixer(UT2004Bot bot, IUT2004PathExecutor<? extends ILocated> pathExecutor, FloydWarshallMap fwMap, UT2004AStar aStar, NavigationGraphBuilder navBuilder, int removeBadEdgeAfterNFailures)
          UT2004PathAutoFixer will remove edge whenever bot fails 'removeBadEdgeAfterNFailures' times to walk through it.
 
Method Summary
 void addListener(UT2004PathAutoFixer.ILinkRemovalListener listener)
           
protected  void botDamaged()
           
protected  void botKilled()
           
 cz.cuni.amis.utils.maps.CountIntMap<NavPointNeighbourLink> getBadLinks()
          Return counts of navigation failures for given links, i.e., map where key == NavPointNeighbourLink, value == how many times bot failed to navigate through the link.
 Set<NavPointNeighbourLink> getRemovedLinks()
          Returns set with all removed links.
protected  void checkRemove(NavPointNeighbourLink link)
          Bot has stuck on 'link', badLinks count has been increased, decide whether to remove the link from the graph.
 boolean isListener(UT2004PathAutoFixer.ILinkRemovalListener listener)
           
protected  void pathComputed()
           
protected  void removeLink(NavPointNeighbourLink link)
          Removes link from the graph + recompute fwMap path matrix.
 void removeListener(UT2004PathAutoFixer.ILinkRemovalListener listener)
           
protected  void stuck()
           
protected  void switchedToNewElement()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REAMOVE_EDGE_AFTER_N_FAILURES_DEFAULT

public static final int REAMOVE_EDGE_AFTER_N_FAILURES_DEFAULT
See Also:
Constant Field Values

listenerLink

public NavPointNeighbourLink listenerLink

listenersLinkCanRemove

public boolean listenersLinkCanRemove
Constructor Detail

UT2004PathAutoFixer

public UT2004PathAutoFixer(UT2004Bot bot,
                           IUT2004PathExecutor<? extends ILocated> pathExecutor,
                           FloydWarshallMap fwMap,
                           UT2004AStar aStar,
                           NavigationGraphBuilder navBuilder)
UT2004PathAutoFixer will remove edge whenever bot fails REAMOVE_EDGE_AFTER_N_FAILURES_DEFAULT times to walk through it.

Parameters:
bot -
pathExecutor -
fwMap - can be null (won't auto-call FloydWarshallMap.refreshPathMatrix() then)
aStar - can be null (won't auto-call UT2004AStar.mapChanged() then)
navBuilder -

UT2004PathAutoFixer

public UT2004PathAutoFixer(UT2004Bot bot,
                           IUT2004PathExecutor<? extends ILocated> pathExecutor,
                           FloydWarshallMap fwMap,
                           UT2004AStar aStar,
                           NavigationGraphBuilder navBuilder,
                           int removeBadEdgeAfterNFailures)
UT2004PathAutoFixer will remove edge whenever bot fails 'removeBadEdgeAfterNFailures' times to walk through it.

Parameters:
bot -
pathExecutor -
fwMap - can be null (won't auto-call FloydWarshallMap.refreshPathMatrix() then)
aStar - can be null (won't auto-call UT2004AStar.mapChanged() then)
navBuilder -
Method Detail

botDamaged

protected void botDamaged()

botKilled

protected void botKilled()

switchedToNewElement

protected void switchedToNewElement()

pathComputed

protected void pathComputed()

stuck

protected void stuck()

checkRemove

protected void checkRemove(NavPointNeighbourLink link)
Bot has stuck on 'link', badLinks count has been increased, decide whether to remove the link from the graph.

Parameters:
link -

removeLink

protected void removeLink(NavPointNeighbourLink link)
Removes link from the graph + recompute fwMap path matrix.

Parameters:
link -

getRemovedLinks

public Set<NavPointNeighbourLink> getRemovedLinks()
Returns set with all removed links.

Returns:

getBadLinks

public cz.cuni.amis.utils.maps.CountIntMap<NavPointNeighbourLink> getBadLinks()
Return counts of navigation failures for given links, i.e., map where key == NavPointNeighbourLink, value == how many times bot failed to navigate through the link.

Returns:

addListener

public void addListener(UT2004PathAutoFixer.ILinkRemovalListener listener)

removeListener

public void removeListener(UT2004PathAutoFixer.ILinkRemovalListener listener)

isListener

public boolean isListener(UT2004PathAutoFixer.ILinkRemovalListener listener)


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.