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


C++ WorldState::getTruthValue方法代码示例

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


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

示例1: asString

std::string RackoWorldStateFormatter::asString(const VecInt & gameHistory, WorldState & ws, const VecVecVecKey & kb) {
	ostringstream os;
	// Number of slot objects is (# slots per player)*2 + 1.  (Extra 1 is "dealer").
	// Integer division by two gives # slots per player.
	//	unsigned slotCount = (unsigned) (proc->typeCardinalities[proc->typeNameIds["slot"]] / 2);
	unsigned slotCount = proc->itemCount("slot");
	unsigned slotsPerPlayer = (slotCount - 1) / 2; // Subtract 1 for dealer; half of remaining are opponent's slots
	unsigned dealerSlotId = slotsPerPlayer; // Because slots are named d1 ... dn, dealer, u1, ... un; so dealer is in middle
	unsigned cardCount = proc->itemCount("card");
	//	os << "Racko World with " << slotCount << " slots and " << cardCount << " cards";
	//	os << " head id for 'at': " << proc->predicateId("at");
	int atIndex = proc->predicateId("at");
	int topIndex = proc->predicateId("top");
	VecInt args(2, 0);
	int whoseTurn = ws.getWhoseTurn();
	int minSlot = (whoseTurn == 2) ? 0 : dealerSlotId + 1;
	int oppMinSlot = (whoseTurn == 1) ? 0 : dealerSlotId + 1;
	os << "History\n";
	for (unsigned m = slotCount + 1; m < gameHistory.size(); m++) {
		string oName;
		VecInt oArgs;
		proc->decodeOperator(gameHistory[m], oName, oArgs);
		if (oName == "swap-top") {
			if (oArgs[0] != whoseTurn) {
				os << "(Opponent) ";
			}
			int slotArg = getSlotArg(oArgs[3], slotsPerPlayer);
			os << "Swapped " << (oArgs[2] + 1) << " for " << (oArgs[4] + 1) << " into " << (char) (('A' + (slotArg)))
					<< "\n";
		} else if (oName == "swap-drawn") {
			if (oArgs[0] != whoseTurn) {
				os << "(Opponent) ";
			}
			int slotArg = getSlotArg(oArgs[2], slotsPerPlayer);
			os << "Swapped " << (oArgs[3] + 1) << " out of " << (char) (('A' + (slotArg))) << " for drawn ";
			if (oArgs[0] == whoseTurn) {
				os << (oArgs[4] + 1) << "\n";
			} else {
				os << "card\n";
			}
		} else if (oName == "pass") {
			if (oArgs[0] != whoseTurn) {
				os << "(Opponent) ";
			}
			os << "Discarded " << (oArgs[2] + 1) << "\n";
		} else {
			//			os << setw(3) << m << " " << oName << "\n";
		}

	}

	os << "\n\n";
	switch (whoseTurn) {
	case 0: // chance
		os << "Chance: ";
		args[1] = slotCount; // This will be the slot 'dealer'
		for (int c = 0; c < (int) (((((cardCount))))); c++) {
			args[0] = c;
			int index = ws.getIndex(args, atIndex);
			if (ws.getTruthValue(index) == KNOWN_TRUE) {
				os << " " << std::setw(3) << (c + 1); //" fact: "  << proc->getFact(index);
			}
		}

		os << "\n";
		break;
	case 1:
	case 2:
		os << "Current Player " << whoseTurn << "\n";
		for (int s = minSlot; s < (int) ((((((minSlot + slotsPerPlayer)))))); s++) {
			os << "   " << (char) (((((('A' + s - minSlot)))))) << ": "; //" fact: "  << proc->getFact(index);
			args[1] = s;
			for (int c = 0; c < (int) (((((cardCount))))); c++) {
				args[0] = c;
				int index = ws.getIndex(args, atIndex);
				if (ws.getTruthValue(index) == KNOWN_TRUE) {
					os << std::setw(3) << (c + 1); //" fact: "  << proc->getFact(index);
				}
			}

			os << "\n";
		}

		if (false)
			for (int s = oppMinSlot; s < (int) ((((((oppMinSlot + slotCount)))))); s++) {
				os << "   " << (char) (((((('A' + s - oppMinSlot)))))) << ": "; //" fact: "  << proc->getFact(index);
				args[1] = s;
				for (int c = 0; c < (int) (((((cardCount))))); c++) {
					args[0] = c;
					int index = ws.getIndex(args, atIndex);
					if (ws.getTruthValue(index) == KNOWN_TRUE) {
						os << std::setw(3) << (c + 1); //" fact: "  << proc->getFact(index);
					}
				}

				os << "\n";
			}

		os << "\n";
		break;
//.........这里部分代码省略.........
开发者ID:mdrichar,项目名称:POGDDL,代码行数:101,代码来源:WorldStateFormatter.cpp


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