提交 46763e5c 编写于 作者: D dev@dev.com

AI规模可输入

上级 7cfc60bc
......@@ -29,7 +29,8 @@ struct chess_node{
char depth = 0;
char killed = 0;
};
extern int max_depth;
extern int max_nodes;
//走位和显示
//-------------------------------------------
......
......@@ -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;
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册