Volume 10, Issue 2 Articles In and Out Trott's Corner Beyond Sudoku New Products New Publications Calendar News Bulletins New Resources Classifieds Download This Issue Editorial Policy Staff and Contributors Submissions Subscriptions Advertising Back Issues Contact Information 
Exploring Board Game Strategies
Analysis and StrategiesIn this section, we will show how easy it is to make the computer play on its own in order to analyze games or analyze, study, and improve playing strategies. We will focus again on the HMaki game, which is complex enough to demonstrate how powerful the analysis can be with our design.
Automatic PlayAs randomness is involved in the initialization of the game, we need to play repeatedly to study the game with statistical tools. So the computer should be able to play a game alone and give us feedback on it. ScoringWe are interested in the final score and the number of plays necessary to reach the end. Moreover, we consider two kind of scores: the number of remaining tiles and the sum of the scores obtained for removing each group of tilesgrowing with the square of the size of the group. The global value Score contains a list of this information; it is initialized by InitScore and updated by UpdateScore.
Where to PlayBefore playing, the computer should know where it is valid to play and then where to play. The function PlayableList computes the list of all the playable locations on the board, using an almost trivial algorithm.
The GetPlay function is rewritten to randomly select an element in the list of playable locations.
PlayingWe define BatchPlayGame, an analog function to PlayGame, to make the computer play. Note the presence of the bound MaxPlay to avoid infinite loops and the call to SeedRandom to control random initialization of the board and select a play among the list of possible beginnings.
In the preceding results, the high computation time is due to the poor implementation of PlayableList: 76 is the number of plays in the game; 270 is the score when "playing for big"; and 60 is the number of remaining tiles. Statistical AnalysisOnce the computer is able to play alone and produce information on the game, we can make it play enough games to give us statistical results. Let us conduct an experiment. Playing 100 GamesThe first experiment consists of playing 100 different games; the second in playing the same game 100 times.
Statistical standard functions describe the dispersion of this data.
We can view the data using standard graphical functions for plotting.
The fairly even dispersion we observe in these graphics is a testimony to the interest of the game for a human player. StrategiesAnother goal of statistical analysis is to compare strategies and get a better understanding of how to play. GroupsSimple strategies for playing HMaki are based on knowledge of the different groups of tiles of the same colors. The SpotList function returns the list of the groups computed from the board.
StrategiesA new version of BatchPlayGame takes an integer argument as an index of the selected strategy, and an option for visualization.
Different instances of GetPlay correspond to different strategies of selecting the group of tiles to remove: 0the group is randomly selected in the list of groups 1the group is randomly selected among the biggest groups 2the first biggest group (starting from the upperleft corner, then from left to right and top to bottom) 3the group is randomly selected among the smallest groups 4the first smallest group (starting from the upperleft corner, then from left to right and top to bottom)
ExperimentResults of 170 games were collected10 different games played 17 times: five times for the strategies involving randomness, only once for the two others. These results took several minutes to produce.
The following command produces the results in Table 1.
Table 1. Mean of the results over 10 games. We can also visualize these results with an ad hoc plot function. The following plots show the numbers of remaining tiles for the first strategy.


About Mathematica  Download Mathematica Player © Wolfram Media, Inc. All rights reserved. 