<p>I'm teaching a kid programming, and am introducing some basic artificial intelligence concepts at the moment. To begin with we're going to implement a tic-tac-toe game that searches the entire game tree and as such plays perfectly. Once we finish that I want to apply the same concepts to a game that has too many positions to evaluate every single one, so that we need to implement a heuristic to evaluate intermediate positions.</p>

<p>The best thing I could think of was <a href="http://en.wikipedia.org/wiki/Dots-and-boxes" rel="nofollow noreferrer">Dots and Boxes</a>. It has the advantage that I can set the board size arbitrarily large to stop him from searching the entire tree, and I can make a very basic scoring function be the number of my boxes minus the number of opponent boxes. Unfortunately this means that for most of the beginning of the game every position will be evaluated equivalently with a score of 0, because it takes quite a few moves before players actually start making boxes.</p>

<p>Does anyone have any better ideas for games? (Or a better scoring function for dots and boxes)?</p>

[{'answer_id': 76290, 'author': 'zweiterlinde', 'author_id': 6592, 'author_profile': 'https://Stackoverflow.com/users/6592', 'pm_score': 2, 'selected': False, 'text': '<p>How about <a href="http://en.wikipedia.org/wiki/Reversi" rel="nofollow noreferrer">Reversi</a>?  It has a pretty nice space of heuristics based on number of pieces, number of edge pieces, and number of corner pieces.  </p>\n'}, {'answer_id': 76299, 'author': 'Dan Williams', 'author_id': 4230, 'author_profile': 'https://Stackoverflow.com/users/4230', 'pm_score': 0, 'selected': False, 'text': "<p>How about starting your Dots and Boxes game with random lines already added.  This can get you into the action quickly.  Just need to make sure you don't start the game with any boxes.</p>\n"}, {'answer_id': 76311, 'author': 'amrox', 'author_id': 4468, 'author_profile': 'https://Stackoverflow.com/users/4468', 'pm_score': 3, 'selected': False, 'text': '<p>Another game choice could be <a href="http://en.wikipedia.org/wiki/Reversi" rel="noreferrer">Reversi</a> aka Othello.</p>\n\n<p>A naive heuristic would be to simply count the number of tiles gained by each valid move and choose the greatest. From there you can factor in board position and minimizing vulnerably to the opponent.</p>\n'}, {'answer_id': 76337, 'author': 'ima', 'author_id': 5733, 'author_profile': 'https://Stackoverflow.com/users/5733', 'pm_score': 0, 'selected': False, 'text': '<p>Take a look at Go.</p>\n\n<ul>\n<li>Simple enough for kid on very small boards.</li>\n<li>Complexity scales infinitely.</li>\n<li>Has a lot of available papers, algorithms and programs to use either as a scale or basis.</li>\n</ul>\n\n<p>Update: reversi was mentioned, which is a simplified variant of Go. Might be a better choice.</p>\n'}, {'answer_id': 76342, 'author': 'StubbornMule', 'author_id': 13341, 'author_profile': 'https://Stackoverflow.com/users/13341', 'pm_score': 3, 'selected': False, 'text': '<p>One game you may consider is <a href="http://en.wikipedia.org/wiki/Connect_Four" rel="noreferrer">Connect Four</a>.  Simple game with straightforward rules but more complicated that Tic-Tac-Toe.</p>\n'}, {'answer_id': 76343, 'author': 'Vinko Vrsalovic', 'author_id': 5190, 'author_profile': 'https://Stackoverflow.com/users/5190', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://en.wikipedia.org/wiki/Connect_Four" rel="nofollow noreferrer">Four in a line</a> Hard enough, but easy enough to come up with an easy working evaluation function, for example, (distance to four from my longest line - distance to four from my opponent\'s longest line)</p>\n'}, {'answer_id': 76355, 'author': 'AShelly', 'author_id': 10396, 'author_profile': 'https://Stackoverflow.com/users/10396', 'pm_score': 2, 'selected': False, 'text': '<p>How about <a href="http://en.wikipedia.org/wiki/Mancala" rel="nofollow noreferrer">Mancala</a>?  Only 6 possible moves each turn, and it\'s easy to calculate the resulting score for each, but it\'s important to consider the opponent\'s response, and the game tree gets big pretty fast.</p>\n'}, {'answer_id': 76383, 'author': 'moonshadow', 'author_id': 11834, 'author_profile': 'https://Stackoverflow.com/users/11834', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://en.wikipedia.org/wiki/Gomoku" rel="nofollow noreferrer">Gomoku</a> is a nice, simple game, and fun one to write AI for.</p>\n'}, {'answer_id': 76385, 'author': 'JBB', 'author_id': 12332, 'author_profile': 'https://Stackoverflow.com/users/12332', 'pm_score': 2, 'selected': False, 'text': '<p>Checkers will let you teach several methods. Simple lookahead, depth search of best-case-worst-case decisions, differences between short-term and long-term gains, and something they could continue to work on after learning what you want to teach them. </p>\n\n<p>Personally I think that last bit is the most critical -- there are natural points in the AI development which are good to stop at, see if you can beat it, and then delve into deeper AI mechanisms. It keeps your student interested without being horribly frustrated, and gives them more to do on their own if they want to continue the project.</p>\n'}, {'answer_id': 83505, 'author': 'Penfold', 'author_id': 11952, 'author_profile': 'https://Stackoverflow.com/users/11952', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://www.boardgamegeek.com/game/10060" rel="nofollow noreferrer">Rubik\'s Infinity</a>\'s quite fun, it\'s a little bit like Connect Four but subtly different. Evauluating a position is pretty easy.</p>\n\n<p>I knocked together a Perl script to play it a while back, and actually had to reduce the number of moves ahead it looked, or it beat me every time, usually with quite surprising tactics.</p>\n'}, {'answer_id': 129758, 'author': 'David Locke', 'author_id': 1447, 'author_profile': 'https://Stackoverflow.com/users/1447', 'pm_score': 0, 'selected': False, 'text': '<p>In regards to a better heuristic for dots and boxes, I suggest looking at online strategy guides for the game.  The <a href="http://cf.geocities.com/ilanpi/tutorial1.html" rel="nofollow noreferrer">first result</a> on Google for "dots and boxes strategy" is quite helpful.</p>\n\n<p>Knowing how to use the chain rule separates an OK player from a good one.  Knowing when the chain rule will work against you is what separates the best players from the good ones.</p>\n'}, {'answer_id': 500848, 'author': 'mdm', 'author_id': 25318, 'author_profile': 'https://Stackoverflow.com/users/25318', 'pm_score': 1, 'selected': False, 'text': '<p>I really like Connect Four. Very easy to program using a Minimax algorithm. A good evaluation function could be:</p>\n\n<pre><code>eval_score = 0\nfor all possible rows/lines/diagonals of length 4 on the board:\n    if (#player_pieces = 0) // possible to connect four here?\n        if (#computer_pieces = 4)\n            eval_score = 10000\n            break for loop\n        else\n            eval_score = eval_score + #computer_pieces\n            (less pieces to go -&gt; higher score)\n        end if\n    else if (#player_pieces = 4)\n        eval_score = -10000\n        break for loop\n    end if\nend for\n</code></pre>\n\n<p>To improve the program you can add:</p>\n\n<ol>\n<li>If computer moves first, play in the middle column (this has been proven to be optimal)</li>\n<li>Alpha-Beta Pruning</li>\n<li>Move Ordering</li>\n<li>Zobrist Hashes</li>\n</ol>\n'}]
['https://Stackoverflow.com/questions/76227', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12981/']