https://github.com/macrat/wordpy
THAT word game in python.
https://github.com/macrat/wordpy
Last synced: 11 months ago
JSON representation
THAT word game in python.
- Host: GitHub
- URL: https://github.com/macrat/wordpy
- Owner: macrat
- License: mit
- Created: 2022-02-11T12:38:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-16T06:08:29.000Z (over 3 years ago)
- Last Synced: 2023-03-04T02:13:42.350Z (over 3 years ago)
- Language: Python
- Homepage:
- Size: 179 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
wordpy
======

Word puzzle solver.
## Use as solver
``` shell
$ git clone https://github.com/macrat/wordpy.git
$ python3.10 -m wordpy
candidates 0:
cares
cores
bares
carey
bores
canes
carts
ceras
cires
corey
what did you input?
_____
> cares
what was correct? (input incorrect character as .)
_____
> ..r..
what characters was yellow?
> a
```
`what did you input?` -> enter what you have input to the game.
`what was correct?` -> enter what letters was correct. please input incorrect letters as `.`.
`what characters was yellow?` -> enter what letters was included in the answer but not correct position.
## Make your own solver
``` python
import wordpy
class MySolver(wordpy.Solver):
def __init__(self, game: wordpy.Game):
super().__init__(game)
# do initialization here
def guess(self) -> wordpy.WordTable:
self.state # current game status.
self.words # current word candidates.
self.drop_words_by_state() # drop words that can't be the answer, from self.words.
return self.words[:10] # return some next word candidates.
if __name__ == '__main__':
words = wordpy.get_words()
wordpy.benchmark(words, MySolver)
```
There are 3 solvers in this repository.
The solvers are defined in [solver.py](./solver.py).
- __wordpy.solver.RandomSolver__: Just choices random word from possible words.
- __wordpy.solver.MajorLetterSolver__: Tries to use letters that commonly use.
- __wordpy.solver.MinorLetterSolver__: The opposite of MajorLetterSolver. Uses minor letters.
- __wordpy.solver.MarkSolver__: Tries to all letters as many as possible to detect what letters used in the answer. (this is most efficient in this repository)