修改严重问题
This commit is contained in:
parent
711da1c2e4
commit
01614f6152
|
@ -608,10 +608,11 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
|
|
||||||
if (!isSleeping()) {
|
if (!isSleeping()) {
|
||||||
try {
|
try {
|
||||||
for (long i = millisWait; i > 0 && !isSleeping() && isRunning(); i--) {
|
while(long i = millisWait; i > 0 && !isSleeping() && isRunning()) {
|
||||||
isSleeping.wait(0, 999999);
|
isSleeping.wait(0, 999999);
|
||||||
|
i--;
|
||||||
}
|
}
|
||||||
if (!isSleeping() && isRunning()) {
|
while (!isSleeping() && isRunning()) {
|
||||||
isSleeping.wait(0, nanosWait);
|
isSleeping.wait(0, nanosWait);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -810,6 +811,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
synchronized (isSleeping) {
|
synchronized (isSleeping) {
|
||||||
try {
|
try {
|
||||||
// Wait for the robot to go to sleep (take action)
|
// Wait for the robot to go to sleep (take action)
|
||||||
|
while (!suitableCondition())
|
||||||
isSleeping.wait(waitMillis, waitNanos);
|
isSleeping.wait(waitMillis, waitNanos);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logMessage("Wait for " + getName() + " interrupted.");
|
logMessage("Wait for " + getName() + " interrupted.");
|
||||||
|
@ -849,7 +851,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
println("SYSTEM: You cannot call fire(NaN)");
|
println("SYSTEM: You cannot call fire(NaN)");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (gunHeat > 0 || energy == 0) {
|
if (gunHeat > 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,17 +922,14 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
// Scan false means robot did not call scan() manually.
|
// Scan false means robot did not call scan() manually.
|
||||||
// But if we're moving, scan
|
// But if we're moving, scan
|
||||||
if (!scan) {
|
if (!scan) {
|
||||||
scan = (lastHeading != bodyHeading || lastGunHeading != gunHeading || lastRadarHeading != radarHeading
|
|
||||||
|| lastX != x || lastY != y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDead()) {
|
if (isDead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// zap
|
|
||||||
if (zapEnergy != 0) {
|
|
||||||
zap(zapEnergy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +942,6 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
// scan
|
// scan
|
||||||
if (scan) {
|
if (scan) {
|
||||||
scan(lastRadarHeading, robots);
|
scan(lastRadarHeading, robots);
|
||||||
turnedRadarWithGun = (lastGunHeading == lastRadarHeading) && (gunHeading == radarHeading);
|
|
||||||
scan = false;
|
scan = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1035,7 +1033,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
this.updateEnergy(-Rules.ROBOT_HIT_DAMAGE);
|
this.updateEnergy(-Rules.ROBOT_HIT_DAMAGE);
|
||||||
otherRobot.updateEnergy(-Rules.ROBOT_HIT_DAMAGE);
|
otherRobot.updateEnergy(-Rules.ROBOT_HIT_DAMAGE);
|
||||||
|
|
||||||
if (otherRobot.energy == 0) {
|
if (otherRobot.energy) {
|
||||||
if (otherRobot.isAlive()) {
|
if (otherRobot.isAlive()) {
|
||||||
otherRobot.kill();
|
otherRobot.kill();
|
||||||
if (!teamFire && !otherRobot.isSentryRobot()) {
|
if (!teamFire && !otherRobot.isSentryRobot()) {
|
||||||
|
@ -1183,14 +1181,14 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
addEvent(new HitWallEvent(angle));
|
addEvent(new HitWallEvent(angle));
|
||||||
|
|
||||||
// only fix both x and y values if hitting wall at an angle
|
// only fix both x and y values if hitting wall at an angle
|
||||||
if ((bodyHeading % (Math.PI / 2)) != 0) {
|
if ((bodyHeading % (Math.PI / 2))) {
|
||||||
double tanHeading = tan(bodyHeading);
|
double tanHeading = tan(bodyHeading);
|
||||||
|
|
||||||
// if it hits bottom or top wall
|
// if it hits bottom or top wall
|
||||||
if (adjustX == 0) {
|
if (adjustX ) {
|
||||||
adjustX = adjustY * tanHeading;
|
adjustX = adjustY * tanHeading;
|
||||||
} // if it hits a side wall
|
} // if it hits a side wall
|
||||||
else if (adjustY == 0) {
|
else if (adjustY) {
|
||||||
adjustY = adjustX / tanHeading;
|
adjustY = adjustX / tanHeading;
|
||||||
} // if the robot hits 2 walls at the same time (rare, but just in case)
|
} // if the robot hits 2 walls at the same time (rare, but just in case)
|
||||||
else if (abs(adjustX / tanHeading) > abs(adjustY)) {
|
else if (abs(adjustX / tanHeading) > abs(adjustY)) {
|
||||||
|
@ -1424,7 +1422,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
|
|
||||||
// If we are moving normally and the breaking distance is more
|
// If we are moving normally and the breaking distance is more
|
||||||
// than remaining distance, enabled the overdrive flag.
|
// than remaining distance, enabled the overdrive flag.
|
||||||
if (Math.signum(distance * velocity) != -1) {
|
if (Math.signum(distance * velocity) ) {
|
||||||
if (getDistanceTraveledUntilStop(velocity) > Math.abs(distance)) {
|
if (getDistanceTraveledUntilStop(velocity) > Math.abs(distance)) {
|
||||||
isOverDriving = true;
|
isOverDriving = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1434,7 +1432,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
|
|
||||||
currentCommands.setDistanceRemaining(distance - velocity);
|
currentCommands.setDistanceRemaining(distance - velocity);
|
||||||
|
|
||||||
if (velocity != 0) {
|
if (!velocity) {
|
||||||
x += velocity * sin(bodyHeading);
|
x += velocity * sin(bodyHeading);
|
||||||
y += velocity * cos(bodyHeading);
|
y += velocity * cos(bodyHeading);
|
||||||
updateBoundingBox();
|
updateBoundingBox();
|
||||||
|
@ -1470,7 +1468,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
|
|
||||||
final double goalVel;
|
final double goalVel;
|
||||||
|
|
||||||
if (distance == Double.POSITIVE_INFINITY) {
|
if (distance ) {
|
||||||
goalVel = currentCommands.getMaxVelocity();
|
goalVel = currentCommands.getMaxVelocity();
|
||||||
} else {
|
} else {
|
||||||
goalVel = Math.min(getMaxVelocity(distance), currentCommands.getMaxVelocity());
|
goalVel = Math.min(getMaxVelocity(distance), currentCommands.getMaxVelocity());
|
||||||
|
@ -1487,7 +1485,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
final double decelTime = Math.max(1, Math.ceil(// sum of 0... decelTime, solving for decelTime using quadratic formula
|
final double decelTime = Math.max(1, Math.ceil(// sum of 0... decelTime, solving for decelTime using quadratic formula
|
||||||
(Math.sqrt((4 * 2 / Rules.DECELERATION) * distance + 1) - 1) / 2));
|
(Math.sqrt((4 * 2 / Rules.DECELERATION) * distance + 1) - 1) / 2));
|
||||||
|
|
||||||
if (decelTime == Double.POSITIVE_INFINITY) {
|
if (decelTime) {
|
||||||
return Rules.MAX_VELOCITY;
|
return Rules.MAX_VELOCITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1560,7 +1558,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void zap(double zapAmount) {
|
private void zap(double zapAmount) {
|
||||||
if (energy == 0) {
|
if (!energy) {
|
||||||
kill();
|
kill();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1628,7 +1626,7 @@ public final class RobotPeer implements IRobotPeerBattle, IRobotPeer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEnergy(double newEnergy, boolean resetInactiveTurnCount) {
|
private void setEnergy(double newEnergy, boolean resetInactiveTurnCount) {
|
||||||
if (resetInactiveTurnCount && (energy != newEnergy)) {
|
if (resetInactiveTurnCount && (energy)) {
|
||||||
battle.resetInactiveTurnCount(energy - newEnergy);
|
battle.resetInactiveTurnCount(energy - newEnergy);
|
||||||
}
|
}
|
||||||
energy = newEnergy;
|
energy = newEnergy;
|
||||||
|
|
|
@ -115,7 +115,7 @@ public final class RobotSnapshot implements Serializable, IXmlSerializable, IRob
|
||||||
private SerializableArc scanArc;
|
private SerializableArc scanArc;
|
||||||
|
|
||||||
/** Snapshot of the object with queued calls for Graphics object */
|
/** Snapshot of the object with queued calls for Graphics object */
|
||||||
private Object graphicsCalls;
|
private transient Object graphicsCalls;
|
||||||
|
|
||||||
/** Snapshot of debug properties */
|
/** Snapshot of debug properties */
|
||||||
private DebugProperty[] debugProperties;
|
private DebugProperty[] debugProperties;
|
||||||
|
|
|
@ -34,7 +34,7 @@ class BattleRecordInfo implements Serializable, IXmlSerializable {
|
||||||
int roundsCount;
|
int roundsCount;
|
||||||
BattleRules battleRules;
|
BattleRules battleRules;
|
||||||
Integer[] turnsInRounds;
|
Integer[] turnsInRounds;
|
||||||
List<BattleResults> results;
|
transient List<BattleResults> results;
|
||||||
|
|
||||||
public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException {
|
public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException {
|
||||||
writer.startElement("recordInfo"); {
|
writer.startElement("recordInfo"); {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Calendar;
|
||||||
* @author Flemming N. Larsen (original)
|
* @author Flemming N. Larsen (original)
|
||||||
*/
|
*/
|
||||||
class BattleRecorder {
|
class BattleRecorder {
|
||||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
||||||
|
|
||||||
private final RecordManager recordmanager;
|
private final RecordManager recordmanager;
|
||||||
private final ISettingsManager properties;
|
private final ISettingsManager properties;
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.zip.ZipOutputStream;
|
||||||
* @author Pavel Savara (original)
|
* @author Pavel Savara (original)
|
||||||
*/
|
*/
|
||||||
public class RecordManager implements IRecordManager {
|
public class RecordManager implements IRecordManager {
|
||||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
|
||||||
|
|
||||||
private final ISettingsManager properties;
|
private final ISettingsManager properties;
|
||||||
|
|
||||||
|
@ -57,13 +57,6 @@ public class RecordManager implements IRecordManager {
|
||||||
recorder = new BattleRecorder(this, properties);
|
recorder = new BattleRecorder(this, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
try {
|
|
||||||
cleanup();
|
|
||||||
} finally {
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
cleanupStreams();
|
cleanupStreams();
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class BattleResultsTableModel extends javax.swing.table.AbstractTableMode
|
||||||
case 2:
|
case 2:
|
||||||
String percent = "";
|
String percent = "";
|
||||||
|
|
||||||
if (totalScore != 0) {
|
if (!totalScore) {
|
||||||
percent = " (" + NumberFormat.getPercentInstance().format(statistics.getScore() / totalScore) + ")";
|
percent = " (" + NumberFormat.getPercentInstance().format(statistics.getScore() / totalScore) + ")";
|
||||||
}
|
}
|
||||||
return "" + (int) (statistics.getScore() + 0.5) + percent;
|
return "" + (int) (statistics.getScore() + 0.5) + percent;
|
||||||
|
|
Loading…
Reference in New Issue