Exemplo n.º 1
0
static FeaturesSet CalcPlayFeatures(const GameState& playerView, Card move, uint32_t ourHero) {
	static PlayFeaturesRegistry reg;

	FeaturesSet result = reg.CreateEmptySet();
	CardsSet knownCards = playerView.GetKnownCards();
	auto setCardF = [&](FeaturesRange& fr, Card c, float value) {
		result.Set(fr, GetCardBit(c), value);
	};

	for (Suit s = Spades; s != NoSuit; s = (Suit)(uint32_t(s) + 1)) {
		uint32_t realRank = 0;
		for (Rank r = 0; r < 8; ++r) {
			auto card = MakeCard(s, r);
			auto cardForFeature = card; //MakeCard(s, realRank);
			if (IsCardCovers(card, playerView.OnDesk(playerView.PlayerWithGreaterCard()), playerView.GetTrump())) {
				setCardF(reg.IsGreaterCard, cardForFeature, 1.0f);
			}
			setCardF(reg.IsValidMove, cardForFeature, playerView.IsValidMove(card) ? 1.0f : 0.0f);
			for (uint32_t i = 0, player = playerView.GetFirstPlayer(); i < 2; player = (player + 1) % 3, i++) {
				if (playerView.OnDesk(player) == card) {
					setCardF(reg.CardsOnDesk[i], cardForFeature, 1.0f);
				}
			}
			if (playerView.Hand(ourHero).IsInSet(card)) {
				setCardF(reg.PlayerCards[0], cardForFeature, 1.0f);
			}
			if (playerView.Out().IsInSet(card)) {
				setCardF(reg.NotInGameCards, cardForFeature, 1.0f);
			}
			realRank++;
		}
	}

	return result;
}
Exemplo n.º 2
0
uint32_t EncodeMoveIndex(const GameState& playerView, Card c) {
	auto suit = GetSuit(c);
	uint32_t realRank = 0;
	for (uint32_t rank = 0; rank < GetRank(c); rank++) {
		bool onDesk = false;
		for (uint32_t player = 0; player < 3; player++) {
			onDesk = onDesk || playerView.OnDesk(player) == c;
		}
		if (!playerView.Out().IsInSet(c) || onDesk) {
			realRank++;
		}
	}
	return GetCardBit(MakeCard(suit, realRank));
}