-
Notifications
You must be signed in to change notification settings - Fork 28
/
EventsStatistics.java
52 lines (37 loc) · 1.35 KB
/
EventsStatistics.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package utils;
import java.io.*;
import java.sql.Timestamp;
import java.util.ArrayList;
public class EventsStatistics {
final static String experimentsFolderPath = "res/gamelogs/";
public ArrayList<String> events;
// TODO: Configured for 4 agents by default
public int[] bombPlacementsAttempted = {0, 0, 0, 0};
public int[] bombsPlaced = {0, 0, 0, 0};
public int[] bombsTriggered = {0, 0, 0, 0};
public int[] woodsDestroyed = {0, 0, 0, 0}; // TODO
public int[] powerUpsTaken = {0, 0, 0, 0};
public static int REP = 0;
public EventsStatistics(){
events = new ArrayList<>();
}
public void saveToTextFile(String gameIdStr, long seed){
File file = new File(experimentsFolderPath+ gameIdStr + "/");
if (! file.exists()){
file.mkdir();
}
if (file.listFiles() == null) {
throw new Error("Folder specified at " + experimentsFolderPath + " does not exist nor could be created.");
}
String path = experimentsFolderPath + gameIdStr + "/" + seed + "_" + REP + "_events.txt";
try {
FileWriter writer = new FileWriter(path, true);
for (String event : events){
writer.write(event);
}
writer.close();
} catch (IOException i) {
i.printStackTrace();
}
}
}