Ejemplo n.º 1
0
        public ActionResult Index(RoleCondition condition)
        {
            var roles  = roleService.SearchRoles(condition);
            var models = new PagedList <Role>(roles, roles.Paging);

            return(View(models));
        }
Ejemplo n.º 2
0
        public IActionResult Search([FromQuery] RoleCondition c, [FromQuery] bool with_RolePermissionList, [FromQuery] string[] order, int currentPage = 1, int pageSize = 10, DateTime?p_when = null)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var q = db.Role
                        .LoadWith(with_RolePermissionList, _ => _.RolePermissionList)
                        .IsActiveAt(p_when)
                ;
                var filtered = c == null ? q : q.Where(c.CreatePredicate());
                var ordered  = order.Any() ? filtered.SortBy(order) : filtered;
                var result   = ordered.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();

                #region アソシエーションでLoadWithしたものもフィルタする
                if (p_when != null)
                {
                    result.ForEach(_ =>
                    {
                        _.RolePermissionList = _.RolePermissionList?.Where(_ => _.IsActiveAt(p_when));
                    });
                }
                #endregion

                return(Ok(result));
            }
        }
Ejemplo n.º 3
0
        public async Task <ListResult <Role> > GetDataList(RoleCondition condition)
        {
            Expression <Func <Role, bool> > where = w =>
                                                    string.IsNullOrEmpty(condition.Name) || w.Name.Contains(condition.Name);
            var result = await base.GetPageAsync(where, w => w.CreateTime, condition.PageIndex, condition.PageSize);

            return(new ListResult <Role>(condition.PageIndex, condition.PageSize, result.Item1, result.Item2));
        }
Ejemplo n.º 4
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            guessList.Clear();

            // 初日は行わない
            if (args.Agi.Day < 1)
            {
                return;
            }

            // 1日目0発言では行わない
            if (args.Agi.Day == 1 && args.Agi.TodayInfo.TalkList.Count == 0)
            {
                return;
            }

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

            foreach (Agent agent in args.Agi.AgentList)
            {
                if (statistics.statistics[agent].roleCount[Role.WEREWOLF] >= 5)
                {
                    int roleCnt    = statistics.statistics[agent].roleCount[Role.WEREWOLF];
                    int roleEveCnt = statistics.statistics[agent].COCount[Role.WEREWOLF][args.Agi.GetComingOutRole(agent)];

                    if (roleEveCnt == 0)
                    {
                        guessList.Add(new PartGuess()
                        {
                            Condition   = RoleCondition.GetCondition(agent, Role.WEREWOLF),
                            Correlation = 0.7
                        });
                    }
                }

                if (statistics.statistics[agent].roleCount[Role.POSSESSED] >= 3)
                {
                    int roleCnt    = statistics.statistics[agent].roleCount[Role.POSSESSED];
                    int roleEveCnt = statistics.statistics[agent].COCount[Role.POSSESSED][args.Agi.GetComingOutRole(agent)];

                    if (roleEveCnt == 0)
                    {
                        guessList.Add(new PartGuess()
                        {
                            Condition   = RoleCondition.GetCondition(agent, Role.POSSESSED),
                            Correlation = 0.7
                        });
                    }
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public async Task <IEnumerable <Role> > GetList(RoleCondition condition)
        {
            var pg = new PredicateGroup {
                Operator = GroupOperator.And, Predicates = new List <IPredicate>()
            };

            if (condition.CreateId.HasValue && condition.CreateId > 0 && condition.RoleId > 1)
            {
                pg.Predicates.Add(Predicates.Field <Role>(l => l.CreateId, Operator.Eq, condition.CreateId.Value));
            }
            return(await _roleRepository.GetListWithCondition <Role>(pg));
        }
Ejemplo n.º 6
0
        public async Task <JsonResult> GetList()
        {
            var user      = (User)Session["User"];
            var condition = new RoleCondition
            {
                CreateId = user.Id,
                RoleId   = user.RoleId
            };
            var list = await _roleService.GetList(condition);

            return(Json(user.Id == 1 ? list : list.Where(s => s.Id > 1), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public List <PartGuess> GetRateGuess(int day, int turn, Role coRole, int talkKind, Agent agent)
        {
            int allRoleTalkCount  = count[day, turn, (int)coRole, 0, 0];
            int wolfTalkCount     = count[day, turn, (int)coRole, (int)Role.WEREWOLF, 0];
            int posTalkCount      = count[day, turn, (int)coRole, (int)Role.POSSESSED, 0];
            int allRoleEventCount = count[day, turn, (int)coRole, 0, talkKind];
            int wolfEventCount    = count[day, turn, (int)coRole, (int)Role.WEREWOLF, talkKind];
            int posEventCount     = count[day, turn, (int)coRole, (int)Role.POSSESSED, talkKind];
            int vilRoleTalkCount  = allRoleTalkCount - wolfTalkCount - posTalkCount;
            int vilRoleEventCount = allRoleEventCount - wolfEventCount - posEventCount;

            if (allRoleTalkCount >= 50)
            {
                double wolfRate = 1.0;
                double posRate  = 1.0;
                if (vilRoleEventCount > 0)
                {
                    if (wolfEventCount > 0)
                    {
                        wolfRate = (wolfEventCount / (double)wolfTalkCount) / (vilRoleEventCount / (double)vilRoleTalkCount);
                    }
                    else
                    {
                        wolfRate = 0.5;
                    }
                    if (posEventCount > 0)
                    {
                        posRate = (posEventCount / (double)posTalkCount) / (vilRoleEventCount / (double)vilRoleTalkCount);
                    }
                    else
                    {
                        posRate = 0.5;
                    }
                }
                else
                {
                    wolfRate = 3.0;
                    posRate  = 3.0;
                }
                return(new List <PartGuess>()
                {
                    new PartGuess()
                    {
                        Condition = RoleCondition.GetCondition(agent, Role.WEREWOLF), Correlation = wolfRate
                    },
                    new PartGuess()
                    {
                        Condition = RoleCondition.GetCondition(agent, Role.POSSESSED), Correlation = posRate
                    },
                });
            }
            return(new List <PartGuess>());
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <IEnumerable <User> > GetUserList(long userId)
        {
            var condition = new RoleCondition
            {
                CreateId = userId
            };
            var roleList = await _roleService.GetList(condition);

            var roleidList = string.Join(",", roleList.Select(s => s.Id.ToString()));

            return(await _userRepository.GetUserList(roleidList));
        }
Ejemplo n.º 9
0
        public int PhysicallyRemove([FromUri] RoleCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var count = db.Role
                            .Where(c.CreatePredicate())
                            .Delete();
                return(count);
            }
        }
Ejemplo n.º 10
0
        public void and条件_複数エージェント狼()
        {
            for (int i = 0; i < loop; i++)
            {
                Viewpoint viewpoint = new Viewpoint(gameSetting15, gameInfo15);

                AndCondition con = new AndCondition();
                con.AddCondition(RoleCondition.GetCondition(Agent.GetAgent(1), Role.WEREWOLF));
                con.AddCondition(RoleCondition.GetCondition(Agent.GetAgent(2), Role.WEREWOLF));
                viewpoint.RemoveMatchPattern(con);

                Assert.AreEqual(viewpoint.MonsterSidePattern.Count, 5304);
            }
        }
Ejemplo n.º 11
0
        public int Remove([FromUri] RoleCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var count = db.Role
                            .Where(c.CreatePredicate())
                            .Set(_ => _.removed_at, Sql.CurrentTimestampUtc)
                            .Update();
                return(count);
            }
        }
Ejemplo n.º 12
0
        public int Count([FromUri] RoleCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var count =
                    c == null?db.Role.Count() :
                        db.Role.Count(predicate: c.CreatePredicate());

                return(count);
            }
        }
Ejemplo n.º 13
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.º 14
0
        public void matchNum条件_複数エージェント狼()
        {
            for (int i = 0; i < loop; i++)
            {
                Viewpoint viewpoint = new Viewpoint(gameSetting15, gameInfo15);

                MatchNumCondition con = new MatchNumCondition()
                {
                    MinNum = 1, MaxNum = 2
                };
                con.AddCondition(RoleCondition.GetCondition(Agent.GetAgent(1), Role.WEREWOLF));
                con.AddCondition(RoleCondition.GetCondition(Agent.GetAgent(2), Role.WEREWOLF));
                con.AddCondition(RoleCondition.GetCondition(Agent.GetAgent(3), Role.WEREWOLF));
                viewpoint.RemoveMatchPattern(con);

                Assert.AreEqual(viewpoint.MonsterSidePattern.Count, 2652);
            }
        }
Ejemplo n.º 15
0
        public IPagedList <Role> SearchRoles(RoleCondition condition)
        {
            var query = new Repository <Role>().Table;

            if (!string.IsNullOrEmpty(condition.Name))
            {
                query = query.Where(t => t.Name.Contains(condition.Name));
            }
            if (condition.BeginDate != null)
            {
                query = query.Where(u => u.CreateDate >= condition.BeginDate);
            }
            if (condition.EndDate != null)
            {
                query = query.Where(u => u.CreateDate <= condition.EndDate);
            }
            query = query.Where(t => t.IsDelete == false);
            query = query.OrderByDescending(t => t.CreateDate);

            return(new PagedList <Role>(query, condition.PageIndex, condition.PageSize));
        }
Ejemplo n.º 16
0
        public List <PartGuess> GetGuess(GuessStrategyArgs args)
        {
            if (guess == null)
            {
                Random r = new System.Random();
                guess = new List <PartGuess>();
                foreach (Agent agent in args.Agi.LatestGameInfo.AgentList)
                {
                    RoleCondition wolfCondition = RoleCondition.GetCondition(agent, Role.WEREWOLF);
                    RoleCondition posCondition  = RoleCondition.GetCondition(agent, Role.POSSESSED);

                    guess.Add(new PartGuess()
                    {
                        Condition   = new OrCondition().AddCondition(wolfCondition).AddCondition(posCondition),
                        Correlation = 0.95 + r.NextDouble() * 0.1
                    });
                }
            }

            return(guess);
        }
Ejemplo n.º 17
0
        public IEnumerable <Role> Search([FromUri] bool with_RolePermissionList, [FromUri] RoleCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var q = db.Role;

                #region LoadWith
                if (with_RolePermissionList)
                {
                    q = q.LoadWith(_ => _.RolePermissionList);
                }
                #endregion

                var list = (c == null ? q : q.Where(c.CreatePredicate())).ToList();
                return(list);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 日付変更時(昼の開始時)の処理
        /// </summary>
        private void DayStart(GameInfo gameInfo)
        {
            // 死体で発見されたエージェントが人狼のパターンを削除する
            foreach (Agent agent in gameInfo.LastDeadAgentList)
            {
                ICondition condition = RoleCondition.GetCondition(agent, Role.WEREWOLF);
                AllViewSystemInfo.RemoveMatchPattern(condition);
            }

            //TODO 飽和が早い配役対応 (15人村→4日目から)(5人村→1狼のため必要無し)
            // 人狼生存人数がおかしいパターンを削除する
            int maxWolfNum = (gameInfo.AliveAgentList.Count - 1) / 2;

            maxWolfNum = Math.Min(maxWolfNum, GameSetting.RoleNumMap[Role.WEREWOLF]);
            if (gameInfo.Day > GameSetting.RoleNumMap[Role.WEREWOLF])
            {
                MatchNumCondition condition = new MatchNumCondition()
                {
                    MinNum = 1, MaxNum = maxWolfNum,
                };
                foreach (Agent agent in gameInfo.AliveAgentList)
                {
                    condition.AddCondition(RoleCondition.GetCondition(agent, Role.WEREWOLF));
                }
                AllViewSystemInfo.RemoveNotMatchPattern(condition);
            }

            talkOffset = 0;

            // debug

            /*
             * Console.Write(gameInfo.Day + "日目 : ");
             * Console.Write(SelfViewSystemInfo.MonsterSidePattern.Count);
             * Console.Write(" / ");
             * Console.Write(AllViewSystemInfo.MonsterSidePattern.Count);
             * Console.WriteLine("");
             */
        }
Ejemplo n.º 19
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            guessList.Clear();

            // 初日1発言目は行わない
            if (args.Agi.Day < 1 && args.Agi.TodayInfo.TalkList.Count == 0)
            {
                wolfScore = Enumerable.Repeat(1.0, args.Agi.AgentList.Count + 1).ToArray();
                posScore  = Enumerable.Repeat(1.0, args.Agi.AgentList.Count + 1).ToArray();
                return;
            }

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

            foreach (ExtTalk talk in args.Agi.TodayInfo.LatestTalkList)
            {
                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)
                {
                    wolfScore[talk.Agent.AgentIdx] *=
                        PowBetween(
                            statistics.statistics[talk.Agent].talkCount.GetWolfRate(
                                talk.Day, talk.Turn, args.Agi.GetComingOutRole(talk.Agent), id
                                ),
                            0.7, 1.5
                            );
                    posScore[talk.Agent.AgentIdx] *=
                        PowBetween(
                            statistics.statistics[talk.Agent].talkCount.GetPosRate(
                                talk.Day, talk.Turn, args.Agi.GetComingOutRole(talk.Agent), id
                                ),
                            0.7, 1.5
                            );
                }
            }

            foreach (Agent agent in args.Agi.AgentList)
            {
                guessList.Add(new PartGuess()
                {
                    Condition   = RoleCondition.GetCondition(agent, Role.WEREWOLF),
                    Correlation = PowBetween(wolfScore[agent.AgentIdx], 0.4, 3.0)
                });
                guessList.Add(new PartGuess()
                {
                    Condition   = RoleCondition.GetCondition(agent, Role.POSSESSED),
                    Correlation = PowBetween(posScore[agent.AgentIdx], 0.4, 3.0)
                });
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 推理結果の集計を取得
        /// </summary>
        /// <param name="args">推理戦略の引数</param>
        /// <param name="guessList">部分内訳への推理</param>
        private GuessResult GetResult(GuessStrategyArgs args, List <PartGuess> guessList, Viewpoint vp)
        {
            GuessResult result = new GuessResult();

            List <Agent> agentList = args.Agi.AgentList;

            // 複数エージェントに対する推理
            List <PartGuess> MultiAgentGuess = new List <PartGuess>(guessList.Count);

            // エージェント単体の推理を先に計算する(高速化)
            double[] singleWolfScore      = new double[agentList.Count + 1];
            double[] singlePossessedScore = new double[agentList.Count + 1];
            foreach (Agent agent in agentList)
            {
                singleWolfScore[agent.AgentIdx]      = 1.0;
                singlePossessedScore[agent.AgentIdx] = 1.0;
            }
            // 各推理が内訳条件を満たせばスコアを適用する
            foreach (PartGuess guess in guessList)
            {
                if (guess.Condition is RoleCondition)
                {
                    RoleCondition con = ((RoleCondition)guess.Condition);
                    if (con.Role == Role.WEREWOLF)
                    {
                        singleWolfScore[con.Agent.AgentIdx] *= guess.Correlation;
                    }
                    else if (con.Role == Role.POSSESSED)
                    {
                        singlePossessedScore[con.Agent.AgentIdx] *= guess.Correlation;
                    }
                }
                else if (guess.Condition is TeamCondition)
                {
                    TeamCondition con = ((TeamCondition)guess.Condition);
                    if (con.Team == Team.WEREWOLF)
                    {
                        singleWolfScore[con.Agent.AgentIdx]      *= guess.Correlation;
                        singlePossessedScore[con.Agent.AgentIdx] *= guess.Correlation;
                    }
                    else
                    {
                        singleWolfScore[con.Agent.AgentIdx]      /= guess.Correlation;
                        singlePossessedScore[con.Agent.AgentIdx] /= guess.Correlation;
                    }
                }
                else
                {
                    MultiAgentGuess.Add(guess);
                }
            }

            // 各集計用
            double allLikelyScore = double.MinValue;

            double[] likelyWolfScore = Enumerable.Repeat(double.MinValue, agentList.Count + 1).ToArray();
            double[] likelyPosScore  = Enumerable.Repeat(double.MinValue, agentList.Count + 1).ToArray();
            double[] likelyFoxScore  = Enumerable.Repeat(double.MinValue, agentList.Count + 1).ToArray();
            double[] likelyVilScore  = Enumerable.Repeat(double.MinValue, agentList.Count + 1).ToArray();

            // 各内訳にスコアを付ける
            result.AllPattern = new List <AggregateGuess>(vp.MonsterSidePattern.Count);
            foreach (MonsterSidePattern pattern in vp.MonsterSidePattern.Values)
            {
                AggregateGuess gpattern = new AggregateGuess(pattern);
                result.AllPattern.Add(gpattern);

                // エージェント単体の推理を反映(高速化)
                foreach (Agent agent in gpattern.Pattern.WerewolfAgent)
                {
                    gpattern.Score *= singleWolfScore[agent.AgentIdx];
                }
                foreach (Agent agent in gpattern.Pattern.PossessedAgent)
                {
                    gpattern.Score *= singlePossessedScore[agent.AgentIdx];
                }

                // 各推理が内訳条件を満たせばスコアを適用する
                foreach (PartGuess guess in MultiAgentGuess)
                {
                    if (guess.Condition.IsMatch(pattern))
                    {
                        gpattern.Score *= guess.Correlation;
                    }
                }

                // 以下集計処理
                // 個人毎の最も村陣営・人狼・狂人・妖狐スコアの大きい内訳を集計する
                HashSet <Agent> remainAgent = new HashSet <Agent>();
                foreach (Agent agent in agentList)
                {
                    remainAgent.Add(agent);
                }

                foreach (Agent agent in gpattern.Pattern.WerewolfAgent)
                {
                    if (gpattern.Score > likelyWolfScore[agent.AgentIdx])
                    {
                        result.LikelyWolfPattern[agent] = gpattern;
                        likelyWolfScore[agent.AgentIdx] = gpattern.Score;
                    }
                    remainAgent.Remove(agent);
                }

                foreach (Agent agent in gpattern.Pattern.PossessedAgent)
                {
                    if (gpattern.Score > likelyPosScore[agent.AgentIdx])
                    {
                        result.LikelyPossessedPattern[agent] = gpattern;
                        likelyPosScore[agent.AgentIdx]       = gpattern.Score;
                    }
                    remainAgent.Remove(agent);
                }

                foreach (Agent agent in gpattern.Pattern.FoxAgent)
                {
                    if (gpattern.Score > likelyFoxScore[agent.AgentIdx])
                    {
                        result.LikelyFoxPattern[agent] = gpattern;
                        likelyFoxScore[agent.AgentIdx] = gpattern.Score;
                    }
                    remainAgent.Remove(agent);
                }

                foreach (Agent agent in remainAgent)
                {
                    if (gpattern.Score > likelyVilScore[agent.AgentIdx])
                    {
                        result.LikelyVillagerPattern[agent] = gpattern;
                        likelyVilScore[agent.AgentIdx]      = gpattern.Score;
                    }
                }

                // 最もスコアの大きい内訳を集計する
                if (gpattern.Score > allLikelyScore)
                {
                    result.LikelyPattern = gpattern;
                    allLikelyScore       = gpattern.Score;
                }
            }

            return(result);
        }
 public async Task <IActionResult> GetPaged(PagingRequest request, RoleCondition condition)
 {
     return(Json(await _roleService.GetPaged(request)));
 }
Ejemplo n.º 22
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            guessList.Clear();

            // 自分の判定は100%信じる
            foreach (AIWolf.Lib.Judge judge in args.Agi.MySeerJudge)
            {
                guessList.Add(new PartGuess()
                {
                    Condition   = RoleCondition.GetCondition(judge.Target, Role.WEREWOLF),
                    Correlation = (judge.Result == Species.WEREWOLF) ? 10.0 : 0.0,
                });
            }

            // 役職CO者を取得
            List <Agent> seerList = args.Agi.GetComingOutAgent(Role.SEER);

            // 判定騙りをするエージェントを取得(推測)
            AgentStatistics statistics   = (AgentStatistics)args.Items["AgentStatistics"];
            List <Agent>    liarSeerList = new List <Agent>();

            foreach (Agent agent in seerList)
            {
                int roleEveCnt  = statistics.statistics[agent].eventCount[Role.SEER].GetOrDefault("1d_DevineWhite", 0);
                int roleEveCnt2 = statistics.statistics[agent].eventCount[Role.SEER].GetOrDefault("1d_DevineBlack", 0);

                if (roleEveCnt + roleEveCnt2 >= 5 && roleEveCnt2 > roleEveCnt)
                {
                    liarSeerList.Add(agent);
                }
            }

            foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
            {
                double fakeBlaskJudgeRate = 0.1;
                if (liarSeerList.Contains(judge.Agent))
                {
                    fakeBlaskJudgeRate = 3.0 / 4.0 * 2.0 / 3.0;
                }

                // 村陣営が人間に人狼判定
                if (judge.Result == Species.WEREWOLF)
                {
                    BitCondition con = new BitCondition();
                    con.AddNotWerewolfTeam(judge.Agent);
                    con.AddNotWerewolf(judge.Target);
                    guessList.Add(new PartGuess()
                    {
                        Condition   = con,
                        Correlation = fakeBlaskJudgeRate,
                    });
                }

                // 村陣営が人狼に人間判定
                if (judge.Result == Species.HUMAN)
                {
                    BitCondition con = new BitCondition();
                    con.AddNotWerewolfTeam(judge.Agent);
                    con.AddWerewolf(judge.Target);
                    guessList.Add(new PartGuess()
                    {
                        Condition   = con,
                        Correlation = 0.1,
                    });
                }
            }

            // COから村騙りが無い場合の内訳を絞り込む
            List <Agent> coAgent = args.Agi.GetComingOutAgent(Role.SEER);

            if (coAgent.Count >= 2)
            {
                BitMatchNumCondition con = new BitMatchNumCondition()
                {
                    MinNum = 0,
                    MaxNum = coAgent.Count - 2
                };
                foreach (Agent agent in coAgent)
                {
                    con.AddWerewolfTeam(agent);
                }
                guessList.Add(new PartGuess()
                {
                    Condition   = con,
                    Correlation = 0.1,
                });
            }

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

            // 初日は行わない
            if (args.Agi.Day < 1)
            {
                return;
            }

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

            List <Agent> estAgentList = new List <Agent>();

            foreach (ExtTalk talk in args.Agi.DayInfo[1].TalkList)
            {
                if (talk.Content.Operator == Operator.NOP && talk.Content.Topic == Topic.ESTIMATE)
                {
                    if (!estAgentList.Contains(talk.Agent))
                    {
                        estAgentList.Add(talk.Agent);
                    }
                }
            }

            foreach (Agent agent in estAgentList)
            {
                if (statistics.statistics[agent].roleCount[Role.VILLAGER] >= 5)
                {
                    int vilEveCnt = statistics.statistics[agent].eventCount[Role.VILLAGER].GetOrDefault("1d_Estimate", 0);

                    if (statistics.statistics[agent].roleCount[Role.WEREWOLF] >= 5)
                    {
                        int roleEveCnt = statistics.statistics[agent].eventCount[Role.WEREWOLF].GetOrDefault("1d_Estimate", 0);

                        if (roleEveCnt == 0 && vilEveCnt >= 5)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(agent, Role.WEREWOLF),
                                Correlation = 0.7
                            });
                        }
                    }

                    if (statistics.statistics[agent].roleCount[Role.POSSESSED] >= 3)
                    {
                        int roleEveCnt = statistics.statistics[agent].eventCount[Role.POSSESSED].GetOrDefault("1d_Estimate", 0);

                        if (roleEveCnt == 0 && vilEveCnt >= 5)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(agent, Role.POSSESSED),
                                Correlation = 0.7
                            });
                        }
                    }
                }
            }

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

            // 初日1発言目は行わない
            if (args.Agi.Day < 1 && args.Agi.TodayInfo.TalkList.Count == 0)
            {
                return;
            }

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


            foreach (ExtTalk talk in args.Agi.DayInfo[1].TalkList)
            {
                if (talk.Content.Operator == Operator.NOP)
                {
                    switch (talk.Content.Topic)
                    {
                    case Topic.Over:
                        break;

                    case Topic.Skip:
                        if (talk.Turn == 0 && args.Agi.GetComingOutRole(talk.Agent) == Role.UNC)
                        {
                            // チーム いろいろ
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                Correlation = 0.9
                            });
                        }
                        if (talk.Turn == 1)
                        {
                            // チーム いろいろ
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                Correlation = 1.2
                            });
                        }
                        if (talk.Turn == 2)
                        {
                            // チーム いろいろ
                            guessList.Add(new PartGuess()
                            {
                                Condition   = TeamCondition.GetCondition(talk.Agent, Team.WEREWOLF),
                                Correlation = 1.2
                            });
                        }
                        break;

                    case Topic.VOTE:
                        if (talk.Turn == 1)
                        {
                            // チーム いろいろ
                            if (args.Agi.GetComingOutRole(talk.Agent) == Role.UNC)
                            {
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                    Correlation = 0.98
                                });
                            }
                        }
                        break;

                    case Topic.ESTIMATE:
                        if (talk.Turn == 0)
                        {
                        }
                        break;

                    case Topic.COMINGOUT:
                        break;

                    case Topic.DIVINED:
                    case Topic.IDENTIFIED:
                    case Topic.GUARDED:
                        if (talk.Turn == 0)
                        {
                            // チーム WordWolf
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                Correlation = 1.2
                            });
                        }
                        break;

                    case Topic.AGREE:
                        if (seerList.Contains(talk.Agent))
                        {
                            if (talk.Turn == 1 || talk.Turn == 2)
                            {
                                // チーム TRKO Serval
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = TeamCondition.GetCondition(talk.Agent, Team.WEREWOLF),
                                    Correlation = 1.3
                                });
                            }
                        }
                        else
                        {
                            if (talk.Turn == 0)
                            {
                                // チーム いろいろ
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = TeamCondition.GetCondition(talk.Agent, Team.WEREWOLF),
                                    Correlation = 1.1
                                });
                            }
                        }

                        break;

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

            if (args.Agi.Day >= 2)
            {
                foreach (ExtTalk talk in args.Agi.DayInfo[2].TalkList)
                {
                    if (talk.Content.Operator == Operator.NOP)
                    {
                        switch (talk.Content.Topic)
                        {
                        case Topic.Over:
                            break;

                        case Topic.Skip:
                            break;

                        case Topic.VOTE:
                            if (talk.Turn == 1)
                            {
                                // チーム いろいろ
                                Role coRole = args.Agi.GetComingOutRole(talk.Agent);
                                if (coRole == Role.UNC)
                                {
                                    guessList.Add(new PartGuess()
                                    {
                                        Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                        Correlation = 1.1
                                    });
                                }
                            }
                            break;

                        case Topic.ESTIMATE:
                            // チーム cndl
                            if (talk.Turn == 0 && talk.Content.Role.GetTeam() == Team.VILLAGER)
                            {
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = RoleCondition.GetCondition(talk.Agent, Role.POSSESSED),
                                    Correlation = 1.2
                                });
                            }
                            break;

                        case Topic.COMINGOUT:
                            break;

                        case Topic.DIVINED:
                        case Topic.IDENTIFIED:
                        case Topic.GUARDED:
                            break;

                        default:
                            break;
                        }
                        if (talk.Turn == 0 && seerList.Contains(talk.Agent) && talk.Content.Topic != Topic.DIVINED)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = TeamCondition.GetCondition(talk.Agent, Team.WEREWOLF),
                                Correlation = 1.5
                            });
                        }
                    }
                    if (talk.Content.Operator == Operator.REQUEST)
                    {
                    }
                }
            }

            List <Agent> bodyguardList = args.Agi.GetComingOutAgent(Role.BODYGUARD);

            foreach (Agent agent in bodyguardList)
            {
                guessList.Add(new PartGuess()
                {
                    Condition   = TeamCondition.GetCondition(agent, Team.WEREWOLF),
                    Correlation = 0.95
                });
            }

            List <Agent> villagerList = args.Agi.GetComingOutAgent(Role.VILLAGER);

            foreach (Agent agent in villagerList)
            {
                guessList.Add(new PartGuess()
                {
                    Condition   = TeamCondition.GetCondition(agent, Team.WEREWOLF),
                    Correlation = 1.2
                });
            }


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

            // 初日は行わない
            if (args.Agi.Day < 1)
            {
                return;
            }

            // 1日目2発言未満では行わない
            if (args.Agi.Day == 1 && args.Agi.TodayInfo.TalkList.Count < args.Agi.AliveAgentList.Count * 2)
            {
                return;
            }

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


            foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
            {
                if (judge.JudgeTalk.Day == 1)
                {
                    Agent agent = judge.Agent;

                    string eventCode1       = "";
                    string eventCode2       = "";
                    double posBaseEventRate = 0.0;  // この率より頻度が大きければ人外濃厚と見る
                    double posBigRate       = 0.0;  // ↑で設定する人外度
                    switch (judge.Result)
                    {
                    case Species.HUMAN:
                        eventCode1       = "1d_DevineWhite";
                        eventCode2       = "1d_DevineBlack";
                        posBaseEventRate = 1.00;
                        posBigRate       = 1.06;
                        break;

                    case Species.WEREWOLF:
                        eventCode1       = "1d_DevineBlack";
                        eventCode2       = "1d_DevineWhite";
                        posBaseEventRate = 0.66;
                        posBigRate       = 1.3;
                        break;

                    default:
                        continue;
                    }

                    if (statistics.statistics[agent].roleCount[Role.POSSESSED] >= 3)
                    {
                        int roleCnt    = statistics.statistics[agent].roleCount[Role.POSSESSED];
                        int roleEveCnt = statistics.statistics[agent].eventCount[Role.POSSESSED].GetOrDefault(eventCode1, 0);

                        if (roleEveCnt >= roleCnt * posBaseEventRate)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(agent, Role.POSSESSED),
                                Correlation = posBigRate
                            });
                        }
                        if (roleEveCnt <= 0)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(agent, Role.POSSESSED),
                                Correlation = 0.7
                            });
                        }
                    }
                    if (statistics.statistics[agent].roleCount[Role.WEREWOLF] >= 3)
                    {
                        int roleCnt     = statistics.statistics[agent].roleCount[Role.WEREWOLF];
                        int roleEveCnt  = statistics.statistics[agent].eventCount[Role.WEREWOLF].GetOrDefault(eventCode1, 0);
                        int roleEveCnt2 = statistics.statistics[agent].eventCount[Role.WEREWOLF].GetOrDefault(eventCode2, 0);

                        if (roleEveCnt > (roleEveCnt + roleEveCnt2) * 0.66)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(agent, Role.WEREWOLF),
                                Correlation = 2.0
                            });
                        }
                        if (roleEveCnt2 >= 5 && roleEveCnt <= 0)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(agent, Role.WEREWOLF),
                                Correlation = 0.7
                            });
                        }
                    }
                }
            }

            // 実行成功にする
            isSuccess = true;
        }
Ejemplo n.º 26
0
        public List <PartGuess> getGuessFromEvent(String eventCode, GameSetting gameSetting)
        {
            // 推理リスト
            List <PartGuess> guesses = new List <PartGuess>();

            double wolfRate = 1.0;
            double posRate  = 1.0;

            // 村人をプレイ済の場合のみ計算を行う(村人の理由はなんとなく)
            if (roleCount.GetOrDefault(Role.VILLAGER, 0) > 0)
            {
                int allEventCount = 0;
                foreach (Role role in Enum.GetValues(typeof(Role)))
                {
                    allEventCount += eventCount[role].GetOrDefault(eventCode, 0);
                }

                // イベントが一定回数以上発生している場合のみ計算可能
                if (allEventCount >= 2)
                {
                    // 狼をプレイ済の場合のみ計算を行う
                    if (roleCount.GetOrDefault(Role.WEREWOLF, 0) > 0)
                    {
                        int wolfEventCount = eventCount[Role.WEREWOLF].GetOrDefault(eventCode, 0);

                        double eventWolfRate            = (double)wolfEventCount / allEventCount;
                        double measurementCountWolfRate = (double)roleCount[Role.WEREWOLF] / gameCount;
                        //double theoreticalCountWolfRate = (double)gameSetting.GetRoleNum(Role.WEREWOLF) / gameSetting.PlayerNum;

                        wolfRate = eventWolfRate / measurementCountWolfRate;

                        if (wolfRate < 0.99 || wolfRate > 1.01)
                        {
                            double weight = Math.Min(gameCount * 0.02, 0.5);

                            RoleCondition wolfCondition = RoleCondition.GetCondition(agent, Role.WEREWOLF);
                            PartGuess     guess         = new PartGuess();
                            guess.Condition   = wolfCondition;
                            guess.Correlation = Math.Pow(Math.Max(wolfRate, 0.3), weight);
                            guesses.Add(guess);
                        }
                    }

                    // 狂をプレイ済の場合のみ計算を行う
                    if (roleCount.GetOrDefault(Role.POSSESSED, 0) > 0)
                    {
                        int posEventCount = eventCount[Role.POSSESSED].GetOrDefault(eventCode, 0);

                        double eventPosRate            = (double)posEventCount / allEventCount;
                        double measurementCountPosRate = (double)roleCount[Role.POSSESSED] / gameCount;
                        //double theoreticalCountPosRate = (double)gameSetting.GetRoleNum(Role.POSSESSED) / gameSetting.PlayerNum;

                        posRate = eventPosRate / measurementCountPosRate;

                        if (posRate < 0.99 || posRate > 1.01)
                        {
                            double weight = Math.Min(gameCount * 0.02, 0.5);

                            RoleCondition posCondition = RoleCondition.GetCondition(agent, Role.POSSESSED);
                            PartGuess     guess        = new PartGuess();
                            guess.Condition   = posCondition;
                            guess.Correlation = Math.Pow(Math.Max(posRate, 0.3), weight);
                            guesses.Add(guess);
                        }
                    }
                }
            }

            return(guesses);
        }
Ejemplo n.º 27
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.º 28
0
        /// <summary>
        /// 日付変更時(昼の開始時)の処理
        /// </summary>
        private void DayStart(GameInfo gameInfo)
        {
            // 昨日の情報を更新
            YesterdayInfo = TodayInfo;
            if (YesterdayInfo != null && YesterdayInfo.Day != 0 && YesterdayInfo.Day + 1 == gameInfo.Day)
            {
                TodayInfo.UpdateFromTomorrow(gameInfo);
            }

            // 日の情報を作成
            TodayInfo = new DayInfo(gameInfo);
            DayInfo.Add(gameInfo.Day, TodayInfo);

            // 死体で発見されたエージェントが人狼のパターンを削除する
            foreach (Agent agent in gameInfo.LastDeadAgentList)
            {
                ICondition condition = RoleCondition.GetCondition(agent, Role.WEREWOLF);
                AllViewSystemInfo.RemoveMatchPattern(condition);
            }

            //TODO 飽和が早い配役対応 (15人村→4日目から)(5人村→1狼のため必要無し)
            // 人狼生存人数がおかしいパターンを削除する
            int maxWolfNum = (gameInfo.AliveAgentList.Count - 1) / 2;

            maxWolfNum = Math.Min(maxWolfNum, GameSetting.RoleNumMap[Role.WEREWOLF]);
            if (gameInfo.Day > GameSetting.RoleNumMap[Role.WEREWOLF])
            {
                BitMatchNumCondition condition = new BitMatchNumCondition()
                {
                    MinNum = 1, MaxNum = maxWolfNum,
                };
                foreach (Agent agent in gameInfo.AliveAgentList)
                {
                    condition.AddWerewolf(agent);
                }
                AllViewSystemInfo.RemoveNotMatchPattern(condition);
            }

            // 自分の占い判定の追加
            if (gameInfo.DivineResult != null)
            {
                MySeerJudge.Add(gameInfo.DivineResult);
            }

            // 自分の霊媒判定の追加
            if (gameInfo.MediumResult != null)
            {
                MyMediumJudge.Add(gameInfo.MediumResult);
            }

            // 自分の護衛履歴の追加
            if (gameInfo.GuardedAgent != null)
            {
                MyGuardHistory.Add(gameInfo.Day - 1, gameInfo.GuardedAgent);
            }

            // 護衛成功からのパターン削除
            if (gameInfo.GuardedAgent != null && gameInfo.LastDeadAgentList.Count <= 0)
            {
                BitCondition condition = new BitCondition();
                condition.AddWerewolf(gameInfo.GuardedAgent);

                AllViewSystemInfo.RemoveMatchPattern(condition);
            }


            talkOffset = 0;

            // debug

            /*
             * Console.Write(gameInfo.Day + "日目 : ");
             * Console.Write(SelfViewSystemInfo.MonsterSidePattern.Count);
             * Console.Write(" / ");
             * Console.Write(AllViewSystemInfo.MonsterSidePattern.Count);
             * Console.WriteLine("");
             */
        }
Ejemplo n.º 29
0
        public void Update(GuessStrategyArgs args)
        {
            // 実行結果のクリア
            isSuccess = false;
            guessList.Clear();

            // 初日1発言目は行わない
            if (args.Agi.Day < 1 && args.Agi.TodayInfo.TalkList.Count == 0)
            {
                return;
            }

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


            foreach (ExtTalk talk in args.Agi.DayInfo[1].TalkList)
            {
                if (talk.Content.Operator == Operator.NOP)
                {
                    switch (talk.Content.Topic)
                    {
                    case Topic.Over:
                        if (talk.Turn == 0)
                        {
                            // チーム TRKOkami Serval
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                Correlation = 0.98
                            });
                        }
                        break;

                    case Topic.Skip:
                        if (talk.Turn == 0)
                        {
                            // チーム WordWolf WolfKing
                            guessList.Add(new PartGuess()
                            {
                                Condition   = TeamCondition.GetCondition(talk.Agent, Team.WEREWOLF),
                                Correlation = 1.02
                            });
                        }
                        break;

                    case Topic.VOTE:
                        if (talk.Turn == 0)
                        {
                            // チーム Litt1eGirl
                            if (seerList.Contains(talk.Agent))
                            {
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = TeamCondition.GetCondition(talk.Agent, Team.WEREWOLF),
                                    Correlation = 0.95
                                });
                            }
                        }
                        break;

                    case Topic.ESTIMATE:
                        if (talk.Turn == 0)
                        {
                            // チーム wasabi
                            if (talk.Content.Role.GetTeam() == Team.VILLAGER)
                            {
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                    Correlation = 1.2
                                });
                            }
                        }
                        break;

                    case Topic.COMINGOUT:
                        // チーム hh
                        if (talk.Content.Role == Role.VILLAGER)
                        {
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                Correlation = 1.2
                            });
                        }
                        break;

                    case Topic.DIVINED:
                    case Topic.IDENTIFIED:
                    case Topic.GUARDED:
                        if (talk.Turn == 0)
                        {
                            // チーム WordWolf
                            guessList.Add(new PartGuess()
                            {
                                Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                                Correlation = 1.2
                            });
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (talk.Content.Operator == Operator.REQUEST)
                {
                    // チーム wasabi
                    if (talk.Content.Role.GetTeam() == Team.VILLAGER)
                    {
                        guessList.Add(new PartGuess()
                        {
                            Condition   = RoleCondition.GetCondition(talk.Agent, Role.WEREWOLF),
                            Correlation = 0.95
                        });
                    }
                }
            }

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

            // 初日は行わない
            if (args.Agi.Day < 1)
            {
                return;
            }

            // 1日目0発言では行わない
            if (args.Agi.Day == 1 && args.Agi.TodayInfo.TalkList.Count == 0)
            {
                return;
            }

            // 初手黒は狂人寄り
            if (args.Agi.GameSetting.PlayerNum == 15)
            {
                foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge.Where(judge => judge.JudgeTalk.Day == 1 && judge.Result == Species.WEREWOLF))
                {
                    guessList.Add(new PartGuess()
                    {
                        Condition   = RoleCondition.GetCondition(judge.Agent, Role.POSSESSED),
                        Correlation = 1.25
                    });
                }
            }

            // 身内切り・誤爆を薄く見る
            foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
            {
                BitCondition con = new BitCondition();
                con.AddWerewolf(judge.Agent);
                con.AddWerewolf(judge.Target);
                guessList.Add(new PartGuess()
                {
                    Condition   = con,
                    Correlation = 0.6
                });

                con = new BitCondition();
                con.AddPossessed(judge.Agent);
                con.AddWerewolf(judge.Target);
                guessList.Add(new PartGuess()
                {
                    Condition   = con,
                    Correlation = 0.8
                });
            }

            // ●打ち先が占霊CO、占COに●打ち
            List <Agent> seerList = args.Agi.GetComingOutAgent(Role.SEER);

            foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
            {
                if (judge.Result == Species.WEREWOLF)
                {
                    foreach (ComingOut co in args.Agi.ComingOut)
                    {
                        if (judge.Target.Equals(co.Agent) && (co.Role == Role.SEER || co.Role == Role.MEDIUM))
                        {
                            if (judge.JudgeTalk.Day * 10000 + judge.JudgeTalk.Turn < co.ComingOutTalk.Day * 10000 + co.ComingOutTalk.Turn)
                            {
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = RoleCondition.GetCondition(judge.Target, Role.WEREWOLF),
                                    Correlation = 1.5
                                });
                            }

                            if (judge.JudgeTalk.Day == 1 && seerList.Count == 2 &&
                                judge.JudgeTalk.Day * 10000 + judge.JudgeTalk.Turn > co.ComingOutTalk.Day * 10000 + co.ComingOutTalk.Turn)
                            {
                                guessList.Add(new PartGuess()
                                {
                                    Condition   = TeamCondition.GetCondition(judge.Agent, Team.WEREWOLF),
                                    Correlation = 1.1
                                });
                            }
                        }
                    }
                }
            }


            // 噛まれた占いの結果を真で見る
            List <Agent> attackedSeer = new List <Agent>();

            foreach (DayInfo dayInfo in args.Agi.DayInfo.Values)
            {
                if (dayInfo.AttackDeadAgent != null && dayInfo.AttackDeadAgent.Count >= 1)
                {
                    if (seerList.Contains(dayInfo.AttackDeadAgent[0]))
                    {
                        attackedSeer.Add(dayInfo.AttackDeadAgent[0]);
                    }
                }
            }
            foreach (KeyValuePair <int, Agent> kv in args.Agi.MyGuardHistory)
            {
                if (args.Agi.DayInfo[kv.Key].AttackDeadAgent != null && args.Agi.DayInfo[kv.Key].AttackDeadAgent.Count <= 0)
                {
                    attackedSeer.Add(kv.Value);
                }
            }
            foreach (Wepwawet.Lib.Judge judge in args.Agi.SeerJudge)
            {
                if (attackedSeer.Contains(judge.Agent))
                {
                    guessList.Add(new PartGuess()
                    {
                        Condition   = RoleCondition.GetCondition(judge.Target, Role.WEREWOLF),
                        Correlation = (judge.Result == Species.WEREWOLF) ? 2.0 : 0.5
                    });
                }
            }

            // 判定数が合わない人を偽で見る(暫定対応で多い場合のみ)
            foreach (Agent agent in seerList)
            {
                int count = args.Agi.SeerJudge.Where(judge => judge.Agent.Equals(agent)).Count();
                if (count > args.Agi.Day)
                {
                    guessList.Add(new PartGuess()
                    {
                        Condition   = TeamCondition.GetCondition(agent, Team.WEREWOLF),
                        Correlation = 4.0
                    });
                }
            }
            List <Agent> mediumList = args.Agi.GetComingOutAgent(Role.MEDIUM);

            foreach (Agent agent in mediumList)
            {
                int count = args.Agi.MediumJudge.Where(judge => judge.Agent.Equals(agent)).Count();
                if (count > args.Agi.Day)
                {
                    guessList.Add(new PartGuess()
                    {
                        Condition   = TeamCondition.GetCondition(agent, Team.WEREWOLF),
                        Correlation = 4.0
                    });
                }
            }


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