diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-11-29 01:44:00 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-11-29 01:44:00 +0100 |
| commit | 5216d920fb26638ceda9f6391c5449c5e7bc8409 (patch) | |
| tree | 8c117086cbb7968f010cae3aca0d16a51e8a2470 /labb5/src/Boggle.h | |
| parent | fb80ac50825c7ca1fa063d3493175b7b27adbdb1 (diff) | |
| download | tddd86-5216d920fb26638ceda9f6391c5449c5e7bc8409.tar.gz | |
initial work labb5
Apparently I need to implement a second search function here.
I don't agree with the reasoning in the lab description.
> NOTERA: Programmet innehåller två rekursiva sökningar: en för att
> hitta ett specifikt ord inmatat av den mänskliga spelaren och en
> annan för att söka ̈över hela brädet under datorspelarens tur. Du
> tänker kanske att dessa borde gå att kombinera till en integrerad
> funktion, genom att göra all ordsökning i början av spelet, precis
> efter att brädet initierats. För att bli godkänd på labben måste
> du dock implementera människan och datorn som två separata
> sökfunktioner. Det finns tillräckliga skillnader mellan de två för
> att de inte ska gå att kombinera rent och snyggt.
Diffstat (limited to 'labb5/src/Boggle.h')
| -rwxr-xr-x | labb5/src/Boggle.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/labb5/src/Boggle.h b/labb5/src/Boggle.h index 3abe9b5..b6551ee 100755 --- a/labb5/src/Boggle.h +++ b/labb5/src/Boggle.h @@ -9,21 +9,47 @@ #include <iostream> #include <string> -// TODO: include any other header files you need +#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; - const int BOARD_SIZE = 4; + static const int BOARD_SIZE = 4; - // TODO: decide the public member functions and declare them + Boggle(); + bool letters_from_string(const string& letters); -private: - // TODO: decide the private member variables/functions and declare them + 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 |
