예제 #1
0
  /**
   * Restarts a paused robot.
   *
   * <p>Must be called from the robot's main thread.
   */
  public static void reactivate() {
    // If we should die, then... do that.
    if (shouldDie) {
      killer.kill();
    }

    if (bytecodesLeft < 0) {
      bytecodesLeft += BYTECODE_LIMIT;
    } else {
      bytecodesLeft = BYTECODE_LIMIT;
    }
  }
예제 #2
0
  /**
   * Increments the currently active robot's bytecode count by the given amount. If the robot
   * exceeds its bytecode limit for the round, this method will block until the robot's next round.
   * Should be called at the end of every basic block.
   *
   * <p>THIS METHOD IS CALLED BY THE INSTRUMENTER.
   *
   * @param numBytecodes the number of bytecodes the robot just executed
   */
  @SuppressWarnings("unused")
  public static void incrementBytecodes(int numBytecodes) {
    // If we should die, then... do that.
    if (shouldDie) {
      killer.kill();
    }

    bytecodesLeft -= numBytecodes;

    while (bytecodesLeft <= 0) {
      pause();
    }
  }