Information Technology Reference
In-Depth Information
first or the computer first. At the beginning of the game it prints the empty board. After
the first move, it assigns the turn to another player and wait for the move after which it
switches turns again. Every move will be recorded in a log file. After each move it
checks whether the turns must be switched and assigns the move to the player to move
next. For both players the same protocol is used every turn. First the current playing
field is printed then the move is made. After the move is made it is added to the move
list and updated in the playing field after which the structure list is updated by adjusting
all structures to the new situation.
Initialize chessboard
Switch turns
Player2 takes move
Player1 takes move
Update game structures
Check if can take
another move
End of game
Fig. 9. The simplest flow of Dots-and-Boxes playing system
z Chessboard representation
This playing board consists of n*m boxes. The playing field is stored in three arrays:
Square array, Horizontal edge array and Vertical edge array. In the square array, we
will store the each coin in the chessboard, including its location, the count of edges
connected to it. The Square array is a two-dimension array, it also stores the ground
node existed in the Strings-and-Coins. The ground nodes are not like the nodes in the
center area, the degree of each ground node is 1, that means only one edge connected to
it at most. But the other coins will each has four edges connected to it, and it will have
the degree of four. When the node is formed which is also means the four edges are all
removed from it, its property of degree will be zero, and this coin will be got by one
player, and its value of property owner will indicate this player.
The type of the elements of Square array is Node, the detailed definition of class
node is represented by Fig.10.In this class the pointer array edge[4] is used for storing
the four strings connected to each coin, and the property degree represents the count of
strings connected to one coin.
We will store all the horizontal edges in the Horizontal edge array, each edge has the
information of the two nodes to which it is connected, and this is similarly to vertical
edges. Each edge will have the property of removed, when it is removed from one
connected coin, the value of this property will be one. Each array element in the hori-
zontal array imply indicates the location of one horizontal string and the information
Search WWH ::




Custom Search