From 598d835142d1f60c7ad675afde688a81d1d7bd64 Mon Sep 17 00:00:00 2001 From: Matuush Date: Wed, 25 Dec 2024 22:45:29 +0100 Subject: [PATCH] Documentation almost done --- DOC.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/DOC.md b/DOC.md index 70192be..b48f94d 100644 --- a/DOC.md +++ b/DOC.md @@ -11,9 +11,34 @@ In this mode, the player has to deduce the secret sequence, which is done by gue Inside of the game, all that is happening is a loop consisting of taking user input, generating a response and outputting it. ### Bot mode +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. + +#### Guessing ### Response generating When a guess is entered, all that is done to make a response is comparing that guess to the secret sequence. First it counts right colors, then the out-of-place right colors. - -## Solver