提交 f23b3dd2 编写于 作者: M manjaro

改进加权

上级 46763e5c
......@@ -15,7 +15,7 @@ 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};
static const unsigned int table_cost[16] = {100000,150,150,150,150,150,150,2000,2000,150,150,100,100,100,100,100};
/*!
* \brief calc_cost 计算走位后,idx棋子被击杀的代价,并返回
* \param coordx 当前各个棋子的X坐标
......@@ -43,28 +43,19 @@ float calc_cost(const int coordx[/*32*/], const int coordy[/*32*/],const int ali
//马战线挺进,以及后期击杀价值高
case 5:
case 6:
if (idx<16 )
rescost *= 1+(coordy[idx]/3.0);
else
rescost *= 1+((11-coordy[idx])/3.0);
rescost *= 1 + killed / 4.0;
rescost *= 1+((11-coordy[idx])/3.0);
rescost *= 1 + killed / 10.0;
break;
//车战线击杀高
case 7:
case 8:
if (idx<16 )
rescost *= 1+(coordy[idx]/3.0);
else
rescost *= 1+((11-coordy[idx])/3.0);
rescost *= 1+((11-coordy[idx])/3.0);
break;
//炮前期击杀高
case 9:
case 10:
if (idx<16 )
rescost *= 1+(coordy[idx]/3.0);
else
rescost *= 1+((11-coordy[idx])/3.0);
rescost *= 1 + (32 - killed) / 4.0;
rescost *= 1+((11-coordy[idx])/3.0);
rescost *= 1 + (32 - killed) / 10.0;
break;
//卒过河击杀高
case 11:
......@@ -72,10 +63,7 @@ float calc_cost(const int coordx[/*32*/], const int coordy[/*32*/],const int ali
case 13:
case 14:
case 15:
if (idx<16 )
rescost *= coordy[idx]>5?4:1;
else
rescost *= coordy[idx]<6?4:1;
rescost *= coordy[idx]<6?4:1;
//当头卒价值高
if (coordx[idx]==5)
rescost *=5;
......@@ -98,7 +86,7 @@ std::vector<chess_node> build_tree(const chess_node & root, const int side,const
size_t curr_i = 0;
//要停留在敌走的偶数步
const int stop_depth = (max_depth+1)/2 * 2;
printf ("Max Nodes = %d\n",max_nodes);
while (tree.size()<=max_nodes && curr_i<tree.size())
{
const size_t ts = tree.size();
......
......@@ -35,7 +35,7 @@ int main()
scanf("%d",&nodesInM);
if (depthInM>=4 && depthInM<10)
max_depth = depthInM;
if (nodesInM>=1 && nodesInM<128)
if (nodesInM>=1 && nodesInM<=128)
max_nodes = nodesInM*1000*1000;
//回合
side %=2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册