Commit 72cd7d4b authored by Adam Štěpánek's avatar Adam Štěpánek
Browse files

Add even more plots

parent aafc2348
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@ namespace Adam.SecretHitler
            ImmutableRandom random,
            IEnumerable<(Role role, IStrategy strategy)> players,
            int fascistPolicyCount = 11,
            int liberalPolicyCount = 6)
            int liberalPolicyCount = 6,
            int peopleVoteTrackerValue = 3)
        {
            if (players.Count() != 7 && players.Count() != 8
                || players.Count(p => p.role == Role.Fascist) != 2
@@ -31,7 +32,8 @@ namespace Adam.SecretHitler
                LastElectedPresident = Player.None,
                LastElectedChancellor = Player.None,
                Dead = Enumerable.Repeat(false, players.Count()).ToImmutableArray(),
                LastRound = RoundSummary.Initial
                LastRound = RoundSummary.Initial,
                PeopleVoteTrackerValue = peopleVoteTrackerValue
            };

            var statePlayers = players.ToArray();
@@ -80,7 +82,9 @@ namespace Adam.SecretHitler
            }
        }

        public static (EndCondition end, GameState finalState, int roundCount) PlayGame(GameState state, bool verbose = false)
        public static (EndCondition end, GameState finalState, int roundCount) PlayGame(
            GameState state,
            bool verbose = false)
        {
            if (verbose)
            {
@@ -213,7 +217,7 @@ namespace Adam.SecretHitler
            {
                round.ElectionTracker++;
                round.Stage = RoundStage.End;
                if (round.ElectionTracker > 2)
                if (round.ElectionTracker >= state.Public.PeopleVoteTrackerValue)
                {
                    // vote failed and people are MAD
                    VotePeople(ref round);
@@ -273,7 +277,7 @@ namespace Adam.SecretHitler
                round.IsVetoed = true;
                round.ElectionTracker++;

                if (round.ElectionTracker > 2)
                if (round.ElectionTracker >= state.Public.PeopleVoteTrackerValue)
                {
                    VotePeople(ref round);
                    return;
+48 −2
Original line number Diff line number Diff line
@@ -141,6 +141,31 @@ namespace Adam.SecretHitler
            }
        }

        public static void RunTracker(
            AvailableStrategy[] strategies,
            int iterations,
            string cfrInput,
            int max)
        {
            PrintRequirements(strategies);
            Console.WriteLine("PeopleVoteTrackerValue,FascistPolicies,LiberalPolicies,"
                + "HitlerElected,HitlerExecuted,RoundCountSum");
            for (int t = 1; t <= max; ++t)
            {
                var (stats, roundCount) = PlayGames(strategies, iterations, cfrInput, peopleVoteTrackerValue: t);
                var fields = new long[]
                {
                    t,
                    stats[EndCondition.FascistPolicies],
                    stats[EndCondition.LiberalPolicies],
                    stats[EndCondition.HitlerElected],
                    stats[EndCondition.HitlerExecuted],
                    roundCount
                };
                Console.WriteLine(string.Join(',', fields));
            }
        }

        public static int Main(string[] args)
        {
            var root = new RootCommand("Secret Hitler In a Terminal")
@@ -176,6 +201,25 @@ namespace Adam.SecretHitler
            policiesCmd.Handler = CommandHandler.Create<AvailableStrategy[], int, string>(RunPolicies);
            root.AddCommand(policiesCmd);

            var trackerCmd = new Command("tracker", "Run games with all different length of the election tracker")
            {
                new Argument<AvailableStrategy[]>("STRATEGIES")
                {
                    Arity = new ArgumentArity(7, 8)
                },
                new Option<int>(
                    aliases: new string[] {"-i", "--iterations"},
                    getDefaultValue: () => 1000000),
                new Option<string>(
                    aliases: new string[] {"-cfr", "--cfrInput"},
                    getDefaultValue: () => CfrStrategyPath),
                new Option<int>(
                    aliases: new string[] {"--max"},
                    getDefaultValue: () => 12)
            };
            trackerCmd.Handler = CommandHandler.Create<AvailableStrategy[], int, string, int>(RunTracker);
            root.AddCommand(trackerCmd);

            var debugCmd = new Command("debug", "Run a single, very verbose game")
            {
                new Argument<AvailableStrategy[]>("STRATEGIES")
@@ -264,7 +308,8 @@ namespace Adam.SecretHitler
            int iterations,
            string cfrInput,
            int fascistPolicyCount = 11,
            int liberalPolicyCount = 6)
            int liberalPolicyCount = 6,
            int peopleVoteTrackerValue = 3)
        {
            var stats = new Dictionary<EndCondition, int>
            {
@@ -281,7 +326,8 @@ namespace Adam.SecretHitler
                    ImmutableRandom.Create(GlobalRandom),
                    players,
                    fascistPolicyCount,
                    liberalPolicyCount);
                    liberalPolicyCount,
                    peopleVoteTrackerValue);
                var (winner, _, roundCount) = Game.PlayGame(state);
                roundCountSum += roundCount;
                stats[winner]++;
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ namespace Adam.SecretHitler
        public Player LastElectedChancellor;
        public ImmutableArray<bool> Dead;
        public int ElectionTracker;
        public int PeopleVoteTrackerValue;
        public RoundSummary LastRound;
    }
}
+96 −18

File changed.

Preview size limit exceeded, changes collapsed.

+13 −0
Original line number Diff line number Diff line
PeopleVoteTrackerValue,FascistPolicies,LiberalPolicies,HitlerElected,HitlerExecuted,RoundCountSum
1,568631,276206,126051,29112,8503987
2,576306,300319,104366,19009,13435374
3,590989,290055,106154,12802,17831725
4,594999,285323,108894,10784,22093428
5,598287,281527,110120,10066,26041271
6,599233,279702,111271,9794,29991919
7,599028,279605,111377,9990,33742052
8,598448,281940,110388,9224,38409713
9,598794,281515,110611,9080,42193400
10,599770,280719,110663,8848,46058890
11,599838,280285,111061,8816,49838656
12,599684,280350,110907,9059,53669124
Loading