This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordle.cpp
109 lines (89 loc) · 2.69 KB
/
wordle.cpp
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
104
105
106
107
108
109
/*********
* A c++ program which solves the Wordle independently and interactively.
* Created December 2022 by Ericka Florio
for the purpose of assessment in the Michaelmas 2022 Research in Computing course.
**********/
#include "modes.cpp"
int main()
{
//declaring main type variables
int tot=12947;
int typ;
string words[tot];
string hid;
string ans;
int run_main;
if (debug != 1)
{
run_main = 1;
}
else if (debug == 1)
{
run_main = 0;
debug_out = fopen("./tools/debug_output.txt", "w");
}
else
{
printf("Debug flag isn't working, stopping program.");
exit(EXIT_FAILURE);
}
read_words(tot, words);
if(run_main==1)
{
//opening message
cout << "Welcome to my Wordle solver!\nWould you like to play independently (0) or interactively (1)?: ";
cin >> typ;
//main body for independent mode
if (typ == 0)
{
int max;
cout << "---------\nYou have chosen to play independently.\nPlease enter a word for me to find: ";
cin >> hid;
check_is_word(hid, tot, words);
cout << "Please enter a maximum number of times you want me to guess: ";
cin >> max;
ans = independent(hid, max, tot, words);
cout << "Your hidden word is: ";
cout << ans << endl;
}
//main body for interactive mode
else if (typ == 1)
{
string best = best_word(1, tot, words);
int strt;
string start;
cout << "---------\nYou have chosen to play interactively.\nDo you wish to enter a starting word (0) or use the best starting word (1)?: ";
cin >> strt;
if (strt == 0)
{
cout << "Please enter your starting word: ";
cin >> start;
check_is_word(start, tot, words);
interactive(start, tot, words);
}
else if (strt == 1)
{
printf("The best starting word is: ");
cout << best << endl;
interactive(best, tot, words);
}
//error trap
else
{
cout << "Please enter a value of either 0 or 1." << endl;
exit(EXIT_FAILURE);
}
}
//error trap
else
{
cout << "Please enter a type which is either 0 or 1.\n";
exit(EXIT_FAILURE);
}
}
printf("Program ended. Thanks for playing!\n");
if(debug == 1)
{
fclose(debug_out);
}
}