コード例 #1
0
ファイル: player.py プロジェクト: mh-northlander/procon
 def simLastV(self, fight_history: List[Fight]) -> Card:
     # simulate view past logic
     n = len(fight_history) + 1 - 1
     ret = fight_history[-1].fighter
     if n % 3 != 1:
         ret = next(fight_history[-2].player)
     return self.draw_card_from_deck(ret)
コード例 #2
0
    def next(self, fight_history: List[Fight]) -> Card:
        f = FizzBuzzLogic()
        s = SerialLogic()
        v = ViewPastLogic()

        rateF = clcRate(f, fight_history, len(fight_history) - self.n)
        rateS = clcRate(s, fight_history, len(fight_history) - self.n)
        rateV = clcRate(v, fight_history, len(fight_history) - self.n)

        m = max(rateF, rateS, rateV)
        if m == rateF:
            return next(f.next(fight_history))
        elif m == rateS:
            return next(s.next(fight_history))
        else:
            return next(v.next(fight_history))
コード例 #3
0
    def next(self, fight_history: List[Fight]):
        n = len(fight_history) + 1
        if n % 3 == 1:
            return card.random()

        last = fight_history[-1]
        return card.next(last.player)
コード例 #4
0
ファイル: player.py プロジェクト: mh-northlander/procon
    def next(self, fight_history: List[Fight]) -> Card:
        n = len(fight_history) + 1
        itv = n % 100
        if itv == 1 or itv == 34 or itv == 67:
            self.n = n
            self.sState = Card.Choki
            self.simF = []
            self.simS = []
            self.simV = []
        else:
            self.simF.append(self.simLastF(fight_history))
            self.simS.append(self.simLastS(fight_history))
            self.simV.append(self.simLastV(fight_history))

        rateF = clcRate(self.simF, fight_history[self.n - 1:])
        rateS = clcRate(self.simS, fight_history[self.n - 1:])
        rateV = clcRate(self.simV, fight_history[self.n - 1:])

        m = max(rateF, rateS, rateV)
        if m == rateV:
            if n % 3 != 1:
                exp = next(fight_history[-1].player)
            else:
                exp = self.random_from_deck()
        elif m == rateS:
            if n % 3 != 1:
                exp = next(self.sState)
            else:
                exp = self.random_from_deck()
        else:
            if n % 3 == 0 and n % 5 == 0:
                exp = Card.Choki
            elif n % 3 == 0:
                exp = Card.Gu
            elif n % 5 == 0:
                exp = Card.Pa
            else:
                exp = self.random_from_deck()

        # update
        if (n % 3 != 1):
            self.sState = next(self.sState)
        if (n > 1):
            self.deck[fight_history[-1].fighter] -= 1

        return next(self.draw_card_from_deck(exp))
コード例 #5
0
def clcRate(logic: Logic, fight_history, n):
    if n == 0:
        return .0

    expect = [logic.next(fight_history[:-(n - i)]) for i in range(n)]
    counter = [next(v) for v in expect]
    actual = [v.fighter for v in fight_history[-n:]]
    battle = [judge(z[0], z[1]) for z in zip(counter, actual)]
    return sum([(v == Code.WIN if 1 else 0) for v in battle]) / n
コード例 #6
0
    def next(self, fight_history: List[Fight]):
        n = len(fight_history) + 1
        if n % 3 == 1:
            return card.random()

        if self.prev_card is None:
            self.prev_card = Card.Gu
            return Card.Gu

        self.prev_card = card.next(self.prev_card)
        return self.prev_card
コード例 #7
0
ファイル: player.py プロジェクト: mh-northlander/procon
 def _find_next_card(self, c: Card) -> Card:
     if self.deck[c] > 0:
         return c
     return self._find_next_card(next(c))
コード例 #8
0
 def _find_next_card(self, c: Card, deck: Dict[Card, int])->Card:
     if deck[c] > 0:
         deck[c] -= 1
         return c
     return self._find_next_card(card.next(c), deck)