Пример #1
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();

            // 人外CO者を取得
            List <Agent> MonsterSideList = new List <Agent>();

            foreach (ComingOut co in args.Agi.MonsterSideComingOut)
            {
                if (co.IsEnable() && !MonsterSideList.Contains(co.Agent))
                {
                    MonsterSideList.Add(co.Agent);
                }
            }

            // 人外CO者への投票スコアを下げる
            foreach (Agent agent in MonsterSideList)
            {
                requestList.Add(new ActionRequest(agent)
                {
                    Vote = 0.9
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #2
0
 public void Update(ActionStrategyArgs args)
 {
     foreach (IActionPlannerNode node in Child)
     {
         node.Update(args);
     }
 }
Пример #3
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            // 0,1日は実行失敗で抜ける
            if (args.Agi.Day <= 1)
            {
                return;
            }

            // GJが発生していなければ実行失敗で抜ける
            if (args.Agi.YesterdayInfo.AttackDeadAgent.Count != 0)
            {
                return;
            }

            requestList.Add(new ActionRequest(args.Agi.YesterdayInfo.TryAttackAgent)
            {
                Attack = 0.2,
            });


            // 実行成功にする
            isSuccess = true;
        }
Пример #4
0
        /// <summary>
        /// 行動方針の決定
        /// </summary>
        protected virtual void PlanAction()
        {
            ActionStrategyArgs args = new ActionStrategyArgs {
                Agi = agi, GuessResult = LatestGuess
            };

            ActionPlanner.Execute(args);
        }
Пример #5
0
        /// <summary>
        /// 行動方針の決定
        /// </summary>
        protected override void PlanAction()
        {
            ActionStrategyArgs args = new ActionStrategyArgs {
                Agi = Agi, GuessResult = LatestGuess
            };

            args.Items.Add("AgentStatistics", statistics);
            LatestPlan = ActionPlanner.Execute(args);
        }
Пример #6
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();


            foreach (Agent agent in args.Agi.AgentList)
            {
                if (agent.Equals(args.Agi.Me))
                {
                    // 自分は全ての行動の対象にしない
                    requestList.Add(new ActionRequest(args.Agi.Me)
                    {
                        Vote   = 0.0,
                        Devine = 0.001,
                        Guard  = 0.0,
                        Attack = 0.0
                    });
                }
                else if (!args.Agi.TodayInfo.LatestAliveAgentList.Contains(agent))
                {
                    // 死亡済みエージェントは全ての行動の対象にしない
                    requestList.Add(new ActionRequest(agent)
                    {
                        Vote   = 0.0,
                        Devine = 0.0,
                        Guard  = 0.0,
                        Attack = 0.0
                    });
                }
                else if (!args.GuessResult.LikelyWolfPattern.ContainsKey(agent) ||
                         (!args.GuessResult.LikelyVillagerPattern.ContainsKey(agent) &&
                          !args.GuessResult.LikelyPossessedPattern.ContainsKey(agent)))
                {
                    // 確定白、確定黒は占いの対象にしない
                    requestList.Add(new ActionRequest(agent)
                    {
                        Devine = 0.001
                    });
                }
            }

            // 仲間の人狼は襲撃の対象にしない
            foreach (KeyValuePair <Agent, Role> val in args.Agi.RoleMap)
            {
                if (val.Value == Role.WEREWOLF && !val.Key.Equals(args.Agi.Me))
                {
                    requestList.Add(new ActionRequest(val.Key)
                    {
                        Attack = 0.0
                    });
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #7
0
        /// <summary>
        /// 行動計画を取得する
        /// </summary>
        /// <param name="args"></param>
        /// <param name="requests"></param>
        protected Plan GetPlan(ActionStrategyArgs args, List <ActionRequest> requests)
        {
            // 全員分の集計を初期化
            Plan plan = new Plan();

            foreach (Agent agent in args.Agi.AgentList)
            {
                plan.AggregateRequest.Add(agent, new ActionRequest(agent));
            }

            // 全計画を集計
            foreach (ActionRequest request in requests)
            {
                if (args.Agi.AgentList.Contains(request.Agent))
                {
                    ActionRequest agentRequest = plan.AggregateRequest[request.Agent];
                    agentRequest.Vote   *= request.Vote;
                    agentRequest.Devine *= request.Devine;
                    agentRequest.Guard  *= request.Guard;
                    agentRequest.Attack *= request.Attack;
                }
            }

            // 各行動の最大値を持つエージェントを取得
            ActionRequest VoteMax   = null;
            ActionRequest DevineMax = null;
            ActionRequest GuardMax  = null;
            ActionRequest AttackMax = null;

            foreach (KeyValuePair <Agent, ActionRequest> val in plan.AggregateRequest)
            {
                if (VoteMax == null || val.Value.Vote > VoteMax.Vote)
                {
                    VoteMax = val.Value;
                }
                if (DevineMax == null || val.Value.Devine > DevineMax.Devine)
                {
                    DevineMax = val.Value;
                }
                if (GuardMax == null || val.Value.Guard > GuardMax.Guard)
                {
                    GuardMax = val.Value;
                }
                if (AttackMax == null || val.Value.Attack > AttackMax.Attack)
                {
                    AttackMax = val.Value;
                }
            }
            plan.VoteTarget   = VoteMax?.Agent;
            plan.DevineTarget = DevineMax?.Agent;
            plan.GuardTarget  = GuardMax?.Agent;
            plan.AttackTarget = AttackMax?.Agent;

            return(plan);
        }
Пример #8
0
        public bool IsExecuteSuccess(ActionStrategyArgs args)
        {
            foreach (IBehaviorNode node in Child)
            {
                if (node.IsExecuteSuccess(args))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #9
0
        public List <ActionRequest> GetRequest(ActionStrategyArgs args)
        {
            request = new List <ActionRequest>();

            foreach (IBehaviorNode node in Child)
            {
                if (node.IsExecuteSuccess(args))
                {
                    request.AddRange(node.GetRequest(args));
                }
            }

            return(request);
        }
Пример #10
0
        public void Execute(ActionStrategyArgs args)
        {
            // 戦略が設定されていない場合、実行に失敗した場合は何もしない
            if (ActionStrategy == null || !ActionStrategy.IsExecuteSuccess(args))
            {
                return;
            }

            // 方針決定戦略から結果を取得
            List <ActionRequest> requests = ActionStrategy.GetRequest(args);

            // エージェント毎に行動要求を集計
            Calc(args, requests);

            // 各行動の対象になるエージェントを設定
            SetActionPlan();
        }
Пример #11
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;
        }
Пример #12
0
        /// <summary>
        /// 行動要求をエージェント毎に集計する
        /// </summary>
        /// <param name="args"></param>
        /// <param name="requests"></param>
        protected void Calc(ActionStrategyArgs args, List <ActionRequest> requests)
        {
            aggregateRequest = new Dictionary <Agent, ActionRequest>();
            foreach (Agent agent in args.Agi.LatestGameInfo.AgentList)
            {
                aggregateRequest.Add(agent, new ActionRequest(agent));
            }

            foreach (ActionRequest request in requests)
            {
                ActionRequest agentRequest = aggregateRequest[request.Agent];
                agentRequest.Vote   *= request.Vote;
                agentRequest.Devine *= request.Devine;
                agentRequest.Guard  *= request.Guard;
                agentRequest.Attack *= request.Attack;
            }
        }
Пример #13
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            // 占霊判定を合わせたリストを取得
            List <Wepwawet.Lib.Judge> MargeJudge = new List <Wepwawet.Lib.Judge>();

            MargeJudge.AddRange(args.Agi.SeerJudge);
            MargeJudge.AddRange(args.Agi.MediumJudge);

            // 狂人候補
            HashSet <Agent> possessedAgent = new HashSet <Agent>();

            // 全判定を見て、間違っていれば狂人候補にする
            foreach (Wepwawet.Lib.Judge judge in MargeJudge)
            {
                if (judge.IsEnable())
                {
                    if ((judge.Result == Species.WEREWOLF) != (isWolf(args.Agi, judge.Target)))
                    {
                        possessedAgent.Add(judge.Agent);
                    }
                }
            }

            // 狂人と思われるエージェントがいなければ実行失敗で抜ける
            if (possessedAgent.Count <= 0)
            {
                return;
            }

            // 狂人と思われるエージェントの襲撃スコアを下げる
            foreach (Agent agent in possessedAgent)
            {
                requestList.Add(new ActionRequest(agent)
                {
                    Attack = 0.2,
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #14
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();

            AgentStatistics statistics = (AgentStatistics)args.Items["AgentStatistics"];

            Array roles = Enum.GetValues(typeof(Role));

            foreach (Agent agent in args.Agi.AliveAgentList)
            {
                int maxc  = 0;
                int nmaxc = 0;

                Dictionary <Role, Dictionary <String, int> > eventCount = statistics.statistics[agent].eventCount;
                foreach (Role role in roles)
                {
                    if (eventCount[role].ContainsKey("VoteToMax"))
                    {
                        maxc += eventCount[role]["VoteToMax"];
                    }
                    if (eventCount[role].ContainsKey("VoteToNotMax"))
                    {
                        nmaxc += eventCount[role]["VoteToNotMax"];
                    }
                }

                if (maxc + nmaxc > 0)
                {
                    double rate = maxc / (double)(maxc + nmaxc);

                    requestList.Add(new ActionRequest(agent)
                    {
                        Vote   = 1 + rate * 0.1,
                        Devine = 1 + rate * 0.3,
                        Attack = 1 + rate * 0.3,
                    });
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #15
0
        public Plan Execute(ActionStrategyArgs args)
        {
            List <ActionRequest> requests = new List <ActionRequest>();

            // 戦略が設定されていて、実行に成功した場合
            if (ActionStrategy != null)
            {
                ActionStrategy.Update(args);

                if (ActionStrategy.IsSuccess())
                {
                    // 方針決定戦略から結果を取得
                    requests = ActionStrategy.GetRequest();
                }
            }

            // 行動方針を取得して返す
            return(GetPlan(args, requests));
        }
Пример #16
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;
        }
Пример #17
0
        public void Update(ActionStrategyArgs args)
        {
            node.Update(args);

            if (node.IsSuccess())
            {
                isSuccess   = true;
                requestList = node.GetRequest();
                foreach (ActionRequest request in requestList)
                {
                    request.Vote   = Math.Pow(request.Vote, weight);
                    request.Devine = Math.Pow(request.Devine, weight);
                    request.Guard  = Math.Pow(request.Guard, weight);
                    request.Attack = Math.Pow(request.Attack, weight);
                }
            }
            else
            {
                isSuccess   = false;
                requestList = new List <ActionRequest>();
            }
        }
Пример #18
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            // PP直前でなければ実行失敗で抜ける
            if (args.Agi.GetAliveWerewolf().Count + 1 < args.Agi.AliveAgentList.Count / 2 ||
                args.Agi.AgentList.Count == args.Agi.AliveAgentList.Count)
            {
                return;
            }

            // 役職CO者を取得
            List <Agent> seerList      = args.Agi.GetComingOutAgent(Role.SEER);
            List <Agent> mediumList    = args.Agi.GetComingOutAgent(Role.MEDIUM);
            List <Agent> bodyguardList = args.Agi.GetComingOutAgent(Role.BODYGUARD);
            List <Agent> villagerList  = args.Agi.GetComingOutAgent(Role.VILLAGER);

            // 全役職を見て、人間が2人以上いれば狂人候補にする
            List <Agent> possessedAgent = new List <Agent>();

            if (isExistPossessed(args.Agi, seerList))
            {
                possessedAgent.AddRange(seerList);
            }
            else if (isExistPossessed(args.Agi, mediumList))
            {
                possessedAgent.AddRange(mediumList);
            }
            else if (isExistPossessed(args.Agi, bodyguardList))
            {
                possessedAgent.AddRange(bodyguardList);
            }
            else
            {
                //役職にいない場合は村人、未COにいると考える
                possessedAgent.AddRange(args.Agi.AgentList);
                possessedAgent.RemoveAll(seerList.Contains);
                possessedAgent.RemoveAll(mediumList.Contains);
                possessedAgent.RemoveAll(bodyguardList.Contains);
            }

            // 狂人と思われるエージェントがいなければ実行失敗で抜ける
            if (possessedAgent.Count <= 0)
            {
                return;
            }

            // 狂人候補が1人でも死亡していれば実行失敗で抜ける
            if (isHumanDead(args.Agi, possessedAgent))
            {
                return;
            }

            // 狂人と思われるエージェントの襲撃スコアを下げる
            foreach (Agent agent in possessedAgent)
            {
                requestList.Add(new ActionRequest(agent)
                {
                    Attack = 0.2,
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #19
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();


            // 各エージェントの信用度を求める
            Dictionary <Agent, double> agentTrustScore = new Dictionary <Agent, double>();

            foreach (Agent agent in args.Agi.AliveAgentList)
            {
                // 自分は対象外
                if (agent.Equals(args.Agi.Me))
                {
                    continue;
                }

                double likelyVilScore = 0.0;
                if (args.GuessResult.LikelyVillagerPattern.ContainsKey(agent))
                {
                    likelyVilScore = args.GuessResult.LikelyVillagerPattern[agent].Score;
                }

                double likelyWolfScore = 0.0;
                if (args.GuessResult.LikelyWolfPattern.ContainsKey(agent))
                {
                    likelyWolfScore = args.GuessResult.LikelyWolfPattern[agent].Score;
                }

                double likelyPosScore = 0.0;
                if (args.GuessResult.LikelyPossessedPattern.ContainsKey(agent))
                {
                    likelyPosScore = args.GuessResult.LikelyPossessedPattern[agent].Score;
                }

                likelyVilScore  = Math.Max(likelyVilScore, 0.0);
                likelyWolfScore = Math.Max(likelyWolfScore, 0.0);
                likelyPosScore  = Math.Max(likelyPosScore, 0.0);

                double suspiciousScore = Math.Max(likelyWolfScore, likelyPosScore / 2);

                double trustScore = (likelyVilScore + 0.001) / (suspiciousScore + 0.001);

                // 一定以上信用できる人物のみ登録
                if (trustScore > 2.50)
                {
                    agentTrustScore.Add(agent, trustScore);
                }
            }

            // 一定以上信用できる人物を走査
            foreach (KeyValuePair <Agent, double> keyValue in agentTrustScore)
            {
                // 投票要求先のエージェント
                Agent requestVoteAgent = null;

                foreach (ExtTalk talk in args.Agi.TodayInfo.TalkList)
                {
                    // 発話エージェント一致
                    if (talk.Agent.Equals(keyValue.Key))
                    {
                        Content content = talk.Content;
                        // REQUEST
                        if (content.Operator == Operator.REQUEST)
                        {
                            Content refContent = content.ContentList[0];
                            // VOTEのREQUEST
                            if (refContent.Topic == Topic.VOTE)
                            {
                                requestVoteAgent = refContent.Target;
                            }
                        }
                    }
                }

                // VOTEのREQUEST先が存在する
                if (requestVoteAgent != null)
                {
                    requestList.Add(new ActionRequest(requestVoteAgent)
                    {
                        Vote = 1.2,
                    });
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #20
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;
        }
Пример #21
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();

            foreach (Agent agent in args.Agi.AliveAgentList)
            {
                // 自分は対象外
                if (agent.Equals(args.Agi.Me))
                {
                    continue;
                }

                double likelyVilScore = 0.0;
                if (args.GuessResult.LikelyVillagerPattern.ContainsKey(agent))
                {
                    likelyVilScore = args.GuessResult.LikelyVillagerPattern[agent].Score;
                }

                double likelyWolfScore = 0.0;
                if (args.GuessResult.LikelyWolfPattern.ContainsKey(agent))
                {
                    likelyWolfScore = args.GuessResult.LikelyWolfPattern[agent].Score;
                }

                double likelyPosScore = 0.0;
                if (args.GuessResult.LikelyPossessedPattern.ContainsKey(agent))
                {
                    likelyPosScore = args.GuessResult.LikelyPossessedPattern[agent].Score;
                }

                double suspiciousScore = Math.Max(likelyWolfScore, likelyPosScore / 2);

                if (likelyVilScore < 0.0001)
                {
                    // 村陣営の内訳が存在しない or 非常に薄い
                    if (args.Agi.AliveAgentList.Count > 4)
                    {
                        suspiciousScore = 2.1;
                    }
                    else if (likelyWolfScore > likelyPosScore * 1.4)
                    {
                        suspiciousScore = 2.1;
                    }
                    else
                    {
                        suspiciousScore = 1.2;
                    }
                }
                else
                {
                    suspiciousScore = Math.Max(likelyWolfScore, likelyPosScore / 3);
                    suspiciousScore = Math.Min(Math.Max(suspiciousScore / likelyVilScore, 0.001), 2.0);
                }

                requestList.Add(new ActionRequest(agent)
                {
                    Vote   = suspiciousScore,
                    Devine = Math.Pow(suspiciousScore, 0.4),
                    Guard  = Math.Pow(1 / suspiciousScore, 0.2),
                    Attack = Math.Pow(1 / suspiciousScore, 0.3),
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #22
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();


            // 役職CO者を取得
            List <Agent> seerList      = args.Agi.GetComingOutAgent(Role.SEER);
            List <Agent> mediumList    = args.Agi.GetComingOutAgent(Role.MEDIUM);
            List <Agent> bodyguardList = args.Agi.GetComingOutAgent(Role.BODYGUARD);
            List <Agent> villagerList  = args.Agi.GetComingOutAgent(Role.VILLAGER);

            // TODO 役職が襲撃されているかを取得
            // TODO 狼は0.3乗するのでAttackをその分大きくしている。別クラスにすべき?

            int day = args.Agi.Day;

            // 占い師
            foreach (Agent agent in seerList)
            {
                double voteScore   = Between((-0.2 + day * 0.3), 0.001, 1.0);
                double devineScore = 0.2;
                double guardScore;
                double attackScore = 40.0;

                switch (seerList.Count)
                {
                case 1:
                    guardScore = 10.0;
                    break;

                case 2:
                    guardScore = 4.0;
                    break;

                case 3:
                    guardScore = 2.0;
                    break;

                default:
                    guardScore = 1.0;
                    break;
                }

                requestList.Add(new ActionRequest(agent)
                {
                    Vote   = voteScore,
                    Devine = devineScore,
                    Guard  = guardScore,
                    Attack = attackScore,
                });
            }

            // 霊媒師
            foreach (Agent agent in mediumList)
            {
                double voteScore;
                double devineScore = 0.05;
                double guardScore;
                double attackScore;

                switch (mediumList.Count)
                {
                case 1:
                    voteScore   = Between((-0.2 + day * 0.3), 0.001, 1.0);
                    guardScore  = 0.2;
                    attackScore = 10.0;
                    break;

                default:
                    voteScore   = Between((1.0 + mediumList.Count - day * 0.5), 1.0, 10.0);
                    guardScore  = 0.1;
                    attackScore = 0.0005;
                    break;
                }

                requestList.Add(new ActionRequest(agent)
                {
                    Vote   = voteScore,
                    Devine = devineScore,
                    Guard  = guardScore,
                    Attack = attackScore,
                });
            }

            // 狩人
            foreach (Agent agent in bodyguardList)
            {
                double voteScore   = Between((-0.2 + day * 0.3), 0.001, 1.0);
                double devineScore = 0.3;
                double guardScore  = 0.001;
                double attackScore = 10000.0;

                requestList.Add(new ActionRequest(agent)
                {
                    Vote   = voteScore,
                    Devine = devineScore,
                    Guard  = guardScore,
                    Attack = attackScore,
                });
            }


            // 判定
            List <Agent> receiveWhiteList = new List <Agent>();
            List <Agent> receiveBlackList = new List <Agent>();

            foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
            {
                // 判定が有効ではない
                if (!judge.IsEnable())
                {
                    continue;
                }
                // 判定を出した者が村側のパターンが存在しない
                if (!args.GuessResult.LikelyVillagerPattern.ContainsKey(judge.Agent))
                {
                    continue;
                }
                ((judge.Result == Species.HUMAN) ? receiveWhiteList : receiveBlackList).Add(judge.Target);
            }
            foreach (Agent agent in args.Agi.AliveAgentList)
            {
                // 人間判定
                if (receiveWhiteList.Contains(agent))
                {
                    double voteScore   = Between((0.4 + day * 0.2), 0.001, 1.0);
                    double devineScore = Between((0.6 + day * 0.1), 0.001, 1.0);
                    double guardScore  = 1.2;
                    double attackScore = 3.0;

                    requestList.Add(new ActionRequest(agent)
                    {
                        Vote   = voteScore,
                        Devine = devineScore,
                        Guard  = guardScore,
                        Attack = attackScore,
                    });
                }
                // 人狼判定
                if (receiveBlackList.Contains(agent))
                {
                    double voteScore   = Between((3.8 - day * 0.7), 1.0, 10.0);
                    double devineScore = Between((0.2 + day * 0.15), 0.001, 0.8);
                    double guardScore  = Between((0.1 + day * 0.02), 0.001, 0.5);
                    double attackScore = 0.0005;

                    requestList.Add(new ActionRequest(agent)
                    {
                        Vote   = voteScore,
                        Devine = devineScore,
                        Guard  = guardScore,
                        Attack = attackScore,
                    });
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #23
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;
        }
Пример #24
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            requestList.Clear();

            // 初回実行時、推理戦略の設定
            if (guessRoot == null)
            {
                guessRoot = new ParallelTreeGuess();
                guessRoot.Child.Add(new FirstImpression());
                guessRoot.Child.Add(new Learn_Talk());
                guessRoot.Child.Add(new AllFake());
                guessRoot.Child.Add(new VoteLine());
                if (args.Agi.GameSetting.PlayerNum == 5)
                {
                    guessRoot.Child.Add(new COPattern());
                    guessRoot.Child.Add(new VoteTarget_5());
                    guessRoot.Child.Add(new KusoMeta5());
                }
                if (args.Agi.GameSetting.PlayerNum == 15)
                {
                    guessRoot.Child.Add(new VoteTarget_15());
                    guessRoot.Child.Add(new KusoMeta15());
                }
            }

            TreeGuessManager guessManager = new TreeGuessManager()
            {
                GuessStrategy = guessRoot
            };
            GuessStrategyArgs gArgs = new GuessStrategyArgs()
            {
                Agi = args.Agi, Items = args.Items
            };
            // 推理する視点
            Viewpoint vp = args.Agi.SelfPossessedViewTrustInfo;

            if (vp.MonsterSidePattern.Count <= 0)
            {
                vp = args.Agi.AllViewSystemInfo;
            }
            GuessResult posGuess = guessManager.Exec(gArgs, vp);


            foreach (Agent agent in args.Agi.AliveAgentList)
            {
                // 自分は対象外
                if (agent.Equals(args.Agi.Me))
                {
                    continue;
                }

                double likelyVilScore = 0.0;
                if (posGuess.LikelyVillagerPattern.ContainsKey(agent))
                {
                    likelyVilScore = posGuess.LikelyVillagerPattern[agent].Score;
                }

                double likelyWolfScore = 0.0;
                if (posGuess.LikelyWolfPattern.ContainsKey(agent))
                {
                    likelyWolfScore = posGuess.LikelyWolfPattern[agent].Score;
                }

                double likelyPosScore = 0.0;
                if (posGuess.LikelyPossessedPattern.ContainsKey(agent))
                {
                    likelyPosScore = posGuess.LikelyPossessedPattern[agent].Score;
                }

                double suspiciousScore = Math.Max(likelyWolfScore, likelyPosScore / 2);

                if (likelyVilScore < 0.0001)
                {
                    // 村陣営の内訳が存在しない or 非常に薄い
                    if (args.Agi.AliveAgentList.Count > 4)
                    {
                        suspiciousScore = 2.1;
                    }
                    else if (likelyWolfScore > likelyPosScore * 1.4)
                    {
                        suspiciousScore = 2.1;
                    }
                    else
                    {
                        suspiciousScore = 1.2;
                    }
                }
                else
                {
                    suspiciousScore = Math.Max(likelyWolfScore, likelyPosScore / 2);
                    suspiciousScore = Math.Min(Math.Max(suspiciousScore / likelyVilScore, 0.001), 2.0);
                }

                requestList.Add(new ActionRequest(agent)
                {
                    Vote   = 1 / suspiciousScore,
                    Devine = Math.Pow(suspiciousScore, 0.4),
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #25
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            AgentStatistics statistics = (AgentStatistics)args.Items["AgentStatistics"];

            // 10戦未満なら抜ける
            if (statistics.statistics[args.Agi.Me].gameCount < 10)
            {
                return;
            }

            Array roles = Enum.GetValues(typeof(Role));

            // 勝率計算
            Dictionary <Agent, double> winRate = new Dictionary <Agent, double>();

            foreach (Agent agent in args.Agi.AliveAgentList)
            {
                int winc = 0, losec = 0;
                Dictionary <Role, Dictionary <String, int> > eventCount = statistics.statistics[agent].eventCount;
                foreach (Role role in roles)
                {
                    if (eventCount[role].ContainsKey("Win"))
                    {
                        winc += eventCount[role]["Win"];
                    }
                    if (eventCount[role].ContainsKey("Lose"))
                    {
                        losec += eventCount[role]["Lose"];
                    }
                }
                winRate.Add(agent, winc / (double)(winc + losec));
            }
            if (winRate.ContainsKey(args.Agi.Me))
            {
                winRate.Remove(args.Agi.Me);
            }

            // 5人村初日用
            if (args.Agi.GameSetting.PlayerNum == 5 && args.Agi.MyRole == Role.SEER)
            {
                if (args.Agi.Day == 0)
                {
                    Agent target = winRate.OrderByDescending(a => a.Value).ElementAt(1).Key;
                    requestList.Add(new ActionRequest(target)
                    {
                        Devine = 10.0,
                    });
                    // 実行成功にして抜ける
                    isSuccess = true;
                    return;
                }
            }

            foreach (Agent agent in winRate.Keys)
            {
                double rate = winRate[agent];

                requestList.Add(new ActionRequest(agent)
                {
                    Vote   = 1 + rate * 0.4,
                    Devine = 1 + rate * 1.0,
                    Attack = 1 + rate * 0.4,
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Пример #26
0
        public void Update(ActionStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            requestList.Clear();

            // 状況が付く前は実行失敗で抜ける
            if (args.Agi.AliveAgentList.Count == args.Agi.AgentList.Count)
            {
                return;
            }

            // 最新の投票を取得
            List <Vote> voteList = null;

            if (args.Agi.YesterdayInfo.VoteList.Count > 0)
            {
                voteList = args.Agi.YesterdayInfo.VoteList[0];
            }
            if (args.Agi.TodayInfo.VoteList.Count > 0)
            {
                voteList = args.Agi.TodayInfo.VoteList[0];
            }
            if (voteList == null)
            {
                return;
            }

            foreach (Vote vote in voteList)
            {
                if (args.Agi.GetAliveWerewolf().Contains(vote.Target))
                {
                    requestList.Add(new ActionRequest(vote.Agent)
                    {
                        Attack = 1.2,
                    });
                }
            }

            /*
             *
             *
             *  for( Agent agent : gameInfo.getAliveAgentList() ){
             *          if( args.agi.isWolf(agent.getAgentIdx())  ){
             *                  continue;
             *          }
             *          double attackRate = 1.0;
             *          for( Agent target : gameInfo.getAliveAgentList() ){
             *                  if( !agent.equals(target) && args.agi.isWolf(target.getAgentIdx()) ){
             *                          double rate = args.agi.getSuspicionWerewolfRate(agent.getAgentIdx(), target.getAgentIdx());
             *
             *                          attackRate *= Math.pow(Math.max(rate, 0.1) + 0.5, 0.2);
             *                  }
             *          }
             *
             *          workReq = new Request(agent.getAgentIdx());
             *          workReq.attack = attackRate;
             *          Requests.add(workReq);
             *  }
             *
             */

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