Skip to content

Commit

Permalink
add main report to output file
Browse files Browse the repository at this point in the history
  • Loading branch information
danny-prodbase committed Sep 8, 2023
1 parent c71c956 commit 1d117b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Empty file added outputs/.gitkeep
Empty file.
25 changes: 23 additions & 2 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import GameExecutor.*;
import Logger.*;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Main {
private static final String OUTPUTS_FOLDER = System.getProperty("user.dir") + "/runs";
private static final int NUMBER_OF_GAMES = 100;

private static final Logger logger = new Logger("Main");
Expand Down Expand Up @@ -42,8 +47,7 @@ public static void main(String[] args) throws InterruptedException {
}

logger.title("Summarizing results");
logger.info("Num_Iterations: " + (totalRawRounds / NUMBER_OF_GAMES));
logger.info("SW: " + (totalSW / NUMBER_OF_GAMES));
reportResults(gameArguments, totalRawRounds, totalSW);
}

static private void printSingleGameResults(GameExecutorResults results, int gameNumber){
Expand All @@ -64,4 +68,21 @@ public static void printUsage(){
logger.info("Usage: java Main <number_of_agents:int> <probability_of_connection:double> "
+ GameType.BoS.getValue() + " <friction:int>");
}

private static void reportResults(GameArguments gameArguments, double totalRawRounds, double totalSW){
String numIterations = "Num_Iterations - " + (totalRawRounds / NUMBER_OF_GAMES);
String SW = "SW - " + (totalSW / NUMBER_OF_GAMES);

logger.info(numIterations);
logger.info(SW);

String output = "input: " + gameArguments.toString() + numIterations + SW;

try {
Files.write(Paths.get(OUTPUTS_FOLDER + gameArguments.gameType() + ".txt"), output.getBytes());
} catch (IOException e) {
logger.error("File to write to output file");
e.printStackTrace();
}
}
}

0 comments on commit 1d117b4

Please sign in to comment.