Пример #1
0
  @Override
  public void logic() throws PogamutException {
    super.logic();
    myInitialize();
    double levelTime = this.game.getTime();
    double speed = this.bot.getVelocity().size();
    double skipTime = 0;
    if (lastTime > 0) {
      skipTime = levelTime - lastTime;
    }
    double distance_estimate = skipTime * speed;
    if (sequence != null && sequence.hasNext()) {
      Point pose;
      if (distance_estimate > 0) {
        pose = sequence.nextByDistance(distance_estimate);
      } else {
        pose = sequence.nextByTime(skipTime);
      }

      Location current = this.getAgentMemory().getAgentLocation().getLocation();
      Location next = pose.getLocation();
      if (next.getDistance(current) > SPACE_DISCONTINUITY) {
        System.out.println("RESPAWN: space discontinuity");
        this.body.getAction().respawn(pose.getLocation(), pose.getRotation());
      } else {
        this.move.moveTo(pose.getLocation());
      }
      System.out.println("current: " + current + " next: " + next);
      System.out.println("level: " + levelTime + " data: " + pose.getT() + " skip: " + skipTime);
    } else {
      if (sequenceIter == null) {
        sequenceIter = sequences.iterator();
      }
      if (sequenceIter.hasNext()) {
        sequence = sequenceIter.next();
        if (sequence.hasNext()) {
          Point pose = sequence.nextByTime(skipTime);
          this.body.getAction().respawn(pose.getLocation(), pose.getRotation());
        }
      }
    }
    lastTime = levelTime;
  }
Пример #2
0
  private void myInitialize() {
    if (initialized) return;
    else initialized = true;
    // reading pose sequences
    File traceHome = new File(Constants.HUMAN_DATA_PATH.get());
    if (this.game == null || this.game.getMapName() == null) {
      this.getLog().severe("Could not find level-specific pose data");
      return;
    }
    File levelSpecificTraceHome = new File(traceHome, this.game.getMapName());
    if (!levelSpecificTraceHome.exists()) {
      this.getLog()
          .log(
              Level.SEVERE,
              "Could not find level-specific pose data for " + this.game.getMapName());
      return;
    }
    File[] subdirs =
        levelSpecificTraceHome.listFiles(
            new FileFilter() {
              public boolean accept(File pathname) {
                return pathname.isDirectory();
              }
            });
    if (subdirs == null) return;
    for (File subdir : subdirs) {
      File[] dataFiles =
          subdir.listFiles(
              new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                  return pathname.getName().endsWith(".dat");
                }
              });

      if (dataFiles != null) {
        for (File dataFile : dataFiles) {
          System.out.println(dataFile.getName());
          try {
            BufferedReader reader = new BufferedReader(new FileReader(dataFile));
            sequences.addAll(PoseSequence.readSequences(reader));
          } catch (FileNotFoundException ex) {
            this.getLog().log(Level.SEVERE, "Data file not found", ex);
          } catch (IOException ioe) {
            this.getLog().log(Level.SEVERE, "Error while reading pose data file", ioe);
          }
        }
      }

      System.out.println("done reading sequences: " + sequences.size() + " in subdir " + subdir);
    }
  }