-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
103 lines (83 loc) · 2.34 KB
/
Copy pathmain.cpp
File metadata and controls
103 lines (83 loc) · 2.34 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include "graph.h"
#include "wordle.h"
using namespace std;
std::string random(Options ops) { return ops.front(); }
std::string risk(Options ops) {
// int z = ops.size();
std::string best = ops.front();
int reward = 0;
int highest_reward = 0;
for (auto op : ops) {
unordered_set<int> s(op.begin(), op.end());
reward = 0;
for (auto cmp : ops) {
int res = count_if(cmp.begin(), cmp.end(),
[&](int k) { return s.find(k) != s.end(); });
reward += res;
}
if (reward > highest_reward) {
highest_reward = reward;
best = op;
}
}
return best;
// for (ind)
}
std::string freq_best(Options ops) {
double max_val = 0;
std::string max = ops.at(0);
double curr = 0;
for (auto s : ops) {
curr = Constants::FREQ[LET(s[0])] + Constants::FREQ[LET(s[1])] +
Constants::FREQ[LET(s[2])] + Constants::FREQ[LET(s[3])] +
Constants::FREQ[LET(s[4])];
if (curr > max_val) {
max_val = curr;
max = s;
}
}
return max;
}
std::string dijkstra_best(Options ops) {
graph g(ops);
std::string guess = g.dijkstra();
// std::cout << "GUESS: " << guess << std::endl;
std::string max_val = ops.front();
int max = 0;
int curr = 0;
auto score = [&](std::string& s, int x) {
if (s.find(guess[x]) == x) return 2;
if (s.find(guess[x]) != std::string::npos) return 1;
return 0;
};
for (auto word : ops) {
curr = score(word, 0) + score(word, 1) + score(word, 2) +
score(word, 3) + score(word, 4);
if (curr > max) {
max = curr;
max_val = word;
}
}
return max_val;
}
int main() {
Wordle w;
int score = 0;
int total = 0;
for (int i = 0; i < Constants::WORD_COUNT; ++i) {
score = w.simulate(Constants::WORDS[i], "ghost", &risk);
total += score;
w.new_game();
}
std::cout << "Farts: " << (double)total / Constants::WORD_COUNT
<< std::endl;
}
// total = 0;
// Options words;
// for (int i = 0; i < Constants::WORD_COUNT; ++i) {
// words.push_back(Constants::WORDS[i]);
// }
// auto res = dijkstra_best(words);
// std::cout << res << std::endl;
// }