本文整理汇总了C++中Bot::goals方法的典型用法代码示例。如果您正苦于以下问题:C++ Bot::goals方法的具体用法?C++ Bot::goals怎么用?C++ Bot::goals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bot
的用法示例。
在下文中一共展示了Bot::goals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeTeamData
//write team data to file
bool TeamData::writeTeamData(QString filename, Team* team){
// check if team success
if (!team){
return false;
}
//open the text file, if already exists overwrite
QFile xmlFile(filename);
if (xmlFile.open(IO_WriteOnly)){ //file opened as overwrite
QTextStream ts(&xmlFile);
QString str;
//write team tag
ts << "<team ";
ts << "name=\"" << team->name() << "\" ";
ts << "wins=\"" << QString::number(team->wins()) << "\" ";
ts << "losses=\"" << QString::number(team->losses()) << "\" ";
ts << "generations=\"" << QString::number(team->generations()) << "\" ";
ts << "ties=\"" << QString::number(team->ties()) << "\">\n";
//write bot tag
Bot *b;
for (unsigned int i = 0; i < team->size(); i++){
b = team->bot(i); //get bot in sequence
ts << "<bot ";
ts << "mass=\"" << QString::number(b->mass()) << "\" ";
ts << "goals=\"" << QString::number(b->goals()) << "\" ";
ts << "interceptions=\"" << QString::number(b->interceptions()) << "\">\n";
ts << "<gaRule>\n";
//write rule tag
GARule *r;
for (unsigned int j = 0; j < b->ruleSetSize(); j++){
r = b->rule(j);
ts << "<rule ";
ts << "teamBall=\"" << QString::number(r->teamBall()) << "\" ";
ts << "myBall=\""; (r->myBall()) ? ts << "T" : ts << "F"; ts << "\" ";
ts << "fire=\""; (r->fire()) ? ts << "T" : ts << "F";
ts << "\" ";
ts << "move=\""; (r->move()) ? ts << "T" : ts << "F";
ts << "\" ";
ts << "turn=\""; (r->turn() == Left) ? ts << "left" :
(r->turn() == Right) ? ts << "right" : ts << "none";
ts << "\">\n";
//write sensors tag
Thing* sen = r->sensors();
ts << "<sensors ";
for (unsigned int k = 0; k < 8; k++){
QString t;
switch(sen[k]) {
case Nothing: t = "nothing"; break;
case MyBot: t = "mybot"; break;
case OtherBot: t = "otherbot"; break;
case TheBall: t = "ball"; break;
case Wall: t = "wall"; break;
case Net: t = "net"; break;
}//end switch
//put the appropriate end tag
ts << "s" << QString::number(k) << "=\"" << t;
if (k < 7){
ts << "\" ";
}else{
ts << "\"/>\n";
}//end if
}//end putting sensor tag
ts << "</rule>\n";
}//end for
ts << "</gaRule>\n";
ts << "</bot>\n";
}//end for
ts << "</team>\n";
xmlFile.close(); //close file
}//end if
return(true);
}//end writeTeamData