コード例 #1
0
ファイル: Villager.py プロジェクト: yoshinobc/wolf-strategy
    def talk(self):
        self.talk_turn += 1
        if self.isCo:
            self.isCo = True
            return cb.AND(cb.AGREE(self.agree_co[0], self.agree_co[1], self.agree_co[2]), cb.COMINGOUT(self.agentIdx, self.myrole))
        elif not self.isVote and self.voteop != None:
            self.isVote = True
            return cb.AND(cb.AGREE(self.request_vote_agree[0], self.request_vote_agree[1], self.request_vote_agree[2]), cb.VOTE(self.voteop))
        elif len(self.Agreeque) >= 1:
            AGREEText = self.Agreeque.pop()
            return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2])

        elif not self.request_vote and self.talk_turn >= 3:
            for d in self.base_info["statusMap"].items():
                if d[1] == "ALIVE" and d[0] != str(self.agentIdx + 1):
                    return cb.REQUEST(int(d[0]) - 1, cb.REQUEST(self.agentIdx, cb.VOTE("ANY")))
        index = 0
        while True:
            if self.talk_turn <= 3:
                return cb.skip()
            if index == self.playerNum:
                return cb.skip()
            if not self.istalk_vote[index] and self.base_info["statusMap"][str(index + 1)] == "ALIVE":
                self.istalk_vote[index] = True
                return cb.INQUIRE(index, cb.VOTE("ANY"))
            else:
                index += 1
        else:
            return cb.skip()
コード例 #2
0
    def talk(self):
        self.talk_step += 1
        if self.co_rate != 2:
            self.co_rate = random.uniform(0, 1)
        if not self.isCo and self.day == 1 and self.co_rate >= 0.3:
            self.isCo = True
            if self.co_rate == 2:
                return cb.AND(
                    cb.AGREE(self.agree_co[0], self.agree_co[1],
                             self.agree_co[2]),
                    cb.COMINGOUT(self.agentIdx, "VILLAGER"))
            else:
                return cb.COMINGOUT(self.agentIdx, "VILLAGER")

        elif not self.isVote and self.talk_step >= 5:
            lists = []
            for i in range(len(self.vote_list)):
                if self.vote_list[i] != -1:
                    lists.append(self.vote_list[i])
            self.isVote = True
            try:
                self.talk_voteop = mode(lists)
            except:
                for d in self.base_info["statusMap"].items():
                    if d[1] == "ALIVE":
                        self.talk_voteop = int(d[0]) - 1
                        break
            for i in range(len(self.vote_list)):
                if self.vote_list[i] == self.talk_voteop:
                    self.because_list.append(i)
            return cb.VOTE(self.talk_voteop)
        elif len(self.because_list) > 0 and self.isVote:
            agent = self.because_list[0]
            del self.because_list[0]
            return cb.BECAUSE(cb.VOTE2(agent, self.talk_voteop),
                              cb.VOTE(self.talk_voteop))
        elif len(self.AGREESentenceQue) >= 1:
            AGREEText = self.AGREESentenceQue.pop()
            return cb.AGREE(AGREEText[0], AGREEText[1], AGREEText[2])
        elif len(self.DISAGREESentenceQue) >= 1:
            DISAGREEText = self.DISAGREESentenceQue.pop()
            return cb.DISAGREE(DISAGREEText[0], DISAGREEText[1],
                               DISAGREEText[2])
        index = 0
        if self.talk_step >= 5:
            while True:
                if index == self.playerNum:
                    return cb.skip()
                if not self.istalk_vote[
                        index] and index != self.agentIdx and self.base_info[
                            "statusMap"][str(index + 1)] == "ALIVE":
                    self.istalk_vote[index] = True
                    return cb.INQUIRE(index, cb.VOTE("ANY"))
                else:
                    index += 1
        return cb.skip()