[Pogamut-list] Finding the flag quickly?
michal.bida
pogamut-forum at diana.ms.mff.cuni.cz
Thu Apr 29 15:05:41 CEST 2010
Re: Finding the flag quickly?
Author: michal.bida
To get the flag bases - points where the flag gets respawned - look in GameInfo object. This object can be retrieved in botInitialized or botSpawned methods.
Now to get the Flags - there will be two flag objects in your WorldView. Flag object class is FlagInfo. Code below inserts all the flags in the game in myFlags HashMap indexed by team number. FlagInfo object will be constantly updated by the Pogamut (note that most of the attributes will be updated only if you see the flag).
{CODE()}
Map myFlags = new HashMap();
@Override
public void botSpawned(GameInfo info, ConfigChange config, InitedMessage init, Self self) {
for (FlagInfo flag : getWorldView().getAll(FlagInfo.class).values()) {
if (myFlags.containsKey(flag.getTeam())) {
getLog().severe("Flag for this team already saved. Bug? " + flag.getTeam());
} else {
getLog().severe("NEWFLAG team:" + flag.getTeam());
myFlags.put(flag.getTeam(), flag);
}
}
} {CODE}
best,
michal
--
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=128&post_reply=1#form>
More information about the Pogamut-list
mailing list