public void Update(GuessStrategyArgs args) { foreach (IGuessNode node in Child) { node.Update(args); } }
public void Update(GuessStrategyArgs args) { // 実行結果のクリア isSuccess = false; guessList.Clear(); // 初日は実行失敗 if (args.Agi.Day <= 1) { return; } DayInfo dayInfo = args.Agi.DayInfo[1]; foreach (ExtTalk talk in dayInfo.TalkList) { if (talk.Content.Operator == Operator.NOP && talk.Content.Topic == Topic.ESTIMATE && talk.Content.Role == Role.WEREWOLF) { BitCondition con = new BitCondition(); con.AddWerewolf(talk.Agent); con.AddWerewolf(talk.Content.Target); guessList.Add(new PartGuess() { Condition = con, Correlation = 0.95, }); } } // 実行成功にする isSuccess = true; }
/// <summary> /// 推理を行う /// </summary> protected virtual void Guess() { GuessStrategyArgs args = new GuessStrategyArgs { Agi = agi }; LatestGuess = new GuessResultExt(hasGuessStrategy, args); }
/// <summary> /// 推理を行う /// </summary> protected virtual void Guess() { GuessStrategyArgs args = new GuessStrategyArgs { Agi = Agi }; LatestGuess = GuessManager.Exec(args); }
/// <summary> /// 推理を行う /// </summary> protected override void Guess() { GuessStrategyArgs args = new GuessStrategyArgs { Agi = Agi }; args.Items.Add("AgentStatistics", statistics); LatestGuess = GuessManager.Exec(args); }
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; }
/// <summary> /// コンストラクタ /// </summary> /// <param name="partGuess">保有戦略毎の推理結果</param> /// <param name="args">推理戦略の引数</param> public GuessResultExt(List <HasGuessStrategy> guessStrategy, GuessStrategyArgs args) { // 各推理戦略から推理結果を取得 PartGuess = new Dictionary <HasGuessStrategy, List <PartGuess> >(); foreach (HasGuessStrategy strategy in guessStrategy) { PartGuess.Add(strategy, strategy.Strategy?.GetGuess(args)); } // 集計を行う Calc(args); }
public GuessResult Exec(GuessStrategyArgs args, Viewpoint vp) { // 推理戦略の更新処理 GuessStrategy.Update(args); // 戦略から部分内訳に対する推理リストを取得 List <PartGuess> guessList = GuessStrategy.IsSuccess() ? GuessStrategy.GetGuess() : new List <PartGuess>(); // 推理結果の集計を取得 GuessResult result = GetResult(args, guessList, vp); return(result); }
public void Update(GuessStrategyArgs args) { // 実行結果のクリア guessList.Clear(); foreach (DayInfo dayInfo in args.Agi.DayInfo.Values) { // その日の投票の取得 VoteAnalyzer voteAnalyzer = null; if (dayInfo.VoteList.Count > 0) { // 実際の投票(1回目の投票のみ) voteAnalyzer = new VoteAnalyzer(dayInfo.VoteList[0]); } else if (dayInfo.Equals(args.Agi.TodayInfo)) { // 投票宣言 voteAnalyzer = new VoteAnalyzer(dayInfo.LatestAliveAgentList, dayInfo.TalkList, Topic.VOTE); } if (voteAnalyzer != null) { foreach (KeyValuePair <Agent, Agent> vote in voteAnalyzer.VoteMap) { if (vote.Value != null) { BitCondition con = new BitCondition(); con.AddWerewolf(vote.Key); con.AddWerewolf(vote.Value); guessList.Add(new PartGuess() { Condition = con, Correlation = 0.7, }); con = new BitCondition(); con.AddNotWerewolf(vote.Key); con.AddNotWerewolf(vote.Value); guessList.Add(new PartGuess() { Condition = con, Correlation = 0.95, }); } } } } // 実行成功にする isSuccess = true; }
public void Update(GuessStrategyArgs args) { if (guessList.Count == 0) { Random r = new System.Random(); guessList = new List <PartGuess>(); foreach (Agent agent in args.Agi.AgentList) { guessList.Add(new PartGuess() { Condition = TeamCondition.GetCondition(agent, Team.WEREWOLF), Correlation = 0.95 + r.NextDouble() * 0.1 }); } } }
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; }
public GuessResult Exec(GuessStrategyArgs args) { // 推理戦略の更新処理 GuessStrategy.Update(args); // 戦略から部分内訳に対する推理リストを取得 List <PartGuess> guessList = GuessStrategy.IsSuccess() ? GuessStrategy.GetGuess() : new List <PartGuess>(); // 推理する視点 Viewpoint vp = args.Agi.SelfViewTrustInfo; if (args.Agi.SelfViewTrustInfo.MonsterSidePattern.Count <= 0) { vp = args.Agi.SelfViewSystemInfo; } // 推理結果の集計を取得 GuessResult result = GetResult(args, guessList, vp); return(result); }
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); }
public void Update(GuessStrategyArgs args) { // 実行結果のクリア guessList.Clear(); // 仲間狼の人外スコアを下げる foreach (KeyValuePair <Agent, Role> keyValue in args.Agi.RoleMap) { if (keyValue.Value == Role.WEREWOLF) { guessList.Add(new PartGuess() { Condition = TeamCondition.GetCondition(keyValue.Key, Team.WEREWOLF), Correlation = 0.8 }); } } // 実行成功にする isSuccess = true; }
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; }
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; }
/// <summary> /// 集計を行う /// </summary> /// <param name="args">推理戦略の引数</param> private void Calc(GuessStrategyArgs args) { // 各内訳にスコアを付ける AllPattern = new List <AggregateGuess>(); foreach (MonsterSidePattern pattern in args.Agi.SelfViewSystemInfo.MonsterSidePattern) { AggregateGuess gpattern = new AggregateGuess(pattern); AllPattern.Add(gpattern); // 各推理が内訳条件を満たせばスコアを適用する foreach (HasGuessStrategy strategy in PartGuess.Keys) { foreach (PartGuess guess in PartGuess[strategy]) { if (guess.Condition.IsMatch(pattern)) { gpattern.Score *= guess.Correlation; Math.Pow(guess.Correlation, strategy.Weight); } } } } // 各集計を行う foreach (AggregateGuess gpattern in AllPattern) { // 個人毎の最も村陣営・人狼・狂人・妖狐スコアの大きい内訳を集計する foreach (Agent agent in args.Agi.LatestGameInfo.AgentList) { if (gpattern.Pattern.IsExist(agent, Role.WEREWOLF)) { if (!LikelyWolfPattern.ContainsKey(agent) || gpattern.Score > LikelyWolfPattern[agent].Score) { LikelyWolfPattern[agent] = gpattern; } } else if (gpattern.Pattern.IsExist(agent, Role.POSSESSED)) { if (!LikelyPossessedPattern.ContainsKey(agent) || gpattern.Score > LikelyPossessedPattern[agent].Score) { LikelyPossessedPattern[agent] = gpattern; } } else if (gpattern.Pattern.IsExist(agent, Role.FOX)) { if (!LikelyFoxPattern.ContainsKey(agent) || gpattern.Score > LikelyFoxPattern[agent].Score) { LikelyFoxPattern[agent] = gpattern; } } else { if (!LikelyVillagerPattern.ContainsKey(agent) || gpattern.Score > LikelyVillagerPattern[agent].Score) { LikelyVillagerPattern[agent] = gpattern; } } } // 最もスコアの大きい内訳を集計する if (LikelyPattern == null || gpattern.Score > LikelyPattern.Score) { LikelyPattern = gpattern; } } }
/// <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 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; }
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; }
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; }
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; }
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; }
public void Update(GuessStrategyArgs args) { // 実行結果のクリア guessList.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); // 占い師が全偽のパターン if (seerList.Count > 0) { BitCondition con = new BitCondition(); foreach (Agent agent in seerList) { con.AddWerewolfTeam(agent); } guessList.Add(new PartGuess() { Condition = con, Correlation = 0.2, }); } // 5人村-狂人が騙っていないパターン if (args.Agi.AgentList.Count == 5 && seerList.Count > 0) { BitCondition con = new BitCondition(); foreach (Agent agent in seerList) { con.AddNotPossessed(agent); } guessList.Add(new PartGuess() { Condition = con, Correlation = 0.3, }); } // 15人村-狂人が騙っていないパターン if (args.Agi.AgentList.Count == 15 && seerList.Count + mediumList.Count >= 4) { BitCondition con = new BitCondition(); foreach (Agent agent in seerList) { con.AddNotPossessed(agent); } foreach (Agent agent in mediumList) { con.AddNotPossessed(agent); } guessList.Add(new PartGuess() { Condition = con, Correlation = 0.3, }); } // 霊媒師が全偽のパターン if (mediumList.Count > 0) { BitCondition con = new BitCondition(); foreach (Agent agent in mediumList) { con.AddWerewolfTeam(agent); } guessList.Add(new PartGuess() { Condition = con, Correlation = 0.1, }); } // 実行成功にする isSuccess = true; }
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; }
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; }