Step-by-step analysis of wuziqi AI [5] key issues-static search

Source: Internet
Author: User

The table is still being replaced, but there are still some problems, so it will be extended for a while after the meeting. But it is clear that, using a hash table is indeed not as fast as an array (ideally, using a pure alpha-beta tailoring and empty strokes tailoring-this is my initial design and there are no other techniques, iterations can be processed at least 7 times, 8 times, or even 10 times. However, if you add other code, the speed will decrease. That is to say, our evaluation function is still too slow and slow, but even if we make various tailoring, the complexity of wuziqi is still very high. This is also the reason .), So most of the code is still learning from the open-source chess engine. After all, my goal is not to write a great wuziqi engine, but to introduce these technologies and use VB. NET code to demonstrate them. Now, let's get down to the truth.

1. What is static search?

It is a function used to evaluate the situation after reaching the specified depth (iterative deepening) and is a further extension of the situation evaluation. It is an alpha-beta tailoring that does not contain deep parameters and is very "arbitrary". It only evaluates the opponent's playing chess or the opponent's playing chess.

2. Why static search?

The best method we can find after searching several steps is "fail", that is, to further check the reliability of the method.

3. How to Implement static search

Just write it like the alpha-beta tailoring function. Just make a slight modification to the condition so that it can only analyze the opponent's playing chess and the opponent's playing chess:

 

 

'====================================== Static search ==== ====================================
'The static (Quiescence) search process is actually very similar to alpha-beta Search, but the target is different. AB search exits when it reaches the depth, no matter what happens below, even if the next step can be used to kill games.
'While static search is an extension of AB search, it will handle these situations.
Private Function SearchQuiesc (vlAlpha As Integer, vlBeta As Integer) As Integer
Dim I, nGenMoves As Integer
NGenMoves =-1
Dim vl, vlBest As Integer
Dim mvs (MAX_GEN_MOVES) As Byte
'A static search can be divided into the following phases:
'1. Return situation evaluation when the limit depth is reached
If pos. nDistance = LIMIT_DEPTH Then Return pos. Evaluate ()
'2. initialize the best value
VlBest =-MATE_VALUE 'so that you can know whether you have never walked through the same method (kicker)

'Evaluate the situation
Vl = pos. Evaluate ()
If vl =-3000 Then
& Apos; 3. If you are playing a game, use all the playing points as the way to go.
For I = 0 To pos. Vectors. lnkinf. Count-1
For j = 0 To pos. Vectors. lnkinf (I). cqpend
NGenMoves + = 1
Mvs (nGenMoves) = pos. Vectors. lnkinf (I). cqp (j)
Next
Next
Else
'4. If you are not playing the game, evaluate the situation first.
If vl> vlBest Then
VlBest = vl
If vl> = vlBeta Then
Return vl
End If
If vl> vlAlpha Then
VlAlpha = vl
End If
End If
'5. If the evaluation result is not truncated, the system generates a dash chart. The dash chart itself does not need to be sorted again.
If vl = 3000 then', there is no need to evaluate the game, and there is no way to go. The 6 loop will be skipped and directly enter the final evaluation.
'The actually these rows are exactly the same as those in 3 and can be extracted, but they are listed separately for clearer structure.
For I = 0 To pos. Vectors. lnkinf. Count-1
For j = 0 To pos. Vectors. lnkinf (I). cqpend
NGenMoves + = 1
Mvs (nGenMoves) = pos. Vectors. lnkinf (I). cqp (j)
Next
Next
End If
End If

'6. perform these steps one by one and perform recursion
For I = 0 To nGenMoves
Pos. AddPiece (mvs (I ))
Vl =-SearchQuiesc (-vlBeta,-vlAlpha)
Pos. DelPiece (mvs (I ))
'7. Alpha-Beta size determination and truncation
If vl> vlBest then' find the optimal value (but it cannot be determined whether it is Alpha, PV or Beta)
VlBest = vl '"vlBest" is the best value to be returned, which may exceed the Alpha-Beta boundary.
If vl> = vlBeta then' find a Beta chart
Return vl 'beta Truncation
End If
If vl> vlAlpha then' find a PV route
VlAlpha = vl 'narrow the Alpha-Beta Boundary
End If
End If
Next
'8. All the methods have been searched, and the best value is returned.
Return IIf (vlBest =-MATE_VALUE, pos. nDistance-MATE_VALUE, vlBest)
End Function
'====================================== Static search end = ======================================

 

In chess, the situation of being played by generals is very similar to that of playing chess. However, it is often necessary to generate all the moves for a chess game by generals, because the problem can be solved by consuming the generals, mats, and routes. However, this is not the case for wuziqi, wuziqi considers the opponent's playing point. Maybe it's time to consider whether he is farther away than Fang Chong.

 

Well, this set is here. For the replacement table, first mention it. The name of the replace table is really unpleasant, because it is a "History Table ", it's just that the term "History Table" has been occupied early -- it records which points in the search process may produce a better way to sort the subsequent searches. Therefore, the replacement table is also a historical table, which records the chess score obtained after a certain depth of search. The depth here refers to the depth of iterations, And the chess model itself records the number of "Steps", because the number of chess pieces required to form the same situation is the same, but no matter the order. We need to consider when to record the change of the situation. Of course, this includes the sub-item and the sub-item. Do we need to consider empty step tailoring? How to record, how to extract, and so on. Now, we will announce it here.

 

Source code of this set:

/Files/zcsor/qingyue lianzhu 0.5.7z

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.