-
Notifications
You must be signed in to change notification settings - Fork 0
/
Driver.java
73 lines (66 loc) · 2.21 KB
/
Driver.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/****************************************
* Name: Takuya Gerret Kubota *
* Project #: 2 (N-Queens Problem) *
* CS 420 *
*****************************************/
import java.util.Scanner;
public class Driver{
public static void main(String[] args){
String input = "";
Scanner kb = new Scanner(System.in);
char c;
do{
boolean stat = true;
int count = 100;
int solved = 0;
double minAverage = 0.0;
double steepestAverage = 0;
//long result = 0;
System.out.println("|------Average Time Menu------|" +
"\n1) Average time for Steepest Hill Algorithm." +
"\n2) Average time for Min-Conflicts Algorithm." +
"\n3) Exit.");
System.out.print("input> ");
c = kb.nextLine().charAt(0);
switch(c){
case '1':
for(int i = count; i > 0; i--){
NQueen n = new NQueen();
System.out.println("|-------Initial Board------|");
n.print();
long startTime = System.currentTimeMillis();
n.steepest();
long endTime = System.currentTimeMillis();
long result = (endTime - startTime);
System.out.println("Time: " + result + " milliseconds.");
steepestAverage += result;
solved += n.getSolved();
}
System.out.println("Steepest Hill Algorithm");
System.out.println("Average time took: " + (steepestAverage/100) + " milliseconds.");
System.out.println((((double)solved/100) * 100) + "% of it was solved.");
break;
case '2':
for(int i = count; i > 0; i--){//count; i > 0; i--){
NQueen n = new NQueen();
n.print();
long startTime = System.currentTimeMillis();
n.minConflict();
long endTime = System.currentTimeMillis();
stat = n.getStatus();
long result = (endTime - startTime); /// 1000;
System.out.println("Time: " + result + " milliseconds.");
minAverage += result;
}
System.out.println("Min Conflict Algorithm");
System.out.println("Average time took: " + (minAverage/100) + " milliseconds.");
break;
case '3':
System.exit(0);
default:
System.out.println("Incorrect input.");
break;
}
}while(input != "3");
}
}