-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAiMain2048.java
More file actions
55 lines (46 loc) · 1.23 KB
/
Copy pathAiMain2048.java
File metadata and controls
55 lines (46 loc) · 1.23 KB
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
53
54
55
import javax.swing.JOptionPane;
public class AiMain2048 {
public static boolean going = true;
public static void main(String[] args) {
final int numIterations = 100;
int totScores[] = {0, 0, 0};
int totMax[] = {0, 0, 0};
String filePath = JOptionPane.showInputDialog("Enter a directory for the nerual net values to be stored");
while(filePath.equals("")) {
}
Speak s = new Speak();
s.start();
//System.out.print("test");
for (int j = 0 ; j < 3 ; j++) {
for (int i = 0 ; i < numIterations ; i++) {
TwoThousandFourtyEight board = new TwoThousandFourtyEight(4, 4);
switch(j) {
case 0:
Ai2048.playLeft(board);
break;
case 1:
Ai2048.playRandom(board);
break;
case 2:
Ai2048.playAI(board, filePath);
break;
}
totScores[j] += board.getScore();
totMax[j] += board.getHighestTile();
}
switch(j) {
case 0:
System.out.print("Left: ");
break;
case 1:
System.out.print("Random: ");
break;
case 2:
System.out.print("AI: ");
break;
}
System.out.println(totScores[j]/numIterations + " average points achieved; " + totMax[j]/numIterations + " average maximum tile achieved.");
}
going = false;
}
}