Difference between revisions of "Thread:Talk:RoboRumble/ThreadDeath problem/reply (14)"

From Robowiki
Jump to navigation Jump to search
m (Reply to ThreadDeath problem)
 
m (oops)
 
Line 2: Line 2:
  
 
# I/O robots (bots that read/write from the data directory) [https://github.com/robo-code/robocode/blob/0eb93ba532bc6731b7ff8dd02da1308d92ccb2fd/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java#L76 get 240 skipped turns]. Apparently a robot can get marked as an I/O robot just by calling [https://github.com/robo-code/robocode/blob/0eb93ba532bc6731b7ff8dd02da1308d92ccb2fd/robocode.host/src/main/java/net/sf/robocode/host/proxies/AdvancedRobotProxy.java#L194 <code>getDataDirectory()</code>].
 
# I/O robots (bots that read/write from the data directory) [https://github.com/robo-code/robocode/blob/0eb93ba532bc6731b7ff8dd02da1308d92ccb2fd/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java#L76 get 240 skipped turns]. Apparently a robot can get marked as an I/O robot just by calling [https://github.com/robo-code/robocode/blob/0eb93ba532bc6731b7ff8dd02da1308d92ccb2fd/robocode.host/src/main/java/net/sf/robocode/host/proxies/AdvancedRobotProxy.java#L194 <code>getDataDirectory()</code>].
# This is where things stop making sense. The stacktrace shows <code>RobotPeer.checkSkippedTurn()</code> calling <code>BasicRobotProxy.forceStopThread</code>, but [https://github.com/robo-code/robocode/blob/0eb93ba532bc6731b7ff8dd02da1308d92ccb2fd/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java#L644 the code] shows that it can't happen without going through <code>println("SYSTEM: ...")</code>, there literally is no other code path. Are println() calls getting silently dropped?
+
# This is where things stop making sense. The stacktrace shows <code>RobotPeer.checkSkippedTurn()</code> calling <code>BasicRobotProxy.forceStopThread()</code>, but [https://github.com/robo-code/robocode/blob/0eb93ba532bc6731b7ff8dd02da1308d92ccb2fd/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java#L644 the code] shows that it can't happen without going through <code>println("SYSTEM: ...")</code>, there literally is no other code path. Are <code>println()</code> calls getting silently dropped?
 
# The Robocode main thread can't "skip turns" because it controls the turn counter.
 
# The Robocode main thread can't "skip turns" because it controls the turn counter.
  
Line 35: Line 35:
 
     }
 
     }
 
}
 
}
</syntaxhighlight
+
</syntaxhighlight>

Latest revision as of 18:51, 5 September 2017

For your questions:

  1. I/O robots (bots that read/write from the data directory) get 240 skipped turns. Apparently a robot can get marked as an I/O robot just by calling getDataDirectory().
  2. This is where things stop making sense. The stacktrace shows RobotPeer.checkSkippedTurn() calling BasicRobotProxy.forceStopThread(), but the code shows that it can't happen without going through println("SYSTEM: ..."), there literally is no other code path. Are println() calls getting silently dropped?
  3. The Robocode main thread can't "skip turns" because it controls the turn counter.

Relevant code:

public void checkSkippedTurn() {
    // Store last and current execution time for detecting skipped turns
    lastExecutionTime = currentExecutionTime;
    currentExecutionTime = battle.getTime();

    int numSkippedTurns = (currentExecutionTime - lastExecutionTime) - 1;
    if (numSkippedTurns >= 1) {
        events.get().clear(false);

        if (isAlive()) {
            for (int skippedTurn = lastExecutionTime + 1; skippedTurn < currentExecutionTime; skippedTurn++) {
                addEvent(new SkippedTurnEvent(skippedTurn));
                println("SYSTEM: " + getShortName() + " skipped turn " + skippedTurn);
            }
        }

        if ((!isIORobot && (numSkippedTurns > MAX_SKIPPED_TURNS))
                || (isIORobot && (numSkippedTurns > MAX_SKIPPED_TURNS_WITH_IO))) {
            println("SYSTEM: " + getShortName() + " has not performed any actions in a reasonable amount of time.");
            println("SYSTEM: No score will be generated.");
            setHalt(true);
            waitWakeupNoWait();
            punishBadBehavior(BadBehavior.SKIPPED_TOO_MANY_TURNS);
            robotProxy.forceStopThread();
        }
    }
}