Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
杨家三木
qtcpp_demo
提交
7cfc60bc
qtcpp_demo
项目概览
杨家三木
/
qtcpp_demo
与 Fork 源项目一致
Fork自
colorEagleStdio / qtcpp_demo
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
qtcpp_demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7cfc60bc
编写于
6月 06, 2021
作者:
D
dev@dev.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
降低内存开销
上级
d4863242
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
14 deletion
+15
-14
chesspi/chesspi.h
chesspi/chesspi.h
+3
-3
chesspi/chesspi_ai.cpp
chesspi/chesspi_ai.cpp
+3
-3
chesspi/chesspi_rules.cpp
chesspi/chesspi_rules.cpp
+8
-7
chesspi/main.cpp
chesspi/main.cpp
+1
-1
未找到文件。
chesspi/chesspi.h
浏览文件 @
7cfc60bc
...
...
@@ -23,7 +23,7 @@ struct chess_node{
//遍历
float
weight
=
1
;
unsigned
int
parent
=
0
;
unsigned
int
leaves
=
0
;
//
unsigned int leaves = 0;
float
jump_cost
[
2
]{
0
,
0
};
//跳转损失
char
side
=
0
;
char
depth
=
0
;
...
...
@@ -44,8 +44,8 @@ void print_node(const chess_node & node,const chess_node & old_node);
//X镜像反转坐标
void
mirror_coordx
(
const
unsigned
char
cod1
[
/*32*/
],
unsigned
char
cod2
[
/*32*/
]);
//计算棋盘哈希
std
::
vector
<
s
td
::
string
>
node2hash
(
const
std
::
vector
<
chess_node
>
&
nodes
);
s
td
::
string
node2hash
(
const
unsigned
char
cod
[
/*32*/
],
const
unsigned
int
alive
);
std
::
vector
<
s
ize_t
>
node2hash
(
const
std
::
vector
<
chess_node
>
&
nodes
);
s
ize_t
node2hash
(
const
unsigned
char
cod
[
/*32*/
],
const
unsigned
int
alive
);
//AI
//-------------------------------------------
...
...
chesspi/chesspi_ai.cpp
浏览文件 @
7cfc60bc
...
...
@@ -93,7 +93,7 @@ float calc_cost(const int coordx[/*32*/], const int coordy[/*32*/],const int ali
std
::
vector
<
chess_node
>
build_tree
(
const
chess_node
&
root
,
const
int
side
,
const
std
::
vector
<
chess_node
>
&
history
)
{
std
::
vector
<
chess_node
>
tree
;
std
::
unordered_set
<
s
td
::
string
>
dict
;
std
::
unordered_set
<
s
ize_t
>
dict
;
for
(
const
chess_node
&
n
:
history
)
dict
.
insert
(
node2hash
(
n
.
coords
,
n
.
alive
));
tree
.
push_back
(
root
);
...
...
@@ -133,7 +133,7 @@ std::vector<chess_node> build_tree(const chess_node & root, const int side,const
const
size_t
sz
=
next_status
.
size
();
for
(
size_t
j
=
0
;
j
<
sz
;
++
j
)
{
s
td
::
string
ha
=
node2hash
(
next_status
[
j
].
coords
,
next_status
[
j
].
alive
);
s
ize_t
ha
=
node2hash
(
next_status
[
j
].
coords
,
next_status
[
j
].
alive
);
bool
needI
=
false
;
#pragma omp critical
{
...
...
@@ -157,7 +157,7 @@ std::vector<chess_node> build_tree(const chess_node & root, const int side,const
next_status
[
j
].
side
=
curr_side
;
next_status
[
j
].
depth
=
clock
+
1
;
vec_appends
[
tid
].
push_back
(
next_status
[
j
]);
++
tree
[
i
].
leaves
;
//
++tree[i].leaves;
++
new_appends
;
if
(
new_appends
%
1000
==
0
)
{
...
...
chesspi/chesspi_rules.cpp
浏览文件 @
7cfc60bc
...
...
@@ -367,7 +367,8 @@ void print_node(const chess_node & node,const chess_node & old_node)
int
alive_o
[
32
]{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
std
::
string
nhash
=
node2hash
(
node
.
coords
,
node
.
alive
);
size_t
nhash
=
node2hash
(
node
.
coords
,
node
.
alive
);
printf
(
"HASH=%X
\n
"
,
nhash
);
for
(
int
i
=
0
;
i
<
32
;
++
i
)
{
coordx
[
i
]
=
node
.
coords
[
i
]
>>
4
;
...
...
@@ -376,8 +377,6 @@ void print_node(const chess_node & node,const chess_node & old_node)
coord_oy
[
i
]
=
old_node
.
coords
[
i
]
&
0x0f
;
alive
[
i
]
=
(
node
.
alive
&
(
1
<<
i
))
?
1
:
0
;
alive_o
[
i
]
=
(
old_node
.
alive
&
(
1
<<
i
))
?
1
:
0
;
//printf ("%X",((unsigned char)(nhash[i]))>>4);
//printf ("%X",((unsigned char)(nhash[i]))&0x0F);
}
//printf ("\n");
//制作坐标站位表
...
...
@@ -446,16 +445,16 @@ void print_node(const chess_node & node,const chess_node & old_node)
}
std
::
vector
<
s
td
::
string
>
node2hash
(
const
std
::
vector
<
chess_node
>
&
nodes
)
std
::
vector
<
s
ize_t
>
node2hash
(
const
std
::
vector
<
chess_node
>
&
nodes
)
{
std
::
vector
<
s
td
::
string
>
v
;
std
::
vector
<
s
ize_t
>
v
;
const
size_t
sz
=
nodes
.
size
();
for
(
size_t
i
=
0
;
i
<
sz
;
++
i
)
v
.
push_back
(
node2hash
(
nodes
[
i
].
coords
,
nodes
[
i
].
alive
));
return
v
;
}
s
td
::
string
node2hash
(
const
unsigned
char
coords
[
/*32*/
],
const
unsigned
int
alive
)
s
ize_t
node2hash
(
const
unsigned
char
coords
[
/*32*/
],
const
unsigned
int
alive
)
{
std
::
string
res
;
std
::
string
str1
;
...
...
@@ -512,7 +511,9 @@ std::string node2hash(const unsigned char coords[/*32*/], const unsigned int ali
else
res
=
str1
+
str2
;
return
res
;
std
::
hash
<
std
::
string
>
ha
;
size_t
r
=
ha
(
res
);
return
r
;
}
void
mirror_coordx
(
const
unsigned
char
cod1
[
/*32*/
],
unsigned
char
cod2
[
/*32*/
])
...
...
chesspi/main.cpp
浏览文件 @
7cfc60bc
...
...
@@ -16,7 +16,7 @@ int main()
int
coordx
[
32
]{
5
,
4
,
6
,
3
,
7
,
2
,
8
,
1
,
9
,
2
,
8
,
1
,
3
,
5
,
7
,
9
,
5
,
4
,
6
,
3
,
7
,
2
,
8
,
1
,
9
,
2
,
8
,
1
,
3
,
5
,
7
,
9
};
int
coordy
[
32
]{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
3
,
3
,
4
,
4
,
4
,
4
,
4
,
10
,
10
,
10
,
10
,
10
,
10
,
10
,
10
,
10
,
8
,
8
,
7
,
7
,
7
,
7
,
7
};
int
alive
[
32
]{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
printf
(
"Node Size=%lu Bytes
\n
"
,
sizeof
(
chess_node
));
srand
(
time
(
0
));
chess_node
root
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录