Forum: General

Make multiple bots go to one NavPoint?

Hi there,

I have this code:

Collection navPoints = tabooNavPoints.filter(getWorldView().getAll(NavPoint.class).values());

Iterator itr = navPoints.iterator();
NavPoint target = null;
while(itr.hasNext())
{
NavPoint temp = (NavPoint)itr.next();
String id = temp.getId().getStringId();
if(id.equals("UTCTFRedFlagBase_2")) //The Goal
{
return temp;
}
}

So I iterate through the navpoints, but I've noticed the collection seems to change, it usually have a size of 548, but this goes down. Does anyone know why the navPoint count would go down? Is there a better way to make bots go to a specific navpoint?
> Hi there,
>
> I have this code:
>
> Collection navPoints = tabooNavPoints.filter(getWorldView().getAll(NavPoint.class).values());

The count goes down, because you are using TabooSet and you are filtering through it in the line above. If the set is not empty, all nav points in the TabooSet won't be in the Collection - they will be filtered. Review your code and find places where you are adding NavPoints to TabooSet - those will be your missing navpoints.
Generally it is a good idea to use some kind of TabooSet to prevent bot from periodically picking the same navigation point.