DFS is fully working, not finished (fine tune results at end) Output file for #d8bea791 filetype.
This commit is contained in:
parent
d8bea791fb
commit
dbfe4c6fe8
103
src/Assignments/A1/performance_stats/DFS.txt
Normal file
103
src/Assignments/A1/performance_stats/DFS.txt
Normal file
@ -0,0 +1,103 @@
|
||||
Run from #d8bea791: (Time in Milliseconds)
|
||||
Run 1: 5677
|
||||
Run 2: 1012
|
||||
Run 3: 17058
|
||||
Run 4: 11860
|
||||
Run 5: 45404
|
||||
Run 6: 10
|
||||
Run 7: 10250
|
||||
Run 8: 29170
|
||||
Run 9: 26660
|
||||
Run 10: 22485
|
||||
Run 11: 5372
|
||||
Run 12: 28510
|
||||
Run 13: 1269
|
||||
Run 14: 37239
|
||||
Run 15: 3
|
||||
Run 16: 36978
|
||||
Run 17: 38774
|
||||
Run 18: 42041
|
||||
Run 19: 662
|
||||
Run 20: 2951
|
||||
Run 21: 11334
|
||||
Run 22: 1581
|
||||
Run 23: 1738
|
||||
Run 24: 2604
|
||||
Run 25: 17161
|
||||
Run 26: 5572
|
||||
Run 27: 14
|
||||
Run 28: 8316
|
||||
Run 29: 25494
|
||||
Run 30: 7669
|
||||
Run 31: 43046
|
||||
Run 32: 20427
|
||||
Run 33: 16146
|
||||
Run 34: 30095
|
||||
Run 35: 11381
|
||||
Run 36: 0
|
||||
Run 37: 1366
|
||||
Run 38: 10928
|
||||
Run 39: 529
|
||||
Run 40: 10643
|
||||
Run 41: 19734
|
||||
Run 42: 3631
|
||||
Run 43: 17513
|
||||
Run 44: 3892
|
||||
Run 45: 21224
|
||||
Run 46: 105
|
||||
Run 47: 30568
|
||||
Run 48: 5313
|
||||
Run 49: 6464
|
||||
Run 50: 21124
|
||||
Run 51: 31758
|
||||
Run 52: 1619
|
||||
Run 53: 35134
|
||||
Run 54: 20679
|
||||
Run 55: 98
|
||||
Run 56: 2760
|
||||
Run 57: 13905
|
||||
Run 58: 15965
|
||||
Run 59: 39522
|
||||
Run 60: 2
|
||||
Run 61: 2293
|
||||
Run 62: 41910
|
||||
Run 63: 17853
|
||||
Run 64: 2950
|
||||
Run 65: 56304
|
||||
Run 66: 45523
|
||||
Run 67: 17346
|
||||
Run 68: 10577
|
||||
Run 69: 703
|
||||
Run 70: 324
|
||||
Run 71: 1081
|
||||
Run 72: 3846
|
||||
Run 73: 13315
|
||||
Run 74: 28206
|
||||
Run 75: 47831
|
||||
Run 76: 7488
|
||||
Run 77: 12499
|
||||
Run 78: 17101
|
||||
Run 79: 7968
|
||||
Run 80: 8936
|
||||
Run 81: 1494
|
||||
Run 82: 0
|
||||
Run 83: 19235
|
||||
Run 84: 15755
|
||||
Run 85: 4979
|
||||
Run 86: 22015
|
||||
Run 87: 11589
|
||||
Run 88: 27377
|
||||
Run 89: 16111
|
||||
Run 90: 25775
|
||||
Run 91: 7022
|
||||
Run 92: 27261
|
||||
Run 93: 6351
|
||||
Run 94: 26618
|
||||
Run 95: 4594
|
||||
Run 96: 13039
|
||||
Run 97: 23729
|
||||
Run 98: 16315
|
||||
Run 99: 35539
|
||||
Run 100: 2126
|
||||
Average Runtime: 15314
|
||||
Number of successful solves: 100/100
|
@ -15,33 +15,34 @@ public class DFS {
|
||||
private final Board solved = new Board();
|
||||
private List<String> tried = new ArrayList<>();
|
||||
|
||||
public Board dfs(Board root, int depth, ArrayList<String> visited) {
|
||||
counter++;
|
||||
if (root.equals(solved)) {
|
||||
return root;
|
||||
}
|
||||
|
||||
ArrayList<String> directParents = new ArrayList<>(visited);
|
||||
if (depth == Parameters.MAX_DEPTH || visited.contains(root.toString()) || tried.contains(root.toString())) {
|
||||
return null;
|
||||
}
|
||||
directParents.add(root.toString());
|
||||
tried.add(root.toString());
|
||||
|
||||
List<Move> moves = root.getMoves();
|
||||
int moveNum = 1;
|
||||
for (Move next : moves) {
|
||||
|
||||
Board child = next.getBoard();
|
||||
child.swap(next);
|
||||
moveNum++;
|
||||
Board board = dfs(child, depth+1, directParents);
|
||||
if (board != null) {
|
||||
return board;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* Commented out for future reference. */
|
||||
// public Board dfs(Board root, int depth, ArrayList<String> visited) {
|
||||
// counter++;
|
||||
// if (root.equals(solved)) {
|
||||
// return root;
|
||||
// }
|
||||
//
|
||||
// ArrayList<String> directParents = new ArrayList<>(visited);
|
||||
// if (depth == Parameters.MAX_DEPTH || visited.contains(root.toString()) || tried.contains(root.toString())) {
|
||||
// return null;
|
||||
// }
|
||||
// directParents.add(root.toString());
|
||||
// tried.add(root.toString());
|
||||
//
|
||||
// List<Move> moves = root.getMoves();
|
||||
// int moveNum = 1;
|
||||
// for (Move next : moves) {
|
||||
//
|
||||
// Board child = next.getBoard();
|
||||
// child.swap(next);
|
||||
// moveNum++;
|
||||
// Board board = dfs(child, depth+1, directParents);
|
||||
// if (board != null) {
|
||||
// return board;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public Board dfs(Board root, int depth) {
|
||||
counter++;
|
||||
|
Loading…
Reference in New Issue
Block a user