コード例 #1
0
  public SoarTaxi(Taxi taxi, Agent agent, String[] shutdown_commands) {
    this.player = taxi;
    this.agent = agent;
    this.shutdownCommands = shutdown_commands;

    agent.SetBlinkIfNoChange(false);

    input = new SoarTaxiIL(agent);
    input.create();

    if (!agent.Commit()) {
      Gridmap2D.control.errorPopUp(Names.Errors.commitFail + taxi.getName());
    }
  }
コード例 #2
0
 public void shutdown() {
   assert agent != null;
   if (shutdownCommands != null) {
     // execute the pre-shutdown commands
     for (String command : shutdownCommands) {
       String result = player.getName() + ": result: " + agent.ExecuteCommandLine(command, true);
       logger.info(player.getName() + ": shutdown command: " + command);
       if (agent.HadError()) {
         Gridmap2D.control.errorPopUp(result);
       } else {
         logger.info(player.getName() + ": result: " + result);
       }
     }
   }
 }
コード例 #3
0
  public void reset() {
    if (agent == null) {
      return;
    }

    input.destroy();

    if (!agent.Commit()) {
      Gridmap2D.control.errorPopUp(Names.Errors.commitFail + player.getName());
      Gridmap2D.control.stopSimulation();
    }

    agent.InitSoar();

    input.create();

    if (!agent.Commit()) {
      Gridmap2D.control.errorPopUp(Names.Errors.commitFail + player.getName());
      Gridmap2D.control.stopSimulation();
    }
  }
コード例 #4
0
  public void update(TaxiMap taxiMap) {
    input.update(
        player.getMoved(),
        player.getLocation(),
        taxiMap,
        player.getPointsDelta(),
        player.getFuel());

    if (!agent.Commit()) {
      Gridmap2D.control.errorPopUp(Names.Errors.commitFail + player.getName());
      Gridmap2D.control.stopSimulation();
    }
  }
コード例 #5
0
  public CommandInfo nextCommand() {
    // if there was no command issued, that is kind of strange
    if (agent.GetNumberCommands() == 0) {
      if (logger.isDebugEnabled()) {
        logger.debug(player.getName() + " issued no command.");
      }
      return new CommandInfo();
    }

    // go through the commands
    // see move info for details
    CommandInfo move = new CommandInfo();
    boolean moveWait = false;
    if (agent.GetNumberCommands() > 1) {
      logger.debug(
          player.getName()
              + ": "
              + agent.GetNumberCommands()
              + " commands detected, all but the first will be ignored");
    }
    for (int i = 0; i < agent.GetNumberCommands(); ++i) {
      Identifier commandId = agent.GetCommand(i);
      String commandName = commandId.GetAttribute();

      if (commandName.equalsIgnoreCase(Names.kMoveID)) {
        if (move.move || moveWait) {
          logger.debug(player.getName() + ": multiple move commands detected");
          commandId.AddStatusError();
          continue;
        }
        move.move = true;

        String direction = commandId.GetParameterValue(Names.kDirectionID);
        if (direction != null) {
          if (direction.equals(Names.kNone)) {
            // legal wait
            move.move = false;
            moveWait = true;
            commandId.AddStatusComplete();
            continue;
          } else {
            move.moveDirection = Direction.parse(direction);
            commandId.AddStatusComplete();
            continue;
          }
        }

      } else if (commandName.equalsIgnoreCase(Names.kStopSimID)) {
        if (move.stopSim) {
          logger.debug(player.getName() + ": multiple stop commands detected, ignoring");
          commandId.AddStatusError();
          continue;
        }
        move.stopSim = true;
        commandId.AddStatusComplete();
        continue;

      } else if (commandName.equalsIgnoreCase(Names.kPickUpID)) {
        if (move.pickup) {
          logger.debug(
              player.getName() + ": multiple " + Names.kPickUpID + " commands detected, ignoring");
          commandId.AddStatusError();
          continue;
        }
        move.pickup = true;
        commandId.AddStatusComplete();
        continue;

      } else if (commandName.equalsIgnoreCase(Names.kPutDownID)) {
        if (move.putdown) {
          logger.debug(
              player.getName() + ": multiple " + Names.kPutDownID + " commands detected, ignoring");
          commandId.AddStatusError();
          continue;
        }
        move.putdown = true;
        commandId.AddStatusComplete();
        continue;

      } else if (commandName.equalsIgnoreCase(Names.kFillUpID)) {
        if (move.fillup) {
          logger.debug(
              player.getName() + ": multiple " + Names.kFillUpID + " commands detected, ignoring");
          commandId.AddStatusError();
          continue;
        }
        move.fillup = true;
        commandId.AddStatusComplete();
        continue;

      } else {
        logger.warn("Unknown command: " + commandName);
        commandId.AddStatusError();
        continue;
      }

      logger.warn("Improperly formatted command: " + commandName);
      commandId.AddStatusError();
    }
    agent.ClearOutputLinkChanges();

    if (!agent.Commit()) {
      Gridmap2D.control.errorPopUp(Names.Errors.commitFail + player.getName());
      Gridmap2D.control.stopSimulation();
    }

    return move;
  }