Пример #1
0
  public static void cleanupForRobocodeEngine() {
    // here we cross transition to EngineClassLoader classes using interface which is defined in
    // system classLoader
    RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class);

    main.cleanup();
  }
Пример #2
0
  public static void initContainerForRobocodeEngine(File robocodeHome, IBattleListener listener) {
    try {
      if (robocodeHome == null) {
        robocodeHome = FileUtil.getCwd();
      }
      FileUtil.setCwd(robocodeHome);

      File robotsDir = FileUtil.getRobotsDir();

      if (robotsDir == null) {
        throw new RuntimeException("No valid robot directory is specified");
      } else if (!(robotsDir.exists() && robotsDir.isDirectory())) {
        throw new RuntimeException(
            '\'' + robotsDir.getAbsolutePath() + "' is not a valid robot directory");
      }

    } catch (IOException e) {
      System.err.println(e);
      return;
    }

    // here we cross transition to EngineClassLoader classes using interface which is defined in
    // system classLoader
    RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class);

    main.initForRobocodeEngine(listener);
  }
Пример #3
0
  public static void robocodeMain(Object args) {
    // here we cross transition to EngineClassLoader classes using interface which is defined in
    // system classLoader
    RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class);

    main.loadSetup((String[]) args);

    // Make sure ALL uncaught exceptions are logged
    Thread.setDefaultUncaughtExceptionHandler(
        new UncaughtExceptionHandler() {
          public void uncaughtException(Thread t, Throwable e) {
            Logger.logError("UncaughtException on thread " + t.getClass(), e);
          }
        });

    ThreadGroup group = new ThreadGroup("Robocode thread group");

    new Thread(group, main, "Robocode main thread").start();
  }