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
|
boggleGame::boggleGame(bool debug) {
if (debug == false)
{
int row, col;
unsigned seed = (unsigned) time (0);
srand (seed);
for (row = 0; row < SIZE; row++) {
for (col = 0; col < SIZE; col++) {
letters[row][col] = rand () % 26 + 'a';
}
}
}
}
//FOR DEBUG ONLY
char boggleGame::letters[4][4] =
{
{'y','o','x','f'},
{'r','b','a','k'},
{'v','e','d','i'},
{'u','y','t','r'}
};
void boggleCheater::solve(int size, boggleGame board, ifstream &words) {
string word;
//go through word in wordlist
while (!words.eof())
{
getline (words, word);
//kick out if not 3 or more letters or more than 17 (16 unless you have Q/Qu so 17)
if ((word.length() < 3 ) || (word.length() > 17)) continue;
for (int row = 0; row < 4; row++)
for (int col = 0; col < 4; col++)
if (board.letters[ row ][ col ] == word[ 0 ])
if (matchWord( word, row, col, (word[ 0 ] == 'q') ? 2 : 1, (1 << ((row *4) +col)), board.letters ))
cout << word << '\n'; //output the word
}
}
|