Ejemplo n.º 1
0
        public void AllSpoiled_Test()
        {
            var dupPersonGuid = Guid.NewGuid();

            var votes = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonIneligibleReasonGuid = Guid.NewGuid(), VoteId = 1
                },
                new VoteInfo {
                    VoteIneligibleReasonGuid = Guid.NewGuid(), VoteId = 2
                },
                new VoteInfo {
                    PersonIneligibleReasonGuid = Guid.NewGuid(), VoteId = 3
                },
            };

            VoteAnalyzer.UpdateAllStatuses(votes,
                                           votes.Select(v => new Vote {
                C_RowId = v.VoteId
            }).ToList(),
                                           new Savers(new TestDbContext()).VoteSaver);

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(BallotStatusEnum.Ok, votes, out newStatus, out spoiledCount)
            .ShouldEqual(false);

            newStatus.ShouldEqual(BallotStatusEnum.Ok);
            spoiledCount.ShouldEqual(3);
        }
Ejemplo n.º 2
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            guessList.Clear();

            foreach (DayInfo dayInfo in args.Agi.DayInfo.Values)
            {
                // その日の投票の取得
                VoteAnalyzer voteAnalyzer = null;
                if (dayInfo.VoteList.Count > 0)
                {
                    // 実際の投票(1回目の投票のみ)
                    voteAnalyzer = new VoteAnalyzer(dayInfo.VoteList[0]);
                }
                else if (dayInfo.Equals(args.Agi.TodayInfo))
                {
                    // 投票宣言
                    voteAnalyzer = new VoteAnalyzer(dayInfo.LatestAliveAgentList, dayInfo.TalkList, Topic.VOTE);
                }

                if (voteAnalyzer != null)
                {
                    foreach (KeyValuePair <Agent, Agent> vote in voteAnalyzer.VoteMap)
                    {
                        if (vote.Value != null)
                        {
                            BitCondition con = new BitCondition();
                            con.AddWerewolf(vote.Key);
                            con.AddWerewolf(vote.Value);
                            guessList.Add(new PartGuess()
                            {
                                Condition   = con,
                                Correlation = 0.7,
                            });

                            con = new BitCondition();
                            con.AddNotWerewolf(vote.Key);
                            con.AddNotWerewolf(vote.Value);
                            guessList.Add(new PartGuess()
                            {
                                Condition   = con,
                                Correlation = 0.95,
                            });
                        }
                    }
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 3
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            guessList.Clear();

            // 0日目は抜ける
            if (args.Agi.Day <= 0)
            {
                return;
            }

            List <Agent> seerList = args.Agi.GetComingOutAgent(Role.SEER);

            // 1日目の投票の取得
            DayInfo      dayInfo      = args.Agi.DayInfo[1];
            VoteAnalyzer voteAnalyzer = null;

            if (dayInfo.VoteList.Count > 0)
            {
                // 実際の投票(1回目の投票のみ)
                voteAnalyzer = new VoteAnalyzer(dayInfo.VoteList[0]);
            }
            else
            {
                // 投票宣言
                voteAnalyzer = new VoteAnalyzer(dayInfo.LatestAliveAgentList, dayInfo.TalkList, Topic.VOTE);
            }

            if (voteAnalyzer != null)
            {
                foreach (KeyValuePair <Agent, Agent> vote in voteAnalyzer.VoteMap)
                {
                    if (seerList.Contains(vote.Value))
                    {
                        guessList.Add(new PartGuess()
                        {
                            Condition   = RoleCondition.GetCondition(vote.Key, Role.WEREWOLF),
                            Correlation = 1.1,
                        });
                    }
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 4
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();
            isSuccess = false;

            // 再投票時以外は抜ける
            if (args.Agi.TodayInfo.VoteList.Count <= 0)
            {
                return;
            }

            VoteAnalyzer firstVote = new VoteAnalyzer(args.Agi.TodayInfo.VoteList[0]);

            // 自分が追放されそうでなければ実行失敗で抜ける
            if (!firstVote.MaxVoteReceivedAgent.Contains(args.Agi.Me))
            {
                return;
            }

            // 自分が最大得票者に投票宣言しているか
            bool isVoteToMax = firstVote.MaxVoteReceivedAgent.Contains(firstVote.VoteMap[args.Agi.Me]);

            foreach (KeyValuePair <Agent, int> keyValue in firstVote.ReceiveVoteCount)
            {
                // 同票
                if (keyValue.Value == firstVote.MaxVoteReceiveCount && !args.Agi.GetAliveWerewolf().Contains(keyValue.Key))
                {
                    requestList.Add(new ActionRequest(keyValue.Key)
                    {
                        Vote = 3.0,
                    });
                }
                // 1票差
                if (keyValue.Value == firstVote.MaxVoteReceiveCount - 1 && !args.Agi.GetAliveWerewolf().Contains(keyValue.Key))
                {
                    requestList.Add(new ActionRequest(keyValue.Key)
                    {
                        Vote = (firstVote.MaxVoteReceivedAgent.Count == 1) ? 3.0 : 2.25,
                    });
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 5
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();

            VoteAnalyzer saidVote = args.Agi.TodayInfo.SaidVote;

            foreach (KeyValuePair <Agent, double> keyValue in saidVote.ReceiveVoteRate)
            {
                if (keyValue.Value != 0)
                {
                    requestList.Add(new ActionRequest(keyValue.Key)
                    {
                        Vote = 1.0 + keyValue.Value * 0.8,
                    });
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 6
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            VoteAnalyzer saidVote = args.Agi.TodayInfo.SaidVote;

            // 一定ターン以下なら抜ける
            if (args.Agi.TodayInfo.TalkList.Count <= args.Agi.AliveAgentList.Count * 2)
            {
                return;
            }

            // 対戦回数が一定未満なら抜ける
            AgentStatistics statistics = (AgentStatistics)args.Items["AgentStatistics"];

            if (statistics.statistics[args.Agi.Me].gameCount < 40)
            {
                return;
            }

            // 自分が追放されそうでなければ実行失敗で抜ける
            if (!saidVote.MaxVoteReceivedAgent.Contains(args.Agi.Me))
            {
                return;
            }


            // 自分が最大得票者に投票宣言しているか
            bool isVoteToMax = saidVote.MaxVoteReceivedAgent.Contains(saidVote.VoteMap[args.Agi.Me]);

            bool canAvoid = false;

            foreach (KeyValuePair <Agent, int> keyValue in saidVote.ReceiveVoteCount)
            {
                // 2票差以下ならまだ吊り逃れ可能と判断
                if (keyValue.Value >= saidVote.MaxVoteReceiveCount - 2 && !args.Agi.GetAliveWerewolf().Contains(keyValue.Key))
                {
                    canAvoid = true;
                }
            }

            // 処刑可能なら実行失敗で抜ける
            if (canAvoid)
            {
                return;
            }

            // 処刑不可避 → 身内切り
            foreach (Agent agent in args.Agi.GetAliveWerewolf())
            {
                requestList.Add(new ActionRequest(agent)
                {
                    Vote = 5.0,
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 7
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            guessList.Clear();

            // 0日目は抜ける
            if (args.Agi.Day <= 0)
            {
                return;
            }

            // 1日目の投票の取得
            DayInfo      dayInfo      = args.Agi.DayInfo[1];
            VoteAnalyzer voteAnalyzer = null;

            if (dayInfo.VoteList.Count > 0)
            {
                // 実際の投票(1回目の投票のみ)
                voteAnalyzer = new VoteAnalyzer(dayInfo.VoteList[0]);
            }
            else
            {
                // 投票宣言
                voteAnalyzer = new VoteAnalyzer(dayInfo.LatestAliveAgentList, dayInfo.TalkList, Topic.VOTE);
            }

            if (voteAnalyzer != null)
            {
                List <Agent> seerList   = args.Agi.GetComingOutAgent(Role.SEER);
                List <Agent> mediumList = args.Agi.GetComingOutAgent(Role.MEDIUM);
                // 黒判定を抽出
                List <Agent> receiveBlack = new List <Agent>();
                foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
                {
                    if (judge.JudgeTalk.Day == 1 && judge.Result == Species.WEREWOLF && !seerList.Contains(judge.Target) && !mediumList.Contains(judge.Target))
                    {
                        receiveBlack.Add(judge.Target);
                    }
                }

                if (mediumList.Count >= 2 && receiveBlack.Count <= 0)
                {
                    foreach (KeyValuePair <Agent, Agent> vote in voteAnalyzer.VoteMap)
                    {
                        if (mediumList.Contains(vote.Value))
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(vote.Key, Role.WEREWOLF),
                                Correlation = 0.7,
                            });
                        }
                    }
                }

                if (receiveBlack.Count >= 1)
                {
                    foreach (KeyValuePair <Agent, Agent> vote in voteAnalyzer.VoteMap)
                    {
                        if (vote.Value != null && !receiveBlack.Contains(vote.Value) && !(receiveBlack.Count == 1 && receiveBlack.Contains(vote.Key)))
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(vote.Key, Role.WEREWOLF),
                                Correlation = 1.2,
                            });
                        }
                    }
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 8
0
        public void update(AdvanceGameInfo agi)
        {
            bool isWinWolf = agi.AliveAgentList.Exists(agent => agi.RoleMap[agent] == Role.WEREWOLF);

            // 勝敗
            foreach (KeyValuePair <Agent, Role> kv in agi.RoleMap)
            {
                statistics[kv.Key].gameCount++;
                statistics[kv.Key].roleCount[kv.Value] = statistics[kv.Key].roleCount[kv.Value] + 1;
                statistics[kv.Key].increaseCOCount(kv.Value, agi.GetComingOutRole(kv.Key));
                if ((kv.Value.GetTeam() == Team.WEREWOLF) == isWinWolf)
                {
                    statistics[kv.Key].increaseEventCount(kv.Value, "Win");
                }
                else
                {
                    statistics[kv.Key].increaseEventCount(kv.Value, "Lose");
                }
            }

            // 投票
            foreach (DayInfo dayInfo in agi.DayInfo.Values)
            {
                if (dayInfo.VoteList.Count > 0)
                {
                    VoteAnalyzer va = dayInfo.SaidVote;
                    foreach (Vote vote in dayInfo.VoteList[0])
                    {
                        if (va.MaxVoteReceivedAgent.Contains(vote.Target))
                        {
                            statistics[vote.Agent].increaseEventCount(agi.RoleMap[vote.Agent], "VoteToMax");
                        }
                        else
                        {
                            statistics[vote.Agent].increaseEventCount(agi.RoleMap[vote.Agent], "VoteToNotMax");
                        }
                    }
                }
            }

            // 1d発言
            List <Agent> estAgentList = new List <Agent>();

            foreach (ExtTalk talk in agi.DayInfo[1].TalkList)
            {
                if (talk.Content.Operator == Operator.NOP && talk.Content.Topic == Topic.ESTIMATE)
                {
                    if (!estAgentList.Contains(talk.Agent))
                    {
                        statistics[talk.Agent].increaseEventCount(agi.RoleMap[talk.Agent], "1d_Estimate");
                        estAgentList.Add(talk.Agent);
                    }
                }
            }
            // 発言傾向
            foreach (DayInfo dayInfo in agi.DayInfo.Values)
            {
                foreach (ExtTalk talk in dayInfo.TalkList)
                {
                    int id = -1;
                    if (talk.Content.Operator == Operator.NOP)
                    {
                        switch (talk.Content.Topic)
                        {
                        case Topic.Over:
                            id = 1;
                            break;

                        case Topic.Skip:
                            id = 2;
                            break;

                        case Topic.VOTE:
                            id = 3;
                            break;

                        case Topic.ESTIMATE:
                            id = (talk.Content.Role.GetTeam() == Team.WEREWOLF) ? 4 : 5;
                            break;

                        case Topic.COMINGOUT:
                            id = 6;
                            break;

                        case Topic.DIVINED:
                        case Topic.IDENTIFIED:
                        case Topic.GUARDED:
                            id = 7;
                            break;

                        case Topic.AGREE:
                            id = 8;
                            break;

                        case Topic.DISAGREE:
                            id = 9;
                            break;

                        default:
                            break;
                        }
                    }
                    else if (talk.Content.Operator == Operator.REQUEST)
                    {
                        id = 10;
                    }

                    if (id > 0)
                    {
                        statistics[talk.Agent].talkCount.increaseCount(talk.Day, talk.Turn, agi.GetComingOutRole(talk.Agent), agi.RoleMap[talk.Agent], id);
                    }
                }
            }

            // 判定
            foreach (Wepwawet.Lib.Judge judge in agi.SeerJudge)
            {
                if (judge.JudgeTalk.Day == 1)
                {
                    if (judge.Result == Species.WEREWOLF)
                    {
                        statistics[judge.Agent].increaseEventCount(agi.RoleMap[judge.Agent], "1d_DevineBlack");
                    }
                    else
                    {
                        statistics[judge.Agent].increaseEventCount(agi.RoleMap[judge.Agent], "1d_DevineWhite");
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            VoteAnalyzer saidVote = args.Agi.TodayInfo.SaidVote;

            if (args.Agi.MyRole == Role.WEREWOLF)
            {
                // 人狼が追放されそうでなければ実行失敗で抜ける
                if (saidVote.MaxVoteReceivedAgent.Intersect(args.Agi.GetAliveWerewolf()).Count() == 0)
                {
                    return;
                }
            }
            else
            {
                // 自分が追放されそうでなければ実行失敗で抜ける
                if (!saidVote.MaxVoteReceivedAgent.Contains(args.Agi.Me))
                {
                    return;
                }
            }


            // 自分が最大得票者に投票宣言しているか
            bool isVoteToMax = saidVote.MaxVoteReceivedAgent.Contains(saidVote.VoteMap[args.Agi.Me]);

            foreach (KeyValuePair <Agent, int> keyValue in saidVote.ReceiveVoteCount)
            {
                // 同票
                if (keyValue.Value == saidVote.MaxVoteReceiveCount && !args.Agi.GetAliveWerewolf().Contains(keyValue.Key))
                {
                    requestList.Add(new ActionRequest(keyValue.Key)
                    {
                        Vote = 2.0,
                    });
                }
                // 1票差
                if (keyValue.Value == saidVote.MaxVoteReceiveCount - 1 && !args.Agi.GetAliveWerewolf().Contains(keyValue.Key))
                {
                    requestList.Add(new ActionRequest(keyValue.Key)
                    {
                        Vote = (saidVote.MaxVoteReceivedAgent.Count == 1) ? 2.0 : 1.5,
                    });
                }
                if (args.Agi.GameSetting.PlayerNum == 15)
                {
                    // 2票差
                    if (keyValue.Value == saidVote.MaxVoteReceiveCount - 2 && !args.Agi.GetAliveWerewolf().Contains(keyValue.Key))
                    {
                        requestList.Add(new ActionRequest(keyValue.Key)
                        {
                            Vote = (saidVote.MaxVoteReceivedAgent.Count == 1) ? 1.5 : 1.2,
                        });
                    }
                }
            }


            // 実行成功にする
            isSuccess = true;
        }