[Pogamut-list] Determining which team to spawn a bot into during initialization

simon.jakobsen pogamut-forum at diana.ms.mff.cuni.cz
Tue Apr 20 14:54:37 CEST 2010


Re: Determining which team to spawn a bot into during initialization

Author: simon.jakobsen

Thanks for the feedback.

I think that what I had actually done before is the same as what you describe.

I did, however, create the Observer directly through the Factory, without ever calling start or anything on it..

I tried to run it again with observer.start(), without any improvements. I added a global event listener as well:

IUT2004Observer observer = new UT2004ObserverRunner(new UT2004ObserverFactory(), "ObserverTest", "localhost", 3002).startAgent();

IWorldEventListener listObtainedListener = new IWorldEventListener() {
  public void notify(PlayerListObtained event) {
    System.out.println("Received PlayerListObtained event in Observer");
    observedPlayers = event.getPlayers();
    for(Player player :observedPlayers) {
      System.out.println(" player = " + player.getName() + " : " + player.getTeam());
    }
  }
};
IWorldEventListener globalListener = new IWorldEventListener() {
  int updateEvents = 0;

  public void notify(IWorldEvent event) {
    if(!(event instanceof WorldObjectUpdatedEvent && ((WorldObjectUpdatedEvent) event).getObject() instanceof InfoMessage)) {
      System.err.println("event = " + event);
    }
    else if(++updateEvents % 1000 == 0) {
      System.err.println("event = " + event);
    }
  }
};
observer.getWorldView().addEventListener(PlayerListObtained.class, listObtainedListener);
observer.getWorldView().addEventListener(IWorldEvent.class, globalListener);

(I filtered the global listener since the amount of update info messages is astounding :) too bad there's no Code tags in the forum)

In any case, now I see the Observer connecting to the server in the server console and it definitely receives events. I can see in the logs that the bots are happily running around and performing whatever their simple logic can handle.
But I still don't see any PlayerListObtained events, no matter how much I call observer.getAct().act(new GetPlayers()).

Can you see what I'm doing wrong?

(Btw. I reported an issue to the Mantis. Took me a while to figure out why the ObserverRunner caused a show-stopping UnexpectedMessageException, since I assumed that my observer properties would work without manually inserting the host and port in the ObserverRunner constructor. I might have overstepped my bounds by reporting it as a crash, since the Pogamut platform actually quits gracefully. Sorry for that, couldn't edit it)

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=79&post_reply=1#form>





More information about the Pogamut-list mailing list