Exemplo n.º 1
0
  public void run() {

    UT2004ObserverFactory observerFactory =
        new UT2004ObserverFactory(new TestUT2004BotObserverModule());
    UT2004AgentParameters observerParameters =
        new UT2004AgentParameters()
            .setAgentId(new AgentId("observer"))
            .setWorldAddress(new SocketConnectionAddress("localhost", 3002));

    TestUT2004BotObserver observer =
        (TestUT2004BotObserver) observerFactory.newAgent(observerParameters);

    observer.start();
    try {
      FileWriter myFileWriter = new FileWriter(botId + "_" + gameStart + ".txt");
      myFile = new PrintWriter(myFileWriter);

      observer.startObserving(botId, myFile);

      observer.hookListeners();
      System.out.println("Observer Started");

      try {
        Thread.sleep(180000);
      } catch (Exception ex) {
      }

      observer.testMessages();
      observer.stop();
      System.out.println("Observer Stopped");
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      if (observer.inState(IAgentStateUp.class)) {
        observer.kill();
        System.out.println("Observer Killed bc it was in Up State");
        myFile.close();
      }
    }
  }
Exemplo n.º 2
0
  public static void initializeServer() {
    TestControlServer server = TestControlServer.createServer();
    String[][] ids = server.playerNameAndIds();

    for (int i = 0; i < ids.length; i++) {
      System.out.println(ids[i][1]);
      if (ids[i][0].equals(myName)) myId = ids[i][1];
      else if (ids[i][0].equals(opponentName)) {
        opponentId = ids[i][1];
      } else {
        System.out.println("Other Player: " + ids[i][0] + " " + ids[i][1]);
      }
    }

    TestUT2004BotObserver.setNavPoints(server.getWorldView().getAll(NavPoint.class).values());

    System.out.println("My Bot: " + myId);
    System.out.println("Opponent: " + opponentId);
    // server.kick("DM-TrainingDay.GBxBot2");
    server.end();
  }