当前位置: 首页>>代码示例>>C++>>正文


C++ AI::get_move方法代码示例

本文整理汇总了C++中AI::get_move方法的典型用法代码示例。如果您正苦于以下问题:C++ AI::get_move方法的具体用法?C++ AI::get_move怎么用?C++ AI::get_move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AI的用法示例。


在下文中一共展示了AI::get_move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_move

void Board::get_move(bool is_2_player_game, AI &_AI,int cur_player){
	Board cur_board_ = *this;
	if (is_2_player_game == false && cur_player == _AI._AI_player)
		place(_AI.get_move(cur_board_, cur_player,-(1<<30),(1<<30)).position, cur_player);
	else{
		while (readMove(cur_player) == false);
	}
	return;
}
开发者ID:magdy-hasan,项目名称:XO,代码行数:9,代码来源:Board.cpp

示例2: play_game


//.........这里部分代码省略.........
			}
			if(connect(AI_sock, (struct sockaddr *)&sin, sizeof(sin))){
				error=true;
			}
			string s;
			if(error){
					socket_write(sock,"ILLEGAL\n;Command is valid, but unable to connect with specified server\n");
			}
			else{
				socket_write(sock,"OK\n");
				socket_write(sock,socket_read(AI_sock));
				socket_write(AI_sock,"HUMAN-AI");
				socket_write(sock,"HUMAN-AI\n");
				socket_write(sock,socket_read(AI_sock));
				socket_write(AI_sock,"WHITE");
				socket_write(sock,"WHITE\n");
				socket_write(sock,socket_read(AI_sock));
				game.set_current_player('w');
				if(difficulty2=="EASY"){
					socket_write(AI_sock,"EASY");
					socket_write(sock,"EASY\n");
				}
				else if(difficulty2 == "MEDIUM"){
					socket_write(AI_sock,"MEDIUM");
					socket_write(sock,"MEDIUM\n");
				}
				else{
					socket_write(AI_sock,"HARD");
					socket_write(sock,"HARD\n");
				}
				socket_write(sock,socket_read(AI_sock));
				while(!game.is_game_over()){
					if(difficulty1=="EASY"){
						move=ai.get_move(game,AI::EASY);
					}
					else if(difficulty1=="MEDIUM"){
						move=ai.get_move(game,AI::MEDIUM);
					}
					else{
						move=ai.get_move(game,AI::HARD);
					}
					game.make_move(move);
					socket_write(AI_sock,move);
					socket_write(sock,move + "\n");
					opponent_move=socket_read(AI_sock);    //Note string parsing will have to be done here.
					found_index = opponent_move.find_first_of("abcdefghABCDEFGH"); //Regex not implemented in gcc4.7 so find move letter
					while (found_index != string::npos){ //Check if following or previous char is move integer
						if(opponent_move[found_index+1]=='1' || opponent_move[found_index+1]=='2' || opponent_move[found_index+1]=='3' || opponent_move[found_index+1]=='4' || opponent_move[found_index+1]=='5' || opponent_move[found_index+1]=='6' || opponent_move[found_index+1]=='7' || opponent_move[found_index+1]=='8'){
							opponent_move_partial=opponent_move[found_index];
							opponent_move_partial+=opponent_move[found_index+1];
						}
						else if(opponent_move[found_index-1]=='1' || opponent_move[found_index-1]=='2' || opponent_move[found_index-1]=='3' || opponent_move[found_index-1]=='4' || opponent_move[found_index-1]=='5' || opponent_move[found_index-1]=='6' || opponent_move[found_index-1]=='7' || opponent_move[found_index-1]=='8'){
							opponent_move_partial=opponent_move[found_index-1];
							opponent_move_partial+=opponent_move[found_index];
						}
						game.make_move(opponent_move_partial);	//make move
						found_index = opponent_move.find_first_of("abcdefghABCDEFGH",found_index+1);
					}
					socket_write(sock,opponent_move + "\n");
				}
				socket_write(sock,"\n");	
			}
		}
		else if(s[0]==';')
			;// do nothing?
		else if(game.make_move(s)) {
开发者ID:igrande0,项目名称:CSCE-315-Project-2,代码行数:67,代码来源:Server.cpp


注:本文中的AI::get_move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。