summaryrefslogtreecommitdiffstats
path: root/labb5/src/Boggle.h
blob: b6551eecd00ccfc3c3a5a8d3b562e8904c7647f2 (plain) (blame)
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
// This is the .h file you will edit and turn in.
// We have provided a minimal skeleton for you,
// but you must finish it as described in the spec.
// Also remove these comments here and add your own, as well as on the members.
// TODO: remove this comment header and replace it with your own

#ifndef _boggle_h
#define _boggle_h

#include <iostream>
#include <string>
#include <set>
#include "lexicon.h"
#include "grid.h"
#include <utility>

using namespace std;
using point = pair<int, int>;

class Boggle {
public:
    const string DICTIONARY_FILE = "EnglishWords.dat";
    const int MIN_WORD_LENGTH = 4;
    static const int BOARD_SIZE = 4;

    Boggle();
    bool letters_from_string(const string& letters);

    void read_dictionary();
    void clear();
    void shuffle();

    void find_all_words();
    string debug_words() const;

    string board_to_string() const;
    string user_words_to_string(int words_per_line = 3) const;

    int get_user_words_size() const;
    int get_user_score() const;

    bool word_is_valid(const string& word) const;
    bool word_is_unplayed(const string& word) const;
    bool add_user_word(const string& word);

private:
    void find_words_helper(point cur_point, string cur_word, set<point> visited);
    Lexicon dictionary;
    Grid<char> board;
    set<string> user_words;
    set<string> valid_words;
    int user_score = 0;
};

#endif