This simple example for Protoss builds a probe and checks if the unit type in the training queue is actually a probe. It's toString() returns probe but it is another object:
import bwapi.*;
public class UnitTypeBug extends DefaultBWListener {
private Mirror mirror = new Mirror();
private Game game;
private Player self;
public void run() {
mirror.getModule().setEventListener(this);
mirror.startGame();
}
@Override
public void onStart() {
game = mirror.getGame();
self = game.self();
}
@Override
public void onFrame() {
for (Unit u: self.getUnits()) {
if (!u.getTrainingQueue().isEmpty()) {
if (u.getTrainingQueue().get(0) != UnitType.Protoss_Probe) {
System.err.println("Unit type mismatch");
}
}
if (!u.isTraining() || u.canTrain(UnitType.Protoss_Probe)) {
u.train(UnitType.Protoss_Probe);
}
}
}
public static void main(String[] args) {
new UnitTypeBug().run();
}
}
It should not print "Unit type mismatch", but it does,
This simple example for Protoss builds a probe and checks if the unit type in the training queue is actually a probe. It's
toString()
returns probe but it is another object:It should not print "Unit type mismatch", but it does,