bot.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Hanabi-AI 作者: MeGotsThis 项目源码 文件源码
def doesCardMatchHand(self, deckIdx: int) -> bool:
        deckCard: CardKnowledge
        deckCard = cast(CardKnowledge, self.game.deck[deckIdx])
        assert deckCard.suit is not None
        assert deckCard.rank is not None
        if self.colorComplete[deckCard.suit]:
            return False
        if deckCard.rank == Value.V5:
            return False
        h: int
        for h in self.hand:
            card: CardKnowledge
            card = cast(CardKnowledge, self.game.deck[h])
            if not card.clued:
                continue
            if card.worthless or card.playWorthless:
                continue
            if card.cantBe[deckCard.suit][deckCard.rank]:
                continue
            if card.color is not None and card.value is not None:
                continue
            if card.color == deckCard.suit:
                maybeValue: Optional[Value] = card.maybeValue
                if maybeValue is not None:
                    if maybeValue == deckCard.rank:
                        return True
                    continue
                if deckCard.rank in card.possibleValues:
                    return True
            if card.value == deckCard.rank:
                maybeColor: Optional[Color] = card.maybeColor
                if maybeColor is not None:
                    if maybeColor == deckCard.suit:
                        return True
                    continue
                if deckCard.suit in card.possibleColors:
                    return True
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号