Skip to content

Commit 72e7147

Browse files
committed
debugging commit
1 parent 1289a23 commit 72e7147

5 files changed

Lines changed: 64 additions & 1 deletion

File tree

src/main/java/bwapi/Cache.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ boolean valid(int currentFrame) {
1717
T get() {
1818
return obj;
1919
}
20+
21+
@Override
22+
public String toString() {
23+
return obj != null ? obj.toString() : "null";
24+
}
2025
}
2126

2227
class IntegerCache extends Cache<Integer> {

src/main/java/bwapi/CommandTemp.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package bwapi;
22

3+
import java.util.Arrays;
4+
35
/**
46
* Latency Compensation:
57
* Only need to implement LatCom for current frame, the server updates the next frame already if latcom is enabled.
@@ -722,8 +724,11 @@ void execute(boolean isCurrentFrame) {
722724
}
723725

724726
// Happens on RLF + 1, we want to pretend this happens on RLF.
727+
System.out.println("getTrainingQueueCount: " + unit.getTrainingQueueCount());
728+
System.out.println("before: " + Arrays.toString(unit.self().trainingQueue) + ", " + unit.self().trainingQueueCount);
725729
unit.self().trainingQueue[unit.getTrainingQueueCount()].set(unitType, frame);
726730
unit.self().trainingQueueCount.setOrAdd(+1, frame);
731+
System.out.println("after: " + Arrays.toString(unit.self().trainingQueue) + ", " + unit.self().trainingQueueCount);
727732
player.self().supplyUsed[unitType.getRace().id]
728733
.setOrAdd(unitType.supplyRequired(), frame);
729734

src/main/java/bwapi/Game.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ void addUnitCommand(final int type, final int unit, final int target, final int
312312
unitCommand.setX(x);
313313
unitCommand.setY(y);
314314
unitCommand.setExtra(extra);
315+
System.out.println("added UnitCommand: " + unitCommand.getTid());
315316
}
316317

317318
void addCommand(final CommandType type, final int value1, final int value2) {

src/main/java/bwapi/Unit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ public UnitType getBuildType() {
836836
*/
837837
public List<UnitType> getTrainingQueue() {
838838
return IntStream.range(0, getTrainingQueueCount())
839-
.mapToObj(i -> game.isLatComEnabled() && self().trainingQueue[i].valid(game.getFrameCount()) ?
839+
.mapToObj(i -> game.isLatComEnabled() && self().trainingQueueCount.valid(game.getFrameCount()) ?
840840
self().trainingQueue[i].get() :
841841
UnitType.idToEnum[unitData.getTrainingQueue(i)])
842842
.collect(Collectors.toList());
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package game;
2+
3+
import bwapi.*;
4+
5+
import java.util.List;
6+
import java.util.stream.Collectors;
7+
8+
class TrainingQueueTest extends DefaultBWListener {
9+
final BWClient bwClient;
10+
Game game;
11+
int mineralsReq = 250;
12+
int workers = 1;
13+
14+
TrainingQueueTest() {
15+
bwClient = new BWClient(this);
16+
bwClient.startGame();
17+
}
18+
19+
public void onStart() {
20+
game = bwClient.getGame();
21+
game.enableFlag(Flag.UserInput);
22+
game.setLocalSpeed(0);
23+
//game.setLatCom(false);
24+
}
25+
26+
@Override
27+
public void onFrame() {
28+
List<Unit> minerals = game.getMinerals().stream().filter(Unit::isVisible).collect(Collectors.toList());
29+
if (game.self().minerals() >= 230) {
30+
game.setLocalSpeed(20);
31+
}
32+
for (Unit unit : game.self().getUnits()) {
33+
UnitType type = unit.getType();
34+
35+
if (type.isWorker() && unit.isIdle()) {
36+
unit.gather(minerals.get(unit.getID() % minerals.size()));
37+
}
38+
else if (type.isResourceDepot() && game.self().minerals() >= mineralsReq) {
39+
System.out.println("######## FRAME " + game.getFrameCount() + " ########");
40+
unit.train(game.self().getRace().getWorker());
41+
System.out.println("training worker: " + workers);
42+
mineralsReq -= 50;
43+
workers += 1;
44+
System.out.println("trainingQueue: " + unit.getTrainingQueue());
45+
}
46+
}
47+
}
48+
49+
public static void main(String[] args) {
50+
new TrainingQueueTest();
51+
}
52+
}

0 commit comments

Comments
 (0)