# How to create a reasonable AI?

I'm creating a logic game based on Fox and Hounds game. The player plays the fox and AI plays the hounds. (as far as I can see) I managed to make the AI perfect, so it never loses. Leaving it as such would not be much fun for human players.

Now, I have to dumb-down the AI so human can win, but I'm not sure how. The current AI logic is based on pattern-matching - if I introduce random moves which make the board go out of pattern space the AI would most probably play dumb until the end of the game.

Any ideas how to dumb down the AI in such way that is does not go from "genius" to "completely dumb" in a single move?

• So you found and implemented the optimum, always winning strategy. Why not moving to slightly more complicated games now? Or, what about a challenge: Implement a strategy which always loses, no matter what the other player does. See also: Losing Chess/Antichess Aug 23, 2011 at 8:52
• Maybe you'd like to take a look at my answer on this other question: gamedev.stackexchange.com/questions/12858/…
– Tyn
Aug 24, 2011 at 10:21
• Fox and hounds is not as complex as chess. One wrong move and AI loses for sure. It's very easy to make AI look dumb. The fact that I solved it using pen and paper and hours of strategic thinking, does not mean that my players will do the same. Sep 29, 2011 at 19:15

Many implementations may lead to a random weighted chance for moves -- say, a chance to make an optimal move and a chance to make a suboptimal move. Determining how suboptimal a move is could be a very tricky problem, but will also lead your AI to making much more seemingly-intelligent decisions.

Important note: No matter the difficulty setting, it would probably be a bad idea to have the AI pass up a chance to immediately win the game. If there is a possibility to make a move that would finish the game that turn, it should always be taken. If not, it will absolutely destroy the player's impression of how the AI is acting.

• Thanks. I decided to let it play smart for all the simple patterns. There are two complex patterns where player's path to freedom is not easily visible, so I created additional patterns that make AI lose by playing moves that would resemble a novice human player in such position. At start of the game, I randomly switch winning pattern with losing one for such positions. Aug 24, 2011 at 6:52

Since this appears to be a 'solved' game, the only answer is that the computer must make intentionally bad moves.

A quick solution may be to calculate the best move, then also calculate another legal move that may not be so good. The difficulty rating of the AI would be measured in the percent chance it picks the other not so good move, over the perfect move.

• Difficult - 90% good moves
• Hard - 70% good moves
• Normal - 50% good moves
• Simple - 20% good moves
• Was Dropped As A Child - <5% good moves
• Hotdog - All Random
• This is probably a good idea, but you'd end up with a retarded AI if it is intentionally taking wrong moves. Off the top of my head, I would first do a pass for "legal" moves, then apply weights to each move and order them by weight, the highest weight being the best move. You can then make a RNG converge towards better moves depending on difficulty. Aug 22, 2011 at 13:03
• I agree with @Jonathan Connell. Consider: hiding behind crates vs hiding behind explosive barrels vs hiding among crates and an active grenade. The AI should evaluate how bad the move is, with better AI making better moves more often. An AI won't be great or hard if 70% of the time it shoots you and 30% of the time it blows itself up. It will just be hilarious. Aug 22, 2011 at 13:12
• @Adrian Seeley Your last comment really touches the biggest problem; for me a human playing against AI will always instinctively find a reasoning behind it's choices even if they are theoretically completely random. In a board game for example this can be countered by limiting the number of iterations in predicting moves, so maybe this could be a good solution in a solvable game? Aug 22, 2011 at 13:43
• I agree with both Jonathans, but I'm giving this answer +1 for 'Was Dropped as a Child' and 'Hotdog' Aug 22, 2011 at 13:49
• @Jonathan Connell: You should post your proposition/solutions as an answer. It would deserve some upvotes. Aug 22, 2011 at 14:08