-
Notifications
You must be signed in to change notification settings - Fork 0
/
Basic_Boggle_Solver.cpp
72 lines (54 loc) · 1.55 KB
/
Basic_Boggle_Solver.cpp
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
#include <iostream>
#include "Boggle.h"
#include "Dictionary.h"
using namespace std;
void GetBoard(string board[BOARD_SIZE][BOARD_SIZE]) {
cout << "Enter Board" << endl;
cout << "-----------" << endl;
for (int i = 0; i < BOARD_SIZE; i++) {
cout << "Row " << i << ": ";
for (int j = 0; j < BOARD_SIZE; j++) {
cin >> board[i][j];
}
}
cout << endl;
}
void HardCodedBoard(string board[BOARD_SIZE][BOARD_SIZE]) {
board[0][0] = "a";
board[0][1] = "b";
board[0][2] = "c";
board[0][3] = "d";
board[1][0] = "x";
board[1][1] = "y";
board[1][2] = "z";
board[1][3] = "a";
board[2][0] = "l";
board[2][1] = "m";
board[2][2] = "n";
board[2][3] = "o";
board[3][0] = "q";
board[3][1] = "t";
board[3][2] = "v";
board[3][3] = "g";
}
int main() {
Boggle boggle;
string board[BOARD_SIZE][BOARD_SIZE];
//HardCodedBoard(board); // Provides a hard coded board
GetBoard(board); // Gets a board from a user
cout << boggle.GetDictionary().WordCount() << " words loaded." << endl << endl;
boggle.SetBoard(board);
string yesno;
cout << "Show board? (y/n): ";
getline(cin, yesno);
cout << endl;
// Output to the screen.
boggle.SolveBoard(yesno == "y", cout);
// Output to a file.
ofstream solveOutput;
solveOutput.open("solve_output_basic.txt");
boggle.SolveBoard(yesno == "y", solveOutput);
solveOutput.close();
boggle.WordsFound().SaveDictionaryFile("solve_dictionary.txt");
return 0;
}