forked from meicholtz/wordle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_dummy.py
More file actions
43 lines (35 loc) · 1.46 KB
/
ai_dummy.py
File metadata and controls
43 lines (35 loc) · 1.46 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
# ai_dummy.py
# Stupid AI for playing Wordle.
#
# The "strategy" of this default AI player is simply to pick a random word.
# This file exists primarily to test the AI capabilities of the main program,
# and perhaps to set the lowest possible benchmark for AI players? :)
import pdb
import random
import utils
def makeguess(wordlist, guesses=[], feedback=[]):
"""Guess a word from the available wordlist, (optionally) using feedback
from previous guesses.
Parameters
----------
wordlist : list of str
A list of the valid word choices. The output must come from this list.
guesses : list of str
A list of the previously guessed words, in the order they were made,
e.g. guesses[0] = first guess, guesses[1] = second guess. The length
of the list equals the number of guesses made so far. An empty list
(default) implies no guesses have been made.
feedback : list of lists of int
A list comprising one list per word guess and one integer per letter
in that word, to indicate if the letter is correct (2), almost
correct (1), or incorrect (0). An empty list (default) implies no
guesses have been made.
Output
------
word : str
The word chosen by the AI for the next guess.
"""
return random.choice(wordlist)
if __name__ == "__main__":
wordlist = utils.readwords("allwords5.txt")
print(f"AI: 'My next choice would be {makeguess(wordlist)}'")