However, when the successive pieces are deployed, Red
Convenience is sure to win. in Figure 7.
Figure 7. Win pattern
The above three types of chess can be fundamentally
avoided. When one player finishes the game, the other should
watch closely to prevent it from forming the above three
situations. Conversely, it gives us a way to improve our winning
percentage. For example, when an arresting move occurs, when
we fill in any marker position, if the opponent does not fill in
another position, the piece is connected. At this point, we can
break its hunting pattern and change it from passive to active.
Not all Hex programs take into account particular shapes and
offer solutions. In addition, the first step is usually placed in the
middle of the board, and experiments can prove that the side that
places the first piece in the middle is easy to win.
4. System Implementation
4.1 The realization of everyone versus everyone
The game player's control of the chess pieces requires the
occurrence of mouse click events. Clicking on a free call with
the mouse to move a piece requires the piece and the board to
communicate information directly and interact. The signals and
slots mechanism in QT Creator solves this problem effectively.
The connect() function is required to transport signals and
slots. Semaphores and slots are defined as signal() and slot
(), respectively. Each time a key is defined, a connect() is
executed so that the clock signal triggers the defined slot
function to pass the parameters.
Signal and slot declaration:
void on_Click(int row,int col);
void clickEmptyPoint(int row,int col);
Send a signal:
QObject:connect(ui.canvas,SIGNAL(clickEmptyPoi
nt(int,int)),
this,SLOT(on_Click(int,int)));
Receive a signal:
void app:on_Click(int row,int col)
{PlayerSetPiece(row,col);}
4.2 Realization of man-machine war
(1) Defined parameters: In terms of the preservation of
checkerboard data, we define the checkerboard as a
two-dimensional array of chess [11]. Everything in the array is
0; Because 0 means the current board is empty. Similarly, when
red plays, red is represented by an array of zeros; Blue is
represented as a 1 when blue plays. Specifically, the piece is
defined as a class, with Nexpnanded-access times of the
node; Children indicates the child node of the node. Index
Indicates basic parameters such as the index value of the current
node.
(2)Judge if it can play chess now: Judge whether the
current is the most advantageous: When the player drops a
piece, the whole board is searched as follows: First, the whole
board is searched for blank pieces to find the squares that can be
played. Second, after finding the position, through a random
function to obtain a position, and then check whether the current
position can play chess. If yes, select, expand, simulate, and
traceback from the current node. If not, continue to call a
random function to find another location.
(3)Judge if the current is the most advantageous:Computer
control of chess pieces mainly depends on the dynamic
establishment of game tree, with the help of UCT search
algorithm optimization completed. The following functions are
mainly used: selection function (), expansion function (),
simulation() and back().
void selection(Node *& current, disjointset::IDisjointSet
*uf);
void expand (Node *& current, disjointset::IDisjointSet
*uf);
color::Color simulation(Node *& current,
disjointset::IDisjointSet *uf);
void back(Node *& current, disjointset::IDisjointSet *uf,
const color:: color winner);
The entire search process is mainly implemented through
these four functions. If the current node has the highest chance
of evaluation, it increments Win and Total and returns row
arguments. Notice that at the end of one search, the parameter is
reinitialized to zero on the next search.
5. Experiments
5.1 Experimental scheme
Nowadays, there are more and more chess algorithms. The
application of the UCT algorithm in the Hex chess game is
verified by comparing it with the Hex chess game system which
adopts the traditional Monte Carlo algorithm as the search
algorithm. To obtain clear experimental results, the experiment
times were set as 1, 10, 50, and 100 times respectively, and then
the experiment was carried out in sequence. In addition, the
experiment compares the winning rate of the first and last hand
of the UCT algorithm in chess. In this experiment, the
coefficient C in the UCT formula is 2.
5.2 Experimental results
As shown in Table 1, when the system uses the UCT
algorithm for firsthand, when the number of experiments is 1,
10, and 100, the success rate is 100%. When the number of trials
was 100, the success rate was 98 percent. The results show that
the UCT algorithm is superior to the traditional Monte Carlo
algorithm when the system uses the UCT algorithm and plays
chess first.
WSEAS TRANSACTIONS on BUSINESS and ECONOMICS
DOI: 10.37394/23207.2022.19.148
Lingling Wang, Yiyang Wei, Feng Li