本文整理汇总了C++中WorldState::getFluentValue方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldState::getFluentValue方法的具体用法?C++ WorldState::getFluentValue怎么用?C++ WorldState::getFluentValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldState
的用法示例。
在下文中一共展示了WorldState::getFluentValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cardRow
std::string VAL::EndGameWorldStateFormatter::asString(const VecInt& gameHistory, WorldState & ws,
const VecVecVecKey& kb) {
ostringstream os;
int scoreIndex = proc->getFunctionId("score");
int cardCount = proc->typeCardinalities[proc->typeNameIds["card"]];
// int slotCount = proc->typeCardinalities[proc->typeNameIds["slot"]];
VecInt cardRow(cardCount, -1);
NumScalar p1Score = ws.getFluentValue(scoreIndex, 1);
NumScalar p2Score = ws.getFluentValue(scoreIndex, 2);
os << "Score 1: " << p1Score << " Score 2: " << p2Score << "\n";
//assert((unsigned)cardCount <= gameHistory.size());
if ((unsigned) cardCount < gameHistory.size()) {
for (unsigned i = 1; i <= (int) cardRow.size(); i++) {
int index = gameHistory[i];
VecInt args = proc->operatorIndexToVector(index);
// os << proc->getOperatorName(args[0]) << " " << proc->asString(args) << "\n";
cardRow[i - 1] = args[3] + 1; // c0=1 c1=2, etc.
}
}
os << proc->asString(cardRow, LIST) << "\n";
return os.str();
}
示例2: startingHands
std::string VAL::GopsWorldStateFormatter::asString(const VecInt & gameHistory, WorldState & ws,
const VecVecVecKey & kb) {
ostringstream os;
int scoreIndex = proc->getFunctionId("score");
string oName;
VecInt oArgs;
int slotCount = proc->typeCardinalities[proc->typeNameIds["slot"]];
unsigned biddingRoundCount = (slotCount - 1) / 3; // Subtract 1 for dealer, divide by 3 because for every bidding round, there
// is the card to bid on plus one card per player to bid with
VecVecInt startingHands(3);
VecVecInt results(3);
for (unsigned i = 0; i < 3; i++) {
startingHands[i] = VecInt(biddingRoundCount, 0);
results[i] = VecInt(biddingRoundCount, 0);
}
int biddingRoundId = 0;
int currentBiddable = -1;
for (unsigned i = 1; i < gameHistory.size(); i++) {
proc->decodeOperator(gameHistory[i], oName, oArgs, true);
int cardId = oArgs[0] + 1;
if (oName == "deal") {
//os << i << " Deal " << (oArgs[0] + 1) << "\n";
if (i <= biddingRoundCount) {
startingHands[0][i - 1] = cardId;
} else {
int pid = 2 - ((i - biddingRoundCount - 1) % 2);
startingHands[pid][(i - biddingRoundCount - 1) / 2] = cardId;
}
} else if (oName == "announce") {
currentBiddable = cardId;
} else if (oName == "bid1") {
results[1][biddingRoundId] = cardId;
} else if (oName == "bid2") {
results[2][biddingRoundId] = cardId;
} else if (oName == "determine") {
int p1Bid = oArgs[0] + 1;
int p2Bid = oArgs[1] + 1;
results[0][biddingRoundId] = (p2Bid > p1Bid) + 1; // 1 if p1 won it; 2 if p2 won it
biddingRoundId++;
}
}
std::string labels[] = { "won by", "p1 bid", "p2 bid" };
// for (unsigned i = 0; i < 3; i++) {
// if (i > 0 && i != ws.getWhoseTurn()) continue; // Don't print the other guys cards
// os << labels[i] << " ";
// for (int j = 0; j < biddingRoundCount; j++) {
// os << startingHands[i][j] << " ";
// }
// os << "\n";
// }
os << "\n";
os << "card: ";
for (int i = 0; i < biddingRoundId; i++) {
os << setw(2) << startingHands[0][i] << " ";
}
os << "\n";
//labels[0] = "W ";
for (unsigned i = 0; i < 3; i++) {
os << labels[i] << ": ";
for (int j = 0; j < biddingRoundId; j++) {
os << setw(2) << results[i][j] << " ";
}
os << "\n";
}
os << "Currently bidding on: " << currentBiddable << "\n";
NumScalar p1Score = ws.getFluentValue(scoreIndex, 1);
NumScalar p2Score = ws.getFluentValue(scoreIndex, 2);
switch (ws.getWhoseTurn()) {
case 0:
os << "Player 1 score: " << setw(2) << p1Score << "\nPlayer 2 score: " << setw(2) << p2Score << "\n";
break;
case 1:
os << "My score: " << setw(2) << p1Score << "\nOpponent score: " << setw(2) << p2Score << "\n";
break;
case 2:
os << "Opponent Score: " << setw(2) << p1Score << "\nMy score: " << setw(2) << p2Score << "\n";
break;
}
return os.str();
}