⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fivestoneprocess.cpp

📁 该工程是一个非常完整的,优化的五子棋源代码(VC),可以帮你学习路径选择算法和vc编程.
💻 CPP
📖 第 1 页 / 共 5 页
字号:

	ShowInfo("has_alive:"+passtime(cur_time));	thinkpos += 4;
	if (has_twolevel_four(color,count,tempresult))
	{
		//存在一个存在四子的二阶活子
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机找到强二阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four:"+passtime(cur_time));	thinkpos += 4;
	//1_____________________________________
	if (has_alive_defent(anticolor,count,tempresult))
	{
		//看对方是否存在活子
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的一阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_alive_defent:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_canfour(color,count,tempresult))
	{
		//不能防住对方的一阶活子,冲四
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机冲四!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_canfour:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_alive_defent_low(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的一阶活子low!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}	
	ShowInfo("has_alive_defent_low2:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_alive(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的一阶活子2!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_alive2:"+passtime(cur_time));	thinkpos += 4;
	//2_____________________________________
	if (has_twolevel_four_defent(anticolor,count,tempresult))
	{
		//存在一个存在四子的二阶活子
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的强二阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four_defent:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_canfour(color,count,tempresult))
	{
		//不能防住对方的强二阶活子,冲四
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机冲四!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_canfour:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_twolevel_four_defent_low(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的强二阶活子low!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four_defent_low2:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_twolevel_four(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的强二阶活子2!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four2:"+passtime(cur_time));	thinkpos += 4;
	//____________________________________________
	//不存在一阶活子,考察是否存在二阶活子
	if (has_twolevel_pure(color,count,tempresult))
	{
		//存在二阶活子,直接输出二阶活子(应从结果集中random选取)
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机找到二阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel:"+passtime(cur_time));	thinkpos += 4;
	if (has_qianmodel_addone(color,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机两个牵制子和一个已下子匹配!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_qianmodel_addone:"+passtime(cur_time));	thinkpos += 4;
	if (has_qianmodel(color,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机三个牵制子匹配!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_qianmodel:"+passtime(cur_time));	thinkpos += 4;
	if (has_twolevel_qianmodel(color,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机二阶牵制子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_qianmodel:"+passtime(cur_time));		thinkpos += 4;
	//3___________________________
	if (has_twolevel_defent(anticolor,count,tempresult))
	{
		//看对方是否存在二阶活子
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的二阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}	
	ShowInfo("has_twolevel_defent:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_canfour(color,count,tempresult))
	{
		//不能防住对方的二阶活子,冲四
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机冲四!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_canfour:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_twolevel_defent_low(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的二阶活子low!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_defent_low2:"+passtime(cur_time));	thinkpos += 4;
	if (!defent_success&&has_twolevel(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel(color,x,y,tempresult,count);
		common_info("找到人的二阶活子2!",debug,cur_time);
		isdanger = true;		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel2:"+passtime(cur_time));	thinkpos += 4;
	//4_________________________________
	if (has_qianmodel_addone(anticolor,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("人两个牵制子和一个已下子匹配!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_qianmodel_addone2:"+passtime(cur_time));		thinkpos += 4;
	//5_______________________________________
	if (has_qianmodel(anticolor,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("人三个牵制子匹配!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_qianmodel2:"+passtime(cur_time));	thinkpos += 4;
	//6________________________________________
	if (has_twolevel_qianmodel(anticolor,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("人二阶牵制子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_qianmodel2:"+passtime(cur_time));	thinkpos += 4;
	if (make_qianmodel(color,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机制造牵制子匹配!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("make_qianmodel:"+passtime(cur_time));	thinkpos += 4;
	//也不存在二阶活子,看能否制造活子
	/*
	if (make_twolevel(color,count,tempresult))
	{
		selectqianmodel(color,x,y,tempresult,count);
		common_info("计算机制造二阶活子!",debug,cur_time);
		return;
	}
	ShowInfo("make_twolevel:"+passtime(cur_time));
	*/
	getmax(count,tempresult);
	int tempi = random(0,count-1);
	x = tempresult[tempi].x;
	y = tempresult[tempi].y;
	common_info("赋值算法!",debug,cur_time);
	thinkpos = 100;
}
void FiveStoneProcess::getpoint5(int &x, int &y, int color,BOOL debug)
{
	//一共有53个算法,每个算法2%,即每个算法算完thinkpos都可以长2
	//如果return,那么一下置为100
	thinkpos = 0;
	//最高等级

	/*算法过程如下

  计算机找到一阶活子
  计算机找到强二阶活子
  计算机两个牵制子和一个已下子强匹配!
  计算机三个牵制子强匹配
  计算机二阶牵制子强匹配
  计算机三阶牵制子强匹配
  //**计算机强打击子
  找到人的一阶活子d
  找到人的强二阶活子d
  人两个牵制子和一个已下子强匹配d
  人三个牵制子强匹配d
  人二阶牵制子强匹配d
  //人三阶牵制子强匹配d 
  计算机找到二阶活子
  计算机两个牵制子和一个已下子匹配
  计算机三个牵制子匹配
  计算机二阶牵制子
  计算机三阶牵制子  
  **计算机打击子
  //**计算机二阶打击子>50不采用
  找到人的二阶活子d
  计算机冲三(color=2时,<20不采用)
  计算机冲四(color=2时,<20不采用)
  人两个牵制子和一个已下子匹配d
  人三个牵制子匹配d
  人二阶牵制子d
  //人三阶牵制子>50时不采用
  //**人强打击子>50时不采用
  //**计算机打击子_low
  //**计算机二阶打击子_low>50不采用
  **人打击子>50时不采用
  //**人二阶打击子>50时不采用  
  //计算机制造打击子
  //计算机制造二阶牵制子匹配
  //计算机制造三阶牵制子匹配  
  //计算机制造二阶活子
  //计算机冲二子和制造牵制子匹配(color=2时,<10不采用)  
  计算机冲二子(color=2时,<10不采用)
  计算机制造牵制子匹配(color=2时,<10不采用)
    
  赋值算法

	*/
	POINT tempresult[225];
	int count=0;	
	int anticolor;//对方的color
	if (color==1) anticolor = 2;
	else anticolor = 1;
	x=0;y=0;
	if (has_five(1)||has_five(2)) 
	{
		thinkpos = 100;
		return;//已经连成5子,什么都不做了
	}	thinkpos += 2;
	int cur_time = GetCurrentTime();
	if (can_five(color,x,y)) 
	{
		common_info("计算机可以连成5子!",debug,cur_time);		thinkpos = 100;
		return;//如果能连成5子,那么返回
	}
	ShowInfo("can_five1:"+passtime(cur_time));	thinkpos += 2;
	if (can_five(anticolor,x,y)) 
	{
		common_info("人可以连成5子!",debug,cur_time);		thinkpos = 100;
		return;//看对方能否连成5子
	}
	ShowInfo("can_five2:"+passtime(cur_time));	thinkpos += 2;
	if (has_alive(color,count,tempresult))
	{
		//存在活子,直接输出活子(应从结果集中random选取)
		selectqianmodel5(color,x,y,tempresult,count);		
		common_info("计算机找到一阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_alive:"+passtime(cur_time));	thinkpos += 2;
	if (has_twolevel_four(color,count,tempresult))
	{
		//存在一个存在四子的二阶活子
		selectqianmodel5(color,x,y,tempresult,count);
		common_info("计算机找到强二阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four:"+passtime(cur_time));
	thinkpos += 2;
	if (has_qianmodel_addone(color,count,tempresult,true))
		
	{
		
		selectqianmodel5(color,x,y,tempresult,count);
		
		common_info("计算机两个牵制子和一个已下子强匹配!",debug,cur_time);
		thinkpos = 100;
		return;
		
	}
	
	ShowInfo("has_qianmodel_addone_qiang:"+passtime(cur_time));
	thinkpos += 2;
	if (has_qianmodel(color,count,tempresult,true))
		
	{
		
		selectqianmodel5(color,x,y,tempresult,count);
		
		common_info("计算机三个牵制子强匹配!",debug,cur_time);
		thinkpos = 100;
		return;
		
	}
	
	ShowInfo("has_qianmodel_qiang:"+passtime(cur_time));	
	thinkpos += 2;
	if (has_twolevelqianmodel_qiang(color,count,tempresult))
		
	{
		
		selectqianmodel5(color,x,y,tempresult,count);
		
		common_info("计算机二阶牵制子强匹配!",debug,cur_time);
		thinkpos = 100;
		return;
		
	}
	
	ShowInfo("has_twolevelqianmodel_qiang:"+passtime(cur_time));	
	thinkpos += 2;
	if (has_threelevelqianmodel_qiang(color,count,tempresult))
		
	{
		
		selectqianmodel5(color,x,y,tempresult,count);
		
		common_info("计算机三阶牵制子强匹配!",debug,cur_time);
		thinkpos = 100;
		return;
		
	}
	
	ShowInfo("has_threelevelqianmodel_qiang:"+passtime(cur_time));	
	thinkpos += 2;
	/*

	if (has_qiang_beat(color,count,tempresult))
		
	{
		
		selectqianmodel5(color,x,y,tempresult,count);
		
		common_info("计算机强打击子!",debug,cur_time);
		
		return;
		
	}
	
	ShowInfo("has_qiang_beat:"+passtime(cur_time));
	*/
	//1_____________________________________
	if (has_alive_defent(anticolor,count,tempresult))
	{
		//看对方是否存在活子
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("找到人的一阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_alive_defent:"+passtime(cur_time));	thinkpos += 2;
	if (!defent_success&&has_canfour(color,count,tempresult))
	{
		//不能防住对方的一阶活子,冲四
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("计算机冲四!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_canfour:"+passtime(cur_time));	thinkpos += 2;
	if (!defent_success&&has_alive_defent_low(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("找到人的一阶活子low!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_alive_defent_low2:"+passtime(cur_time));	thinkpos += 2;
	if (!defent_success&&has_alive(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("找到人的一阶活子2!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_alive2:"+passtime(cur_time));	thinkpos += 2;
	//2_____________________________________
	if (has_twolevel_four_defent(anticolor,count,tempresult))
	{
		//存在一个存在四子的二阶活子
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("找到人的强二阶活子!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four_defent:"+passtime(cur_time));	thinkpos += 2;
	if (!defent_success&&has_canfour(color,count,tempresult))
	{
		//不能防住对方的强二阶活子,冲四
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("计算机冲四!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_canfour:"+passtime(cur_time));	thinkpos += 2;
	if (!defent_success&&has_twolevel_four_defent_low(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("找到人的强二阶活子low!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four_defent_low2:"+passtime(cur_time));	thinkpos += 2;
	if (!defent_success&&has_twolevel_four(anticolor,count,tempresult))
	{
		//还是不能防住,那么只挡某一个活子即可
		selectqianmodel5(color,x,y,tempresult,count,true);
		common_info("找到人的强二阶活子2!",debug,cur_time);		thinkpos = 100;
		return;
	}
	ShowInfo("has_twolevel_four2:"+passtime(cur_time));	thinkpos += 2;
	//____________________________________________

	
	//7____________________
	if (has_qianmodel_addone_defent(anticolor,count,tempresult,true))
		
	{
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -