TODO: Introduce [game rules](https://en.wikipedia.org/wiki/Mastermind_(board_game)) and related work.
TODO: Introduce [game rules](https://en.wikipedia.org/wiki/Mastermind_(board_game)) and real word applications (diagnostics).
## Related work
TODO
## Notations
Let $`N`$ be the number of pegs in the code and $`C`$ be the number of possible peg colors. A *code* is a vector in $`\{0, \ldots, C - 1\}^N`$. The number of possible codes is $`M = C^N`$. The game is played as follows:
Let $`N`$ be the number of pegs in the code and $`C`$ be the number of possible peg colors. We will call a game with these particular parameters a $`(N, C)`$-game. A *code* is a vector in $`\BbbC = \{0, \ldots, C - 1\}^N`$. The number of possible codes is $`M = C^N`$. The game is played as follows:
1. The codemaker chooses a secret code $`c`$.
2. The codebreaker tries to guess $`c`$ in as few iterations as possible. At each iteration $`t`$ :
...
...
@@ -51,7 +55,7 @@ The feedbacks are also encoded as integers between $`0`$ and $`F - 1`$, where $`
Using this encoding, feedback $`0`$ always means that the codebreaker guessed the code. According to the situation, some of the feedbacks above are impossible. For example, the codebreaker can never get a feedback $`\langle N - 1, 1 \rangle`$. This encoding tries to find a good trade-off between implementation simplicity and memory economy.
The class `CodeToolkit` makes these encodings more or less transparent. The main method is `int feedback(int code, int guess)`. For performance reasons, feedbacks are precomputed and stored in a $`M \times M`$ symmetrical `feedbacks` matrix. The class also contains some methods for encoding, decoding and displaying codes and feedbacks.
The class `CodeToolkit` makes these encodings more or less transparent. The main method is `int feedback(int code, int guess)`. For performance reasons, feedbacks are precomputed and stored in a $`M \times M`$ symmetrical `feedbacks` matrix. The class also contains some methods for encoding, decoding and displaying codes and feedbacks. The sketch `test_toolkit` shows how to use this class.