Documentation done
This commit is contained in:
parent
c55dbee834
commit
f715b02e8d
2 changed files with 10 additions and 23 deletions
31
DOC.md
31
DOC.md
|
@ -14,30 +14,19 @@ Inside of the game, all that is happening is a loop consisting of taking user in
|
|||
Works the same way, but instead of the player typing guessed sequences, there is a program guessing.
|
||||
The real fun happens inside of the solver, where it makes the guesses and learns from responses.
|
||||
|
||||
The solver keeps track of past guesses with their responses in history.
|
||||
It also remembers a table with which colors can be on which positions - this starts at all colors possible on all positions.
|
||||
|
||||
#### Learning
|
||||
With each new guess-response duo, the solver adds it to the history.
|
||||
Then it goes through all the historical, extracting all possible information from them.
|
||||
This is repeated as long as some new information is learnt.
|
||||
|
||||
While extracting info from history, it is important to strip guesses from the info already gained,
|
||||
so they are simplified and information is easier to recognize. That is done by replacing the known colors
|
||||
in the guess with an unreal color, like *-1* and decreasing the response accordingly.
|
||||
|
||||
Extracting information from a guess-response duo is a complicated process,
|
||||
it has many possibilities, depending on the response.
|
||||
[A/B] meaning A colors are somewhere else in the sequence, B colors are correct.
|
||||
- [0/0]: None of the colors from the guess are in the sequence. Now we can erase these colors from the table,
|
||||
as they are nowhere in the sequence. Of course we must not erase them from the positions we already know they are in,
|
||||
but were cleared to simplify the guess.
|
||||
- [X/0]: None of these colors are on the right spot.
|
||||
- [0/X]: If these colors cannot be on their spot, they can't be in the sequence.
|
||||
Also if only the colors that can be in those spots are left, they are correct.
|
||||
- [X/X]: If only the colors that can be in those spots are left, they are correct too.
|
||||
The solver keeps a set of possible sequences.
|
||||
With every response, to a guess, it removes all sequences from the set, which wouldn't generate the same response.
|
||||
Like this, the solver filters possible sequences, until there is only one left.
|
||||
|
||||
#### Guessing
|
||||
We have a set of all possible sequences.
|
||||
Now we have to pick a guess, which divides them the most equally.
|
||||
The solver goes through all sequences, not just the remaining possible ones and divides the possible ones by their response.
|
||||
After that, it gives these guesses a weight, depending on how big is its biggest group at any response.
|
||||
Finally it picks the guess, which has the least weight - has the smallest biggest remaining sequences count at worst-case.
|
||||
|
||||
This is inspired by Donald Knuth and his algorithm to solve Mastermind.
|
||||
|
||||
### Response generating
|
||||
When a guess is entered, all that is done to make a response is comparing that guess to the secret sequence.
|
||||
|
|
|
@ -17,13 +17,11 @@ The game has multiple modes:
|
|||
|
||||
* **Player mode**: Try your best to guess the random generated sequence of colors.
|
||||
* **Bot mode**: Try to outsmart my bot with a sequence, which he will try to guess.
|
||||
* **Test mode**: Watch the bot against a random sequence.
|
||||
|
||||
## Commandline arguments
|
||||
* `-n <number>` : Length of guessed sequence
|
||||
* `-m <number>` : Number of colors to play with
|
||||
* `-p [human/bot]` : Who plays the game
|
||||
* `-l [y/n]` : Whether you want to see what the bot learns
|
||||
* `-g [human/random]` : Who generates the guessed sequence (If human plays, this is ignored and the sequence is random)
|
||||
|
||||
## Usage
|
||||
|
|
Loading…
Reference in a new issue