Skip to content

Commit e0f8633

Browse files
authored
fix: dont log anything if nothing logged by player (#3)
1 parent 68f3cb9 commit e0f8633

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

cpp/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ void output(State &state, Game &game) {
4040

4141
// Player logs are logged to cerr, so that driver will collect it
4242
game.logr().flush();
43-
std::cerr << "TURN " << state.get_turn_no() << '\n';
44-
std::cerr << game.logr().view() << '\n';
45-
std::cerr << "ENDLOG" << std::endl;
43+
if (!game.logr().view().empty()) {
44+
std::cerr << "TURN " << state.get_turn_no() << '\n';
45+
std::cerr << game.logr().view() << '\n';
46+
std::cerr << "ENDLOG" << std::endl;
47+
}
4648

4749
// Game details logged
4850
const auto &spawn_positions = game.get_spawn_positions();

java/Main.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ private static void output(State state, Game game) {
4646

4747
String log = game.getLog();
4848

49-
System.err.println("TURN " + state.getTurnNo());
50-
System.err.println(log);
51-
System.err.println("ENDLOG");
49+
if (!log.isEmpty()) {
50+
System.err.println("TURN " + state.getTurnNo());
51+
System.err.println(log);
52+
System.err.println("ENDLOG");
53+
}
5254

5355
List<SpawnDetail> spawnPositions = game.getSpawnPositions();
5456

python/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def output(state: State, game: Game):
66
log_line = game.get_log()
7-
if log_line:
7+
if log_line and len(log_line)!=0:
88
sys.stderr.write(f"TURN {state.turn_no}\n")
99
sys.stderr.write(log_line)
1010
sys.stderr.write(f"ENDLOG\n")

0 commit comments

Comments
 (0)