Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
chain78
qtcpp_demo
提交
46763e5c
qtcpp_demo
项目概览
chain78
/
qtcpp_demo
与 Fork 源项目一致
Fork自
colorEagleStdio / qtcpp_demo
通知
1
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 搜索 >>
提交
46763e5c
编写于
6月 06, 2021
作者:
D
dev@dev.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AI规模可输入
上级
7cfc60bc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
15 deletion
+14
-15
chesspi/chesspi.h
chesspi/chesspi.h
+2
-1
chesspi/chesspi_ai.cpp
chesspi/chesspi_ai.cpp
+2
-8
chesspi/main.cpp
chesspi/main.cpp
+10
-6
未找到文件。
chesspi/chesspi.h
浏览文件 @
46763e5c
...
...
@@ -29,7 +29,8 @@ struct chess_node{
char
depth
=
0
;
char
killed
=
0
;
};
extern
int
max_depth
;
extern
int
max_nodes
;
//走位和显示
//-------------------------------------------
...
...
chesspi/chesspi_ai.cpp
浏览文件 @
46763e5c
...
...
@@ -12,6 +12,8 @@
#include "chesspi.h"
int
max_depth
=
5
;
int
max_nodes
=
1000
*
1000
*
32
;
//棋子代价
static
const
unsigned
int
table_cost
[
16
]
=
{
100000
,
150
,
150
,
150
,
150
,
150
,
150
,
500
,
500
,
150
,
150
,
100
,
100
,
100
,
100
,
100
};
/*!
...
...
@@ -25,11 +27,8 @@ static const unsigned int table_cost[16] = {100000,150,150,150,150,150,150,500,5
*/
float
calc_cost
(
const
int
coordx
[
/*32*/
],
const
int
coordy
[
/*32*/
],
const
int
alive
[
/*32*/
],
const
int
killed
,
const
int
idx
)
{
// * 帅士士相相马马车车炮炮兵兵兵兵兵 將仕仕象象馬馬車車砲砲卒卒卒卒卒
assert
(
idx
>=
16
);
unsigned
int
rescost
=
table_cost
[
idx
%
16
];
//位置加权
switch
(
idx
%
16
)
{
...
...
@@ -84,9 +83,6 @@ float calc_cost(const int coordx[/*32*/], const int coordy[/*32*/],const int ali
default:
break
;
}
return
rescost
;
}
...
...
@@ -99,9 +95,7 @@ std::vector<chess_node> build_tree(const chess_node & root, const int side,const
tree
.
push_back
(
root
);
tree
[
0
].
side
=
side
%
2
;
tree
[
0
].
depth
=
0
;
int
max_nodes
=
1000
*
1000
*
32
;
size_t
curr_i
=
0
;
//要停留在敌走的偶数步
const
int
stop_depth
=
(
max_depth
+
1
)
/
2
*
2
;
...
...
chesspi/main.cpp
浏览文件 @
46763e5c
...
...
@@ -9,7 +9,7 @@
#include <ctime>
#include <unordered_set>
#include "chesspi.h"
extern
int
max_depth
;
int
main
()
{
//初始棋局
...
...
@@ -26,13 +26,17 @@ int main()
return
0
;
}
int
side
=
0
;
int
nodesInM
=
0
;
printf
(
"
Side(0=RED,1=BLACK
):"
);
int
nodesInM
=
0
,
depthInM
=
0
;
printf
(
"
持子(0=红,1=黑
):"
);
scanf
(
"%d"
,
&
side
);
printf
(
"Max Depth(default 5):"
);
printf
(
"AI最大深度(3-10,建议5):"
);
scanf
(
"%d"
,
&
depthInM
);
printf
(
"AI最大节点(M,1-128,建议32):"
);
scanf
(
"%d"
,
&
nodesInM
);
if
(
nodesInM
>=
4
&&
nodesInM
<
10
)
max_depth
=
nodesInM
;
if
(
depthInM
>=
4
&&
depthInM
<
10
)
max_depth
=
depthInM
;
if
(
nodesInM
>=
1
&&
nodesInM
<
128
)
max_nodes
=
nodesInM
*
1000
*
1000
;
//回合
side
%=
2
;
if
(
side
<
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录