Under the address: http://files.cnblogs.com/helimin19/Gobang.rar
Let's talk about the real principle of wuziqi I think: determine whether there are five pieces in the same direction as the forward direction, backward direction, oblique direction, and reverse direction.
Now, we analyze the current principles with OO ideas:
Wuziqi is basically a game player. It is made up of a grid, so we get two maps: The game player and the game player grid.
First, let's analyze the basic unit elements and methods of wuziqi:
Adequacy:
1. The size of a single cell exists, so we can specify the allocation and height.
2. when a single cell is placed in a chess game, we can use top, bottom, left, right, topright, bottomright, bottomleft, and topleft for the single cell in eight directions.
3. We can use topnumber, rightnumber, bottomnumber, leftnumber, toprightnumber, bottomrightnumber, bottomleftnumber, and topleftnumber to represent the same number of pawns in eight directions.
4. whether a single cell contains pawns. We use player for representation. For example, if we use 1, it indicates that the cell contains white, 2 indicates that the cell contains sunspots, and 0 indicates that no pawns are stored.
5. When a single cell is placed in the chess game, we use rowindex and celindex to indicate the forward and backward indexes of the single cell in the chess game.
Event:
When we perform this operation in a single cell, we will add corresponding pawns to the single cell, and set the number of chess pieces in the same eight sides and the number of chess pieces in the corresponding eight-direction unit cell (this is related)
As far as the opponent of the game is very simple, there is no need to worry about it. It will be clear at the first glance on behalf of the game.
Finally, build a game partner
Attention should be paid to the anti-fraud games. The chess games we see are different from those controlled by the real players.
In fact, the current control game is the game we can play on (we play in the grid)
The chess scene we see: in order to make it look like a game on the grid, we have added a chess scene we can see, it shows that the effect is half a unit cell different from the actually controlled chess game.