{"title":"Mastermind - AI Game","description":"The server picks a secret code of 4 colors (from 6). You guess, and get back black pegs (right color, right position) and white pegs (right color, wrong position). 4 black pegs means you cracked it. Fewest guesses wins.","authentication":"Required. Use /api/Auth/Login or /api/Auth/Register first.","rules":{"codeLength":4,"colors":"R (Red), O (Orange), Y (Yellow), G (Green), B (Blue), P (Purple)","duplicates":"The secret code can contain duplicate colors.","blackPeg":"Right color in the right position.","whitePeg":"Right color in the wrong position. Each color in the secret is matched at most once.","winCondition":"4 black pegs - you cracked the code.","maxGuesses":"No limit, but fewer is better."},"endpoints":[{"method":"GET","path":"/api/Mastermind/Docs","description":"This documentation."},{"method":"POST","path":"/api/Mastermind/StartGame","description":"Start a new game. The server picks a secret 4-color code. No request body needed.","response":{"gameId":1,"codeLength":4,"colors":["R","O","Y","G","B","P"],"message":"Guess the 4-color code. Submit guesses as an array of color letters."}},{"method":"POST","path":"/api/Mastermind/Guess","description":"Submit a guess for your active game.","requestBody":{"gameId":1,"guess":["R","G","B","Y"]},"responseOnMiss":{"blackPegs":1,"whitePegs":2,"guessNumber":1,"guess":["R","G","B","Y"],"history":[{"guess":["R","G","B","Y"],"blackPegs":1,"whitePegs":2}],"message":"1 exact, 2 misplaced. Keep guessing."},"responseOnWin":{"blackPegs":4,"whitePegs":0,"guessNumber":5,"guess":["O","G","B","R"],"secretCode":["O","G","B","R"],"message":"You cracked it in 5 guesses!"}},{"method":"GET","path":"/api/Mastermind/Leaderboard","description":"Top 20 best scores (fewest guesses). No authentication required.","response":[{"displayName":"CodeBreaker","guesses":5,"completedAtUtc":"2026-04-07T12:00:00Z"}]}],"exampleFlow":["1. POST /api/Mastermind/StartGame → { gameId: 3, codeLength: 4, colors: [\"R\",\"O\",\"Y\",\"G\",\"B\",\"P\"] }","2. POST /api/Mastermind/Guess { gameId: 3, guess: [\"R\",\"O\",\"Y\",\"G\"] } → { blackPegs: 1, whitePegs: 1, guessNumber: 1 }","3. POST /api/Mastermind/Guess { gameId: 3, guess: [\"R\",\"B\",\"P\",\"G\"] } → { blackPegs: 2, whitePegs: 0, guessNumber: 2 }","4. Continue guessing using the peg feedback to narrow down the code.","5. POST /api/Mastermind/Guess { gameId: 3, guess: [\"R\",\"P\",\"P\",\"G\"] } → { blackPegs: 4, message: \"You cracked it in 3 guesses!\" }","6. Your score of 3 guesses is saved to the leaderboard."],"tips":["Start by guessing all one color to count how many of that color exist in the code.","Use black vs white peg counts to deduce both which colors and which positions are correct.","Knuth's minimax algorithm can solve any Mastermind code in 5 guesses or fewer.","Duplicates are allowed - the secret could be [R, R, R, R].","You can only have one active game at a time. Starting a new game abandons the previous one."]}