示例#1
0
    def talk(self):
        # printする場合は、print_onをTrueに変更
        print_on = False

        # talk_turnの更新
        self.talk_turn += 1

        # 1日目2ターン目に霊媒CO
        if self.base_info["day"] == 1 and self.talk_turn == 2:
            if print_on: print("SEER:COmedium")
            return cb.comingout(self.base_info['agentIdx'], "MEDIUM")

        # 最新霊媒結果があれば、発表
        elif self.result_medium_new:
            who, result = self.result_medium_new.pop(0)
            result = "WEREWOLF" if result else "HUMAN"
            if print_on:
                print("who:Agent" + str(who) + ", result:" + result)
                print("result_medium_new:", self.result_medium_new, "<-中身が空であればOK")
            return cb.identified(who, result)

        # 霊媒結果がなければ村人と同じ
        return super().talk()
示例#2
0
 def talk(self):
     self.talk_turn += 1
     
     # 1.CO
     if(self.base_info['myRole'] == 'MEDIUM' and self.comingout == '' \
         and ( self.seer_co_num >= 2 or self.comingoutday <= self.base_info['day'])):
         self.comingout = 'MEDIUM'
         return cb.comingout(self.base_info['agentIdx'], self.comingout)
     elif(self.base_info['myRole'] == 'SEER' and self.comingout == ''):
         self.comingout = 'SEER'
         return cb.comingout(self.base_info['agentIdx'], self.comingout)
     elif(self.base_info['myRole'] == 'POSSESS' and self.comingout == '' \
          and (self.possess_justco == 1 or self.seer_co_num >= 1)):
         self.comingout = 'SEER'
         return cb.comingout(self.base_info['agentIdx'], self.comingout)
     
     # 2. 結果報告
     if(self.not_reported):
         if(self.base_info['myRole'] == 'MEDIUM' and self.result_roll != []):
             ident = self.result_roll.pop()
             return cb.identified(ident[0], ident[1])
         elif(self.base_info['myRole'] == 'SEER' and self.result_roll != []):
             divination = self.result_roll.pop()
             return cb.divination(divination[0], divination[1])
     if(self.base_info['myRole'] == 'POSSESS' and self.comingout != ''):
         # self.possess_justcoこれ使ってるけどco関係なくてただの欄数が欲しいだけ
         # idx = chainer_predict.estimate_wolf(self.info, self.base_info)
         idx = random.shuffle(range(len(self.base_info['agentIdx']))+1)
         if(self.possess_justco == 1 and idx != -1):
             possess_div = []
             for i in range(1,len(self.base_info['statusMap'])+1):
                 if((i not in idx) and (i not in self.voted_list)):
                     possess_div.append(i)
             div = random.choice(possess_div)
             self.voted_list.append(div)
             species = random.choice(['HUMAN','WEREWOLF'])
             if(species == 'WEREWOLF'):
                 self.possess_wolf.append(div)
             return cb.divination(div, species)
         else:
             not_vote_list = []
             for i in idx:
                 if(i not in self.voted_list):
                     not_vote_list.append(i)
             voted = random.choice(not_vote_list)
             self.voted_list.append(voted)
             return cb.divination(voted, 'HUMAN')
             
     
     # 3.vote宣言
     # 狂人は黒判定した奴に投票
     if(self.base_info['myRole'] == 'POSSESS' and self.possess_wolf != []):
         return cb.vote(random.choice(self.possess_wolf))
     elif(self.vote_declare != self.vote()):
         self.vote_declare = self.vote()
         print(self.vote_declare)
         return cb.vote(self.vote_declare)
     
     # 4.発言回数残ってたらskip
     if self.talk_turn <= 10:
         return cb.skip()
     
     return cb.over()
示例#3
0
    def talk(self):
        self.talk_turn += 1
        self.attack_judge = 0
        # 占い師talk
        if self.role_decision == 0:
            # 初日
            #     1ターン目 占いCO
            #     2ターン目 全体から占いと霊能と人狼を引いた集合からランダムに黒出し
            #     3ターン目以降 その人に投票宣言(voteもこの黒出しに合わせる)
            # 1 ターン目に "MEDIUM" を宣言する
            if self.base_info["day"] == 1:
                if self.stealth == 0:
                    if self.talk_turn == 1:
                        CO_SEER = cb.comingout(self.base_info['agentIdx'],
                                               "SEER")
                        return CO_SEER
                    elif self.talk_turn == 2:
                        if self.COs - {int(self.base_info["agentIdx"])}:
                            self.shonichi_target = random.choice(
                                list(self.COs -
                                     {int(self.base_info["agentIdx"])}))
                            self.kurodashi.add(self.shonichi_target)
                            return cb.divined(self.shonichi_target, "WEREWOLF")
                        else:
                            self.shonichi_target = random.choice(
                                list(self.alive - self.COs - set(self.COm) -
                                     self.divineders))
                            self.kurodashi.add(self.shonichi_target)
                            return cb.divined(self.shonichi_target, "WEREWOLF")
                    elif self.talk_turn >= 3:
                        return cb.vote(self.shonichi_target)
                else:
                    return super().talk()

            # 二日目以降
            #     1ターン目 aliveから占いと霊能と人狼を引いた集合-占い済からrandomに白だし
            #     2ターン目以降現状の投票候補から白だしを引いてvoteに渡し、それを発言
            #     1~2回だけ 1ターン目 alive人狼の集合からrandomに白だし これは二日目以降30%程度の確率でやりたい
            #   7人以下になった時の特殊戦略
            #       狂人COの投票先が人狼以外ならそれに乗っかる
            #       人狼以外の最多得票者に投票
            else:
                if self.stealth == 0:
                    judger = random.random()
                    if judger <= 0.7 and self.SPcounter <= 2:
                        if self.talk_turn == 1:
                            if self.alive - self.COs - set(
                                    self.COm
                            ) - self.divineders - self.kurodashi - self.shirodashi:
                                target = random.choice(
                                    list(self.alive - self.COs -
                                         set(self.COm) - self.divineders -
                                         self.kurodashi - self.shirodashi))
                                self.shirodashi.add(target)
                                return cb.divined(target, "HUMAN")
                            elif self.alive - self.kurodashi - self.shirodashi:
                                target = random.choice(
                                    list(self.alive - self.kurodashi -
                                         self.shirodashi))
                                self.shirodashi.add(target)
                                return cb.divined(target, "HUMAN")
                            elif self.alive & self.shirodashi:
                                target = random.choice(
                                    list(self.alive & self.shirodashi))
                                self.shirodashi.add(target)
                                return cb.divined(target, "HUMAN")
                            else:
                                target = random.choice(
                                    list(self.alive & self.kurodashi))
                                self.kurodashi.add(target)
                                return cb.divined(target, "WEREWOLF")
                        else:
                            target = self.vote()
                            return cb.vote(target)
                    else:
                        self.SPcounter += 1
                        if self.talk_turn == 1:
                            if self.alive & self.wolfs - {
                                    int(self.base_info["agentIdx"])
                            }:
                                target = random.choice(
                                    list(self.alive & self.wolfs -
                                         {int(self.base_info["agentIdx"])}))
                                self.shirodashi.add(target)
                                return cb.divined(target, "HUMAN")
                            else:
                                target = self.vote()
                                self.shirodashi.add(target)
                                return cb.divined(target, "HUMAN")
                        else:
                            target = self.vote()
                            return cb.vote(target)
                else:
                    return super().talk()
            return super().talk()

        # stealth talk
        if self.role_decision == 1:
            return super().talk()

        # 霊媒師 talk
        if self.role_decision == 2:
            # 1 ターン目に "MEDIUM" を宣言する
            if self.base_info["day"] == 1:
                if self.talk_turn == 1:
                    if self.stealth == 0:
                        CO_MEDIUM = cb.comingout(self.base_info['agentIdx'],
                                                 "MEDIUM")
                        return CO_MEDIUM
                    else:
                        # CO_VILLAGER = cb.comingout(self.base_info['agentIdx'], "VILLAGER")
                        # return CO_VILLAGER
                        return super().talk()

                # 他は村人と同じ会話をする
                else:
                    return super().talk()

            # 二日目以降の人狼の挙動
            else:
                # 偽霊能者の動き方をする時
                if self.stealth == 0:
                    if self.talk_turn == 1:
                        # 処刑された人物が COm の中にいた場合
                        # (ここに入るということは自分以外の人狼が COm はありえないということ)
                        if self.exed_players[-1] in set(self.COm):
                            # COm の 1 人目の占いをする場合
                            if self.first_identify == 0:
                                # 自分以外の COm がいた場合の話
                                if len(self.COm) >= 2:
                                    # 1人目のみ自分以外の霊能CO者が釣られたらそいつのことを黒という
                                    IDENTIFIED_BLACK = cb.identified(
                                        self.exed_players[-1], "WEREWOLF")
                                    self.first_identify = 1
                                    return IDENTIFIED_BLACK
                                # 他は村人と同じ会話をする
                                else:
                                    return super().talk()

                            # COm の 2 人目以降の占いをする場合,以降の Medium 宣言者は全て白を出す
                            if self.first_identify == 1:
                                if len(self.COm) >= 2:
                                    # そいつが先に釣られた場合はそいつを黒と言う
                                    IDENTIFIED_WHITE = cb.identified(
                                        self.exed_players[-1], "HUMAN")
                                    self.first_identify = 1
                                    return IDENTIFIED_WHITE
                                # 他は村人と同じ会話をする
                                else:
                                    return super().talk()

                        # 処刑された人物が COm の中にいない場合,正直に identify する.ただし例外あり.
                        else:
                            # これが例外.偽の黒出しをされた人が処刑された場合.
                            black_cand = set()
                            for i in self.divineders:
                                black_cand |= self.result_all_divineders[i][
                                    'black']
                            black_cand -= self.wolfs
                            if self.exed_players[-1] in black_cand:
                                IDENTIFIED_BLACK = cb.identified(
                                    self.exed_players[-1], "WEREWOLF")
                                return IDENTIFIED_BLACK
                            else:
                                # 死んだ人が人狼であった場合,正直に黒出しをする
                                if self.exed_players[-1] in set(self.wolfs):
                                    IDENTIFIED_BLACK = cb.identified(
                                        self.exed_players[-1], "WEREWOLF")
                                    return IDENTIFIED_BLACK
                                else:
                                    IDENTIFIED_WHITE = cb.identified(
                                        self.exed_players[-1], "HUMAN")
                                    return IDENTIFIED_WHITE
                    if self.talk_turn >= 2:
                        return super().talk()
                # 偽村人の動き方をする時
                else:
                    return super().talk()