README complete
This commit is contained in:
parent
6d7544eddb
commit
89348119a6
1 changed files with 100 additions and 33 deletions
133
README.md
133
README.md
|
@ -1,45 +1,112 @@
|
|||
# Ordle: A Wordle Solver
|
||||
## Design
|
||||
Programmet är strukturerat i tre huvudkomponenter som arbetar tillsammans för
|
||||
att lösa Wordle-pussel. Den första delen hanterar inläsning och förberedelse av
|
||||
ordlistan. funktionen *read\_candidates* läser in alla ord från en fil och
|
||||
filtrerar ut de som inte är fem bokstäver långa. Samtidigt konverteras orden
|
||||
till gemener och dubbletter tas bort. Detta säkerställer att programmet börjar
|
||||
med en ren lista av potentiella lösningar.
|
||||
The program is structured into three main components that work together to solve Wordle puzzles. The first part handles the loading and preparation of the word list. The *read\_candidates* function reads all words from a file and filters out those that are not exactly five letters long. At the same time, the words are converted to lowercase, and duplicates are removed. This ensures that the program starts with a clean list of potential solutions.
|
||||
|
||||
Den andra delen av programmet fokuserar på filtrering av ord baserat på
|
||||
användarens input- Här används 3 funktoter för att hantera olika typer av krav:
|
||||
The second part of the program focuses on filtering words based on user input. Three functors are used to handle different types of requirements:
|
||||
|
||||
* *wrong\_fn* filterar bort ord som innehåller bokstäver som användaren angivit
|
||||
“felaktiga”.
|
||||
* *correct\_fn* säkerställer att de ord som finns kvar har alla gröna bokstäver
|
||||
på rätt positioner.
|
||||
* *misplaced\_fn* kontrollerar att gula bokstäver finns i ordet, men inte på de
|
||||
positioner som angivits som felaktiga.
|
||||
- *wrong\_fn*: Filters out words that contain letters the user has marked as "incorrect".
|
||||
- *correct\_fn*: Ensures that the remaining words have all the green letters at the correct positions.
|
||||
- *misplaced\_fn*: Checks that yellow letters are present in the word but not at the specified incorrect positions.
|
||||
|
||||
Dessa funktioner används i funktionen *do\_filter*, som applicerar användarens
|
||||
kriterier på den aktuella listan av kandidater. Efter varje steg minskar
|
||||
antalet möjliga lösningar tills en kandidat återstår, eller tills användaren
|
||||
väljer att avsluta.
|
||||
These functors are applied in the *do\_filter* function, which filters the current list of candidates based on the user's criteria. After each step, the number of possible solutions decreases until only one candidate remains, or the user decides to exit.
|
||||
|
||||
Den tredje komponenten hanterar användarinteraktionen. Funktionen *prompt*
|
||||
används för att samla in indata från användaren. Bokstäver som inte finns i
|
||||
ordet, gröna bokstäver med deras positioner och gula bokstäver med deras
|
||||
felaktiga positioner. Denna indata används sedan för att uppdatera
|
||||
filtreringen.
|
||||
The third component manages user interaction. The *prompt* function is used to gather input from the user, such as letters that do not appear in the word, green letters with their positions, and yellow letters with their incorrect positions. This input is then used to update the filtering process.
|
||||
|
||||
The program consists of three files:
|
||||
- **main.cc**: Runs the program and uses logic from **ordle.cc**.
|
||||
- **ordle.cc**: Implements the core logic.
|
||||
- **ordle.h**: Contains the definitions for the functions and functors in *ordle.cc*.
|
||||
|
||||
Programmet består av 3 filer. Vilket är *main.cc* som kör självaste programmet
|
||||
och använder logik från *ordle.cc* genom att inkludera *ordle.h*. *ordle.h* är
|
||||
definitionen för *ordle.cc* och *ordle.cc* är självaste logiken.
|
||||
## Build Instructions
|
||||
Common actions are defined in the provided Justfile and can be viewed with
|
||||
`just -l`
|
||||
|
||||
For a release build:
|
||||
```bash
|
||||
make RELEASE=1
|
||||
```
|
||||
## User Instructions
|
||||
## Limitations and Drawbacks
|
||||
## Comments
|
||||
### Step-by-Step Instructions
|
||||
|
||||
1. **Clean old files**
|
||||
To ensure a fresh build, clean up previous build artifacts:
|
||||
```bash
|
||||
make clean
|
||||
```
|
||||
|
||||
2. **Generate the words list**
|
||||
Create a `words.txt` file using the system dictionary:
|
||||
```bash
|
||||
make words.txt
|
||||
```
|
||||
|
||||
3. **Build the project**
|
||||
Compile the project in debug mode:
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
4. **Run the program**
|
||||
Start the program and specify the `words.txt` file:
|
||||
```bash
|
||||
./main.elf words.txt
|
||||
```
|
||||
|
||||
5. **Release Build**
|
||||
To build an optimized version of the program:
|
||||
```bash
|
||||
make RELEASE=1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Available Commands
|
||||
|
||||
| **Task** | **Command** |
|
||||
|------------------------|----------------------|
|
||||
| Debug Build | `make` |
|
||||
| Release Build | `make RELEASE=1` |
|
||||
| Clean Build Artifacts | `make clean` |
|
||||
| Generate Words List | `make words.txt` |
|
||||
| Lint Code | `make clang-tidy` |
|
||||
| Static Analysis | `make cppcheck` |
|
||||
| Format Code | `make format` |
|
||||
| Watch and Rebuild | `just watch` |
|
||||
|
||||
---
|
||||
|
||||
## User Instructions
|
||||
1. Start the program with the provided `words.txt` file:
|
||||
```bash
|
||||
./main.elf words.txt
|
||||
```
|
||||
|
||||
2. Follow the program's instructions to input:
|
||||
- **Wrong letters**: Letters that do not appear in the solution.
|
||||
- **Correct letters (green)**: Letters that are correctly placed along with their positions. Input format: `letter position`.
|
||||
- **Misplaced letters (yellow)**: Letters that exist in the word but are incorrectly placed. Input format: `letter position`.
|
||||
|
||||
Example input:
|
||||
```
|
||||
Enter wrong letters:
|
||||
a e
|
||||
|
||||
Enter correct letters (letter index)*:
|
||||
r 1 i 3
|
||||
|
||||
Enter misplaced letters (letter index)*:
|
||||
o 2
|
||||
```
|
||||
|
||||
3. The program will filter the possible candidates based on your input and display the remaining words after each iteration.
|
||||
|
||||
4. Repeat the process until:
|
||||
- Only one candidate remains, which is the solution.
|
||||
- You decide to exit the program.
|
||||
|
||||
---
|
||||
|
||||
## Limitations and Drawbacks
|
||||
- The word list depends on the system dictionary, which might be incomplete.
|
||||
- The program assumes that the user inputs valid and correctly formatted data.
|
||||
- There is no robust handling for incorrect input.
|
||||
|
||||
## Comments
|
||||
The program is straightforward to use and relies on clear filtering logic. The use of **C++17** and the standard library makes the code efficient and easy to read. A possible improvement could involve better validation of user input to avoid errors.
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue