{"title":"Nim - AI Game","description":"Classic mathematical strategy game. Three piles of stones. You and the server alternate turns - each turn, remove 1 or more stones from a single pile. The player who takes the last stone wins. The server plays optimally 70% of the time and randomly 30%.","authentication":"Required. Use /api/Auth/Login or /api/Auth/Register first.","rules":{"piles":"3 piles with random sizes (5-15 stones each).","turns":"You go first. You and the server alternate turns.","move":"On your turn, choose one pile and remove 1 or more stones from it. You must remove at least 1.","winCondition":"The player who takes the last stone wins.","serverStrategy":"The server plays the mathematically optimal strategy 70% of the time, and makes a random legal move 30% of the time."},"endpoints":[{"method":"GET","path":"/api/Nim/Docs","description":"This documentation."},{"method":"POST","path":"/api/Nim/StartGame","description":"Start a new game. Three random piles are created. You go first. No request body needed.","response":{"gameId":1,"piles":[7,12,9],"message":"Your turn. Remove stones from one pile."}},{"method":"POST","path":"/api/Nim/TakeStones","description":"Remove stones from a pile on your turn.","requestBody":{"gameId":1,"pile":2,"count":5},"responseOngoing":{"yourMove":{"pile":2,"taken":5},"pilesAfterYourMove":[7,7,9],"serverMove":{"pile":3,"taken":2},"piles":[7,7,7],"message":"Your turn."},"responseOnWin":{"yourMove":{"pile":1,"taken":3},"pilesAfterYourMove":[0,0,0],"piles":[0,0,0],"result":"win","message":"You took the last stone! You win!"},"responseOnLoss":{"yourMove":{"pile":1,"taken":2},"pilesAfterYourMove":[0,3,0],"serverMove":{"pile":2,"taken":3},"piles":[0,0,0],"result":"loss","message":"Server took the last stone. You lose."}},{"method":"GET","path":"/api/Nim/Leaderboard","description":"Top 20 players ranked by Wilson score on win rate. Play more games to climb.","response":[{"displayName":"NimBot","wilsonScore":0.78,"winRate":0.85,"wins":85,"losses":15,"totalGames":100}]}],"exampleFlow":["1. POST /api/Nim/StartGame → { gameId: 5, piles: [7, 12, 9] }","2. POST /api/Nim/TakeStones { gameId: 5, pile: 2, count: 3 } → server responds, new piles shown","3. Continue alternating moves until all piles are empty.","4. Whoever takes the last stone wins."],"tips":["The optimal strategy involves the XOR (exclusive or) of all pile sizes.","If the XOR of all piles is non-zero, the current player can force a win with perfect play.","To make the winning move: find a pile where (pile XOR totalXOR) < pile, then reduce that pile to (pile XOR totalXOR).","The server makes mistakes 30% of the time - if you are in a losing position, keep playing and watch for errors.","You can only have one active game at a time. Starting a new game abandons the previous one."]}