// Status Condition Methods public bool AddStatusCondition(TeamCondition condition) { if (!HasStatusCondition(condition.statusID)) { bProps.conditions.Add(condition); return(true); } return(false); }
// Clone public static TeamCondition Clone(TeamCondition original) { TeamCondition cloneAilment = new TeamCondition( statusID: original.statusID, turnsActive: original.turnsActive, turnsLeft: original.turnsLeft ); return(cloneAilment); }
public void team条件_単一エージェント狼狂_1() { Viewpoint viewpoint = new Viewpoint(gameSetting15, gameInfo15); TeamCondition con = TeamCondition.GetCondition(Agent.GetAgent(1), Team.WEREWOLF); viewpoint.RemoveMatchPattern(con); Assert.AreEqual(viewpoint.MonsterSidePattern.Count, 4004); }
private void AddNewSubCondition() { var newCondition = new TeamCondition() { ParentCondition = Condition }; Condition.Subconditions.Add(newCondition); RedrawCondition(); Condition.CallConditionChanged(); listBoxSubConditions.SelectedItem = null; new FormEditTeamCondition(Team, newCondition).ShowDialog(); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="gameInfo"></param> /// <param name="gameSetting"></param> public AdvanceGameInfo(GameInfo gameInfo, GameSetting gameSetting) { // ゲーム設定を保管 GameSetting = gameSetting; // 全視点情報・自分視点情報の初期化 AllViewSystemInfo = new Viewpoint(GameSetting); SelfViewSystemInfo = AllViewSystemInfo.AddInclusionViewpoint(); // 自分視点から自分が人外の内訳を削除する ICondition condition = TeamCondition.GetCondition(gameInfo.Agent, Team.VILLAGER); SelfViewSystemInfo.RemoveNotMatchPattern(condition); }
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) { // 実行結果のクリア 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; }
// Clone public static BattleTeamProperties Clone(BattleTeamProperties original) { BattleTeamProperties clone = new BattleTeamProperties(); for (int i = 0; i < original.entryHazards.Count; i++) { clone.entryHazards.Add(EntryHazard.Clone(original.entryHazards[i])); } clone.GMaxWildfireStatus = (original.GMaxWildfireStatus == null) ? null : original.GMaxWildfireStatus.Clone(); for (int i = 0; i < original.lightScreens.Count; i++) { clone.lightScreens.Add(TeamCondition.Clone(original.lightScreens[i])); } for (int i = 0; i < original.matBlocks.Count; i++) { clone.matBlocks.Add(original.matBlocks[i].Clone()); } for (int i = 0; i < original.reflectScreens.Count; i++) { clone.reflectScreens.Add(ReflectScreen.Clone(original.reflectScreens[i])); } for (int i = 0; i < original.safeguards.Count; i++) { clone.safeguards.Add(Safeguard.Clone(original.safeguards[i])); } clone.protectMovesActive = new List <string>(original.protectMovesActive); for (int i = 0; i < original.conditions.Count; i++) { clone.conditions.Add(TeamCondition.Clone(original.conditions[i])); } return(clone); }
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(); // 初日は行わない 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 FormEditTeamCondition(Team teamData, TeamCondition data) { Team = teamData; Condition = data; InitializeComponent(); ChangeFormText(); Icon = Properties.Resources.AppIcon; if (Condition != null) { textBoxConditionDescription.Text = Condition.Description; textBoxLimiterValue.Text = Condition.LimiterValue.ToString(); switch (Condition.Limiter) { case TeamLimiter.OR: radioButtonLimiterOR.Checked = true; textBoxLimiterValue.Enabled = false; textBoxAccountNames.Enabled = false; groupBoxAccountNames.Visible = false; groupBoxSubConditions.Visible = true; break; case TeamLimiter.AND: radioButtonLimiterAND.Checked = true; textBoxLimiterValue.Enabled = false; textBoxAccountNames.Enabled = false; groupBoxAccountNames.Visible = false; groupBoxSubConditions.Visible = true; break; case TeamLimiter.CommanderName: radioButtonLimiterCommanderName.Checked = true; textBoxLimiterValue.Enabled = false; textBoxAccountNames.Enabled = true; groupBoxAccountNames.Visible = true; groupBoxSubConditions.Visible = false; break; case TeamLimiter.Except: radioButtonLimiterExcept.Checked = true; textBoxLimiterValue.Enabled = false; textBoxAccountNames.Enabled = true; groupBoxAccountNames.Visible = true; groupBoxSubConditions.Visible = false; break; case TeamLimiter.Exact: radioButtonLimiterExact.Checked = true; textBoxLimiterValue.Enabled = true; textBoxAccountNames.Enabled = true; groupBoxAccountNames.Visible = true; groupBoxSubConditions.Visible = false; break; default: radioButtonLimiterAtLeast.Checked = true; textBoxLimiterValue.Enabled = true; textBoxAccountNames.Enabled = true; groupBoxAccountNames.Visible = true; groupBoxSubConditions.Visible = false; break; } textBoxAccountNames.Text = ((Condition.AccountNames?.Count ?? 0) > 0) ? Condition.AccountNames.Aggregate((x, y) => $"{x}{Environment.NewLine}{y}") : string.Empty; textBoxConditionVisual.Text = Condition.Draw(); } radioButtonLimiterOR.CheckedChanged += new EventHandler(RadioButtonLimiterOR_CheckedChanged); radioButtonLimiterAND.CheckedChanged += new EventHandler(RadioButtonLimiterAND_CheckedChanged); radioButtonLimiterCommanderName.CheckedChanged += new EventHandler(RadioButtonLimiterCommanderName_CheckedChanged); radioButtonLimiterExcept.CheckedChanged += new EventHandler(RadioButtonLimiterExcept_CheckedChanged); radioButtonLimiterExact.CheckedChanged += new EventHandler(RadioButtonLimiterExact_CheckedChanged); radioButtonLimiterAtLeast.CheckedChanged += new EventHandler(RadioButtonLimiterAtLeast_CheckedChanged); textBoxAccountNames.TextChanged += new EventHandler(TextBoxAccountNames_TextChanged); Condition.ConditionChanged += HandleConditionChange; }
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; }
/// <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); }