Skip to content

Commit

Permalink
outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
danny-prodbase committed Sep 8, 2023
1 parent eb30f96 commit 2ee6de0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions outputs/PD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// input parameters - 20 PD 0.5

Num_Iterations - 2.0
SW - 1080.0
13 changes: 10 additions & 3 deletions src/ArgsSerializer/GameArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import Logger.Logger;

import java.util.Random;

/**
* Represents the parsed and validated game parameters.
*/
public record GameArguments(int numberOfAgents, double probability, GameType gameType, float fraction) {
private static final Random random = new Random();
private static final String TO_STRING_PD_TEMPLATE = "%d %s %,.1f";
private static final String TO_STRING_BoS_TEMPLATE = "%d %s %,.1f %,.1f";

// Format string for logging the parsed arguments
private final static String FORMATTED_ARGUMENTS_STRING = "Game arguments: numberOfAgents: %d, probability: %,.1f, gameType: %s, fraction: %s";
Expand All @@ -33,5 +32,13 @@ public GameArguments(int numberOfAgents, double probability, GameType gameType)
public void print(){
logger.info(String.format(FORMATTED_ARGUMENTS_STRING, numberOfAgents, probability, gameType, fraction));
}

@Override
public String toString() {
if(this.gameType() == GameType.PD){
return String.format(TO_STRING_PD_TEMPLATE, numberOfAgents, gameType.getValue(), probability);
}
return String.format(TO_STRING_BoS_TEMPLATE, numberOfAgents, gameType.getValue(), probability, fraction);
}
}

6 changes: 3 additions & 3 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
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 String OUTPUTS_FOLDER = System.getProperty("user.dir") + "/outputs/";
private static final int NUMBER_OF_GAMES = 1;

private static final Logger logger = new Logger("Main");

Expand Down Expand Up @@ -76,7 +76,7 @@ private static void reportResults(GameArguments gameArguments, double totalRawRo
logger.info(numIterations);
logger.info(SW);

String output = "input: " + gameArguments.toString() + numIterations + SW;
String output = "// input parameters - " + gameArguments.toString() + "\n\n" + numIterations + "\n" + SW + "\n";

try {
Files.write(Paths.get(OUTPUTS_FOLDER + gameArguments.gameType() + ".txt"), output.getBytes());
Expand Down

0 comments on commit 2ee6de0

Please sign in to comment.