-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-1.fixed-kill-search-time-waste-condition.patch
191 lines (171 loc) · 6.99 KB
/
0001-1.fixed-kill-search-time-waste-condition.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
From 3237fd9a6662e8f7c6b0b98e697ca5027f78d14b Mon Sep 17 00:00:00 2001
From: guokla <[email protected]>
Date: Sat, 16 May 2020 14:58:12 +0800
Subject: [PATCH] 1.fixed kill search time waste condition. 2.add oppsite rush
four judgement in distance. 3.fixed cut nodes for move queue order.
---
mainwindow.h | 2 +-
mythread.cpp | 65 ++++++++++++++++++++++------------------------------
2 files changed, 29 insertions(+), 38 deletions(-)
diff --git a/mainwindow.h b/mainwindow.h
index 0053f39..5376fc8 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -60,7 +60,7 @@ const long long HASH_TABLE_SIZE = 1 << 22; // 哈希表大小
//#define FLOAT_CENTER
// const int chessValue[] = {1,2,2,3,3,5,5,50,80,120,200};
-const int chessValue[] = {2,8,8,16,32,48,64,250,600,1000,2000};
+const int chessValue[] = {2,8,8,24,32,48,64,250,600,1000,2000};
#define ONE 1
#define TWO 10
diff --git a/mythread.cpp b/mythread.cpp
index aae3480..b2ca66c 100644
--- a/mythread.cpp
+++ b/mythread.cpp
@@ -216,6 +216,7 @@ bool inline MyThread::inside(Pos move){
int MyThread::deepSearch(Pos& ret, int origin, int key, int deep, int rec, int alpha, int beta, QVector<Pos>& path)
{
int i, j, p1, p2, k, dx, dy;
+ Pos newMove;
QVector<Pos> attackQueue, vec_moves;
if(t2.elapsed() > limit){
@@ -227,6 +228,10 @@ int MyThread::deepSearch(Pos& ret, int origin, int key, int deep, int rec, int a
if(rec > deep && path.last().a1 >= 10000)
return -R_INFINTETY;
+ if(lookup(deep, alpha, beta, newMove)){
+ return newMove.value;
+ }
+
// 获取着法
for (i = 0; i < 15; i++){
for (j = 0; j < 15; j++){
@@ -288,7 +293,7 @@ int MyThread::deepSearch(Pos& ret, int origin, int key, int deep, int rec, int a
else if(attackQueue[i].a3 >= 100){
dx = abs(attackQueue[i].x - attackQueue[0].x);
dx = abs(attackQueue[i].y - attackQueue[0].y);
- if(Max(dx, dy) <= 4)
+ if(Max(dx, dy) <= 3)
vec_moves.push_back(attackQueue[i]);
}
}
@@ -319,6 +324,7 @@ int MyThread::deepSearch(Pos& ret, int origin, int key, int deep, int rec, int a
move.value = - deepSearch(ret, origin, 3-key, deep-1, rec, -beta, -alpha, path);
else{
move.value = evaluate(key);
+ store(mutex, HASH_EXACT, hash, move, 1);
}
path.pop_back();
@@ -339,7 +345,7 @@ int MyThread::deepSearch(Pos& ret, int origin, int key, int deep, int rec, int a
int MyThread::killSearch(Pos& ret, int key, int deep, int alpha, int beta, QVector<Pos>& path)
{
- int i, j, p1, p2, k;
+ int i, j, p1, p2, k, dx, dy;
int hashf = HASH_ALPHA;
long long hashIndex, hashBest;
Pos newMove, bestMove;
@@ -390,9 +396,16 @@ int MyThread::killSearch(Pos& ret, int key, int deep, int alpha, int beta, QVect
for(i=0; attackQueue[i].value >= 1000 && i < attackQueue.size(); i++)
vec_moves.push_back(attackQueue[i]);
- for(; i < attackQueue.size(); i++)
- if(attackQueue[i].a1 + attackQueue[i].a3 >= 100)
+ for(; i < attackQueue.size(); i++){
+ if(attackQueue[i].a1 >= 100)
vec_moves.push_back(attackQueue[i]);
+ else if(attackQueue[i].a3 >= 100){
+ dx = abs(attackQueue[i].x - attackQueue[0].x);
+ dx = abs(attackQueue[i].y - attackQueue[0].y);
+ if(Max(dx, dy) <= 4)
+ vec_moves.push_back(attackQueue[i]);
+ }
+ }
}
// 普通情况
else
@@ -453,9 +466,10 @@ int MyThread::killSearch(Pos& ret, int key, int deep, int alpha, int beta, QVect
int MyThread::checkSearch(Pos& ret, int origin, int key, int deep, int rec, int alpha, int beta, QVector<Pos>& path)
{
int i, j, p1, p2, k, dx, dy;
+ Pos newMove;
QVector<Pos> attackQueue, vec_moves;
- if(t2.elapsed() > limit/2){
+ if(t2.elapsed() > 2*limit/3){
if(runing) runing = false;
return alpha;
}
@@ -464,6 +478,10 @@ int MyThread::checkSearch(Pos& ret, int origin, int key, int deep, int rec, int
if(rec > deep && path.last().a1 >= 10000)
return -R_INFINTETY;
+ if(lookup(deep, alpha, beta, newMove)){
+ return newMove.value;
+ }
+
// 获取着法
for (i = 0; i < 15; i++){
for (j = 0; j < 15; j++){
@@ -527,7 +545,7 @@ int MyThread::checkSearch(Pos& ret, int origin, int key, int deep, int rec, int
else if(attackQueue[i].a3 >= 100){
dx = abs(attackQueue[i].x - attackQueue[0].x);
dx = abs(attackQueue[i].y - attackQueue[0].y);
- if(Max(dx, dy) <= 4)
+ if(Max(dx, dy) <= 3)
vec_moves.push_back(attackQueue[i]);
}
}
@@ -558,6 +576,7 @@ int MyThread::checkSearch(Pos& ret, int origin, int key, int deep, int rec, int
move.value = - checkSearch(ret, origin, 3-key, deep-1, rec, -beta, -alpha, path);
else{
move.value = evaluate(key);
+ store(mutex, HASH_EXACT, hash, move, 1);
}
path.pop_back();
@@ -773,7 +792,7 @@ void MyThread::cutTreeNode(QVector<Pos>& queue_move, QVector<Pos>& vec_moves, QV
return;
Pos newMove;
- int MaxDeep=16, val, pri[60]={0}, i;
+ int MaxDeep=14, val, pri[60]={0}, i;
for(int d = 2; d <= MaxDeep; d += 2){
@@ -791,11 +810,9 @@ void MyThread::cutTreeNode(QVector<Pos>& queue_move, QVector<Pos>& vec_moves, QV
powerOperation(move.x, move.y, FLAGS_POWER_RELEASE, key);
if(runing){
- newMove.value = val;
- if(newMove.value >= chessValue[10]){
+ if(val >= chessValue[10]){
pri[i] = d;
- if(openlog)
- qDebug("[%d,%d]=%d", move.x, move.y, d);
+ if(openlog) qDebug("[%d,%d]=%d", move.x, move.y, d);
}
}
@@ -807,32 +824,6 @@ void MyThread::cutTreeNode(QVector<Pos>& queue_move, QVector<Pos>& vec_moves, QV
if(pri[i] == 0)
vec_moves.push_back(queue_move[i]);
-// for(Pos &move: queue_move){
-
-// powerOperation(move.x, move.y, FLAGS_POWER_CONDESE, key);
-// path.push_back(move);
-
-// move.a3 = 0;
-// for(int d = 2; d <= MaxDeep; d += 2){
-// val = checkSearch(newMove, 3-key, 3-key, d, d, -R_INFINTETY, R_INFINTETY, path);
-// if(runing){
-// newMove.value = val;
-// if(newMove.value >= chessValue[10])
-// move.a3 = d;
-// break;
-// }
-// }
-
-// if(openlog)
-// qDebug("[%d,%d,%d]=%d", move.x, move.y, move.a3, newMove.value);
-
-// path.pop_back();
-// powerOperation(move.x, move.y, FLAGS_POWER_RELEASE, key);
-
-// if(newMove.value < chessValue[10])
-// vec_moves.push_back(move);
-// }
-
// 当全为必败着法时,保存最长的结果
if(vec_moves.isEmpty()){
--
2.23.0.windows.1