本文整理汇总了C++中AI::getWinValue方法的典型用法代码示例。如果您正苦于以下问题:C++ AI::getWinValue方法的具体用法?C++ AI::getWinValue怎么用?C++ AI::getWinValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AI
的用法示例。
在下文中一共展示了AI::getWinValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playGame
bool playGame(AI& fp,AI& sp,char* host,int&results)
{
//cout<<"PlayGame Function Called"<<endl;
int socket = open_server_connection(host, "19000");
if(socket == -1)
{
cerr << "Unable to connect to server" << endl;
return false;
}
if(!serverLogin(socket, fp.username(), fp.password()))
{
cerr << "Login Failed" << endl;
return false;
}
socket = createGame();
int game = getGameNumber();
cout<<"TOP Game: "<<game<<endl;
//cout<<"Above Fork"<<endl;
pid_t pID = fork();
if(pID ==0)//PLAYER 2
{
//cout<<"Fork Happened for Player 2"<<endl;
socket = open_server_connection(host, "19000");
if(socket == -1)
{
cerr << "Unable to connect to server" << endl;
return false;
}
//cout<<"Attempting to log in"<<endl;
if(!serverLogin(socket, sp.username(), sp.password()))
{
return false;
}
//cout<<"Joining Game"<<endl;
socket = joinGame(game);
//cout<<"Above while loop"<<endl;
while(networkLoop(socket))
{
if(sp.startTurn())
{
endTurn();
}
else
{
getStatus();
}
}
}
else
{
//cout<<"P1 above while"<<endl;
while(networkLoop(socket))
{
if(fp.startTurn())
{
endTurn();
}
else
{
getStatus();
}
}
}
//Wait for log
while (networkLoop(socket)){}
//Get the scores
results=(fp.getWinValue());
if(pID == 0)
{
close(socket);
exit(0);
//TODO Hack to kill the spawned copy
}
close(socket);
cout<<"Game["<<game<<"] "<<fp.aiNum<<" VS "<<sp.aiNum<<" final score = "<<results<<endl;
return true;
}