private Coordinate runAway(final DungeonLevel currentLevel, final AbstractActor opponent) {
    // Move away from the opponent
    // Compute a vector from the opponent to us; don't bother to normalize it
    final Coordinate origin =
        currentLevel
            .getPosition()
            .add(new Coordinate(currentLevel.getHeight() / 2, currentLevel.getWidth() / 2));
    if (opponent.getPosition().equals(origin)) {
      return self.getPosition().subtract(opponent.getPosition());
    }

    return self.getPosition().subtract(opponent.getPosition()).add(origin);
  }
  @Override
  protected Message updateStateDelegate(
      final ActorFactionData factionData, final DungeonLevel currentLevel) {
    if (opponent == null) {
      return new Message(Command.REST, null, null, null, null);
    }

    // We have reached an exit
    if (currentLevel.getTileRelative(self.getPosition()).getExit() != null) {
      final Direction exit = currentLevel.getTileRelative(self.getPosition()).getExit();
      final DungeonLevel neighbor = currentLevel.getNeighbor(exit);

      // Make sure there is actually room for another NPC
      if (neighbor.getRandomCoordinate() != null) {
        currentLevel.getNonPlayerCharacters().remove(self);
        neighbor.getNonPlayerCharacters().add(self);
      }

      return new Message(exit.toCommand(), null, null, null, null);
    }

    // Run away from the opponent
    final Coordinate destination = getDestination(currentLevel, opponent);
    final Command direction = getDirection(destination, currentLevel);
    return self.processCommand(currentLevel, direction);
  }
  private Coordinate getNearestExit(final DungeonLevel currentLevel) {
    // Move to nearest exit
    final List<Tile> exits = currentLevel.getExits();

    Coordinate nearestExit = null;
    int minDistance = Integer.MAX_VALUE;

    for (final Tile exit : exits) {
      if (exit == null) {
        continue;
      }

      final int dist2 = self.getPosition().distance2(exit.getPosition());
      if (dist2 < minDistance) {
        minDistance = dist2;
        nearestExit = exit.getPosition();
      }
    }

    return nearestExit;
  }