Skip to content

Commit 9370fa6

Browse files
committed
Cleanup, path to correct solution
1 parent 37d478d commit 9370fa6

6 files changed

+32
-22
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,18 @@ the Checker is the "referee."
5858

5959
- Basic game constraints defined here
6060

61+
- `wordle_selectors.[h|cpp]`
62+
63+
- Selection Algorithms to feed to Solver
64+
6165
- `wordle_solver.h`
6266

6367
- Base class/interface for the Solver
6468

69+
- `wordle_trie.[h|cpp]`
70+
71+
- Trie data structure used for Wordle
72+
6573
- `wordlist_wordle_solver.[h|cpp]`
6674

6775
- More intelligent solvers that use a dictionary

wordle_checker_test.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,26 @@ what does this mean for my algo?
7373
can i make a new selector strategy?
7474
RandomSelector<iterable>
7575
76-
76+
answer: haute
77+
guess: verve
78+
BBBBG
79+
guess: veest
80+
BYBBY
81+
82+
^^ this tells me that you must handle greens first for elimination... but also need letter frequency before being overaggressive for blacks
83+
store all locations of same letter. if only letter and black, then eliminate all.
84+
otherwise,
85+
86+
if freq > 1
87+
yellow = eliminate current
88+
black = eliminate current
89+
90+
91+
Black:
92+
if letterFreqInGuess == 1
93+
removeAll
94+
else if letterFreqInGuess == 2 && 1 == G:
95+
removeAllExcept(depth)
96+
else if letterFreqInGuess == 2 && 1 == Y:
97+
7798
*/

wordle_selectors.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@ using namespace std;
88

99
string RandomSelector::select(ForwardIterator begin, ForwardIterator end) {
1010
advance(begin, getRandom(begin, end));
11-
cout << "selectFwd(" << *begin << ")" << endl;
1211
return *begin;
1312
}
1413

1514
string RandomSelector::select(SetIterator begin, SetIterator end, size_t rangeSize) {
16-
cout << "selectSet()" << endl;
17-
cout << "selectSet(" << *begin << ")" << endl;
1815
advance(begin, getRandom(begin, end, rangeSize));
19-
cout << "selectSet(" << *begin << ")" << endl;
2016
return *begin;
2117
}
2218

2319
size_t RandomSelector::getRandom(ForwardIterator begin, ForwardIterator end) const {
2420
size_t numElements = end-begin;
25-
cout << "numElems:" << numElements << "|" << rand() << endl;
2621
return rand() % numElements;
2722
}
2823

@@ -131,7 +126,6 @@ void MostCommonLetterSelector::rateCandidates() {
131126
for (auto it = m_iterBegin; it != m_iterEnd; it++) {
132127
WordScore ws;
133128
ws.word = *it;
134-
cout << "it:" << *it << endl;
135129
for (auto& c : ws.word) {
136130
auto letterScoreIt = m_frequencyMapWord.find(c);
137131
if (letterScoreIt != m_frequencyMapWord.end()) {
@@ -142,9 +136,7 @@ void MostCommonLetterSelector::rateCandidates() {
142136

143137
sort(m_sortedWords.begin(), m_sortedWords.end(), compareWordScores);
144138
auto it = m_sortedWords.begin();
145-
cout << "#1:" << it->word << endl;
146139
advance(it, 1);
147-
cout << "#2:" << it->word << endl;
148140
}
149141

150142
void MostCommonLetterSelector::computeFrequencyMap() {

wordle_trie.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class WordleTrie {
4242
removeAllOfLetter(letter, *m_root);
4343
}
4444
string getCandidate(Selector* selector);
45-
size_t getNumCandidates() const { cout << "numCands:" << m_candidates.size() << endl; return m_candidates.size(); }
45+
size_t getNumCandidates() const { return m_candidates.size(); }
4646
void printCandidates();
4747
private:
4848
void insertAtNode(string prefix, string remainingWord, WordleTrieNode* node);

wordlist_wordle_solver.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ Tree
5858

5959
WordlistWordleSolver::WordlistWordleSolver(Selector* s) : WordleSolver(s) {
6060
loadWordList([this](const string& word) -> void {
61-
//wl.insert(word);
6261
m_wordlist.push_back(word);
6362
m_wordSet.insert(word);
6463
for (size_t i = 0; i < LETTER_COUNT; i++) {
@@ -97,9 +96,7 @@ TrieBasedWordleSolver::TrieBasedWordleSolver(Selector* s) : PassthroughWordleSol
9796
}
9897

9998
string TrieBasedWordleSolver::makeInitialGuess() {
100-
// cout << "initial trie g" << endl;
10199
if (m_trie->getNumCandidates() > 0) {
102-
// cout << "initial trie g" << endl;
103100
string candidateWord = m_trie->getCandidate(m_selector);
104101
if (candidateWord.size() == 0) {
105102
throw;
@@ -112,14 +109,6 @@ string TrieBasedWordleSolver::makeInitialGuess() {
112109

113110
string TrieBasedWordleSolver::makeSubsequentGuess() {
114111
return makeInitialGuess();
115-
// if (m_trie->getNumCandidates() > 0) {
116-
// string candidateWord = m_trie->getCandidate();
117-
// if (candidateWord.size() == 0) {
118-
// throw;
119-
// }
120-
// return candidateWord;
121-
// }
122-
// throw;
123112
}
124113

125114
void TrieBasedWordleSolver::processResult(const WordleGuess& guess) {

wordlist_wordle_solver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PassthroughWordleSolver : public WordlistWordleSolver {
3434
public:
3535
using WordlistWordleSolver::WordlistWordleSolver;
3636
string makeInitialGuess() override { return m_selector->select(m_wordlist.begin(), m_wordlist.end()); }
37-
string makeSubsequentGuess() override { cout << "subseq" << endl; return makeInitialGuess(); }
37+
string makeSubsequentGuess() override { return makeInitialGuess(); }
3838
void processResult(const WordleGuess& guess) override {}
3939
};
4040

0 commit comments

Comments
 (0)