Пример #1
0
        public void VisualizeAll()
        {
            Directory.CreateDirectory("kingdomsIntermediate/");
            Directory.CreateDirectory("kingdomsFinal/");
            List <string> directories = new List <string>(Directory.EnumerateDirectories("kingdomsIntermediate/"));

            foreach (var dir in directories)
            {
                List <string> leaderboardFiles = new List <string>(Directory.EnumerateFiles(dir + "/leaderboard", "*.txt"));
                foreach (var f in leaderboardFiles)
                {
                    if (f.EndsWith(".txt") && !File.Exists(f.Replace(".txt", ".png")))
                    {
                        DominionVisualization vis = new DominionVisualization(database, f, f.Replace(".txt", ".png"));
                    }
                }

                List <string> progressionFiles = new List <string>(Directory.EnumerateFiles(dir + "/progression", "*.txt"));
                foreach (var f in progressionFiles)
                {
                    if (f.EndsWith(".txt") && !File.Exists(f.Replace(".txt", ".png")))
                    {
                        DominionVisualization vis = new DominionVisualization(database, f, f.Replace(".txt", ".png"));
                    }
                }
            }

            VisualizeFinal();
        }
Пример #2
0
        public void VisualizeFinal()
        {
            Directory.CreateDirectory("kingdomsIntermediate/");
            Directory.CreateDirectory("kingdomsFinal/");
            List <string> directories = new List <string>(Directory.EnumerateDirectories("kingdomsIntermediate/"));

            foreach (var dir in directories)
            {
                string dirOnly = dir.Replace("kingdomsIntermediate/", "");

                string finalLeaderboard       = Utility.FindLargestIndexInDirectory(dir + "/leaderboard");
                string leaderboardVisFilename = finalLeaderboard.Replace(".txt", ".png");
                if (finalLeaderboard.Length > 0 && !File.Exists(finalLeaderboard.Replace(".txt", ".png")))
                {
                    DominionVisualization vis = new DominionVisualization(database, finalLeaderboard, leaderboardVisFilename);
                }
                Utility.SafeFileCopy(leaderboardVisFilename, "kingdomsFinal/" + dirOnly + "_l.png");
                Utility.SafeFileCopy(finalLeaderboard, "kingdomsFinal/" + dirOnly + ".txt");

                string finalProgression       = Utility.FindLargestIndexInDirectory(dir + "/progression");
                string progressionVisFilename = finalProgression.Replace(".txt", ".png");
                if (finalProgression.Length > 0 && !File.Exists(finalProgression.Replace(".txt", ".png")))
                {
                    DominionVisualization vis = new DominionVisualization(database, finalProgression, progressionVisFilename);
                }
                Utility.SafeFileCopy(progressionVisFilename, "kingdomsFinal/" + dirOnly + "_p.png");
            }
        }
Пример #3
0
        private void buttonLoadAndVisualize_Click(object sender, EventArgs e)
        {
            string file = Utility.FindLargestIndexInDirectory(activeTournamentDirectory);

            if (file.Length > 0)
            {
                LoadAIFile(file);
                string visFile            = file.Replace(".txt", ".png");
                DominionVisualization vis = new DominionVisualization(parentWindow.database, file, visFile);
                if (File.Exists(visFile))
                {
                    Process.Start(visFile);
                }
            }
        }
Пример #4
0
        private void timerCheckProgress_Tick(object sender, EventArgs e)
        {
            if (activeTournamentDirectory.Length == 0)
            {
                return;
            }

            string file = Utility.FindLargestIndexInDirectory(activeTournamentDirectory);

            if (file.Length == 0)
            {
                labelLeaderboard.Text = "Tournament in progress...";
                return;
            }

            int fileIndex;

            try
            {
                fileIndex = Convert.ToInt32(file.Replace(activeTournamentDirectory, "").Replace(".txt", ""));
            }
            catch
            {
                return;
            }

            if (fileIndex == activeTournamentGenerationCount)
            {
                labelLeaderboard.Text      = "Tournament completed.";
                timerCheckProgress.Enabled = false;
                string visFile            = file.Replace(".txt", ".png");
                DominionVisualization vis = new DominionVisualization(parentWindow.database, file, visFile);
                if (File.Exists(visFile))
                {
                    Process.Start(visFile);
                }
            }
            else
            {
                labelLeaderboard.Text = "Leaderboard for generation " + fileIndex.ToString() + " completed.";
            }
            buttonLoadAndVisualize.Enabled = true;
        }
Пример #5
0
        private void buttonShowLeaderboard_Click(object sender, EventArgs e)
        {
            if (visualizationFilename.Length == 0)
            {
                MessageBox.Show("This button shows the visualization corresponding to an AI file created by the \"Run Tournament\" button and loaded using the \"Load AI File\" button." +
                                "  Start by running a tournament and using the \"Load AI File\" button to load a text file in the \"leaderboard\" or \"progression\" folders.");
                return;
            }

            DominionVisualization vis = new DominionVisualization(parentWindow.database, visualizationFilename.Replace(".png", ".txt"), visualizationFilename);

            if (File.Exists(visualizationFilename))
            {
                Process.Start(visualizationFilename);
            }
            else
            {
                MessageBox.Show("The corresponding strategy visualization for " + visualizationFilename + " does not exist.  Use the \"Visualize All\" button to " +
                                "generate visualization files for leaderboard and progression AI files.");
            }
        }
Пример #6
0
        private void timerCheckProgress_Tick(object sender, EventArgs e)
        {
            if(activeTournamentDirectory.Length == 0) return;

            string file = Utility.FindLargestIndexInDirectory(activeTournamentDirectory);
            if (file.Length == 0)
            {
                labelLeaderboard.Text = "Tournament in progress...";
                return;
            }

            int fileIndex;
            try
            {
                fileIndex = Convert.ToInt32(file.Replace(activeTournamentDirectory, "").Replace(".txt",""));
            }
            catch
            {
                return;
            }

            if (fileIndex == activeTournamentGenerationCount)
            {
                labelLeaderboard.Text = "Tournament completed.";
                timerCheckProgress.Enabled = false;
                string visFile = file.Replace(".txt", ".png");
                DominionVisualization vis = new DominionVisualization(parentWindow.database, file, visFile);
                if (File.Exists(visFile))
                {
                    Process.Start(visFile);
                }
            }
            else
            {
                labelLeaderboard.Text = "Leaderboard for generation " + fileIndex.ToString() + " completed.";
            }
            buttonLoadAndVisualize.Enabled = true;
        }
Пример #7
0
        private void buttonShowLeaderboard_Click(object sender, EventArgs e)
        {
            if (visualizationFilename.Length == 0)
            {
                MessageBox.Show("This button shows the visualization corresponding to an AI file created by the \"Run Tournament\" button and loaded using the \"Load AI File\" button." +
                                "  Start by running a tournament and using the \"Load AI File\" button to load a text file in the \"leaderboard\" or \"progression\" folders.");
                return;
            }

            DominionVisualization vis = new DominionVisualization(parentWindow.database, visualizationFilename.Replace(".png", ".txt"), visualizationFilename);
            if (File.Exists(visualizationFilename))
            {
                Process.Start(visualizationFilename);
            }
            else
            {
                MessageBox.Show("The corresponding strategy visualization for " + visualizationFilename + " does not exist.  Use the \"Visualize All\" button to " +
                                "generate visualization files for leaderboard and progression AI files.");
            }
        }
Пример #8
0
 private void buttonLoadAndVisualize_Click(object sender, EventArgs e)
 {
     string file = Utility.FindLargestIndexInDirectory(activeTournamentDirectory);
     if (file.Length > 0)
     {
         LoadAIFile(file);
         string visFile = file.Replace(".txt", ".png");
         DominionVisualization vis = new DominionVisualization(parentWindow.database, file, visFile);
         if (File.Exists(visFile))
         {
             Process.Start(visFile);
         }
     }
 }
Пример #9
0
        public void VisualizeFinal()
        {
            Directory.CreateDirectory("kingdomsIntermediate/");
            Directory.CreateDirectory("kingdomsFinal/");
            List<string> directories = new List<string>(Directory.EnumerateDirectories("kingdomsIntermediate/"));

            foreach (var dir in directories)
            {
                string dirOnly = dir.Replace("kingdomsIntermediate/", "");

                string finalLeaderboard = Utility.FindLargestIndexInDirectory(dir + "/leaderboard");
                string leaderboardVisFilename = finalLeaderboard.Replace(".txt", ".png");
                if (finalLeaderboard.Length > 0 && !File.Exists(finalLeaderboard.Replace(".txt", ".png")))
                {
                    DominionVisualization vis = new DominionVisualization(database, finalLeaderboard, leaderboardVisFilename);
                }
                Utility.SafeFileCopy(leaderboardVisFilename, "kingdomsFinal/" + dirOnly + "_l.png");
                Utility.SafeFileCopy(finalLeaderboard, "kingdomsFinal/" + dirOnly + ".txt");

                string finalProgression = Utility.FindLargestIndexInDirectory(dir + "/progression");
                string progressionVisFilename = finalProgression.Replace(".txt", ".png");
                if (finalProgression.Length > 0 && !File.Exists(finalProgression.Replace(".txt", ".png")))
                {
                    DominionVisualization vis = new DominionVisualization(database, finalProgression, progressionVisFilename);
                }
                Utility.SafeFileCopy(progressionVisFilename, "kingdomsFinal/" + dirOnly + "_p.png");
            }
        }
Пример #10
0
        public void VisualizeAll()
        {
            Directory.CreateDirectory("kingdomsIntermediate/");
            Directory.CreateDirectory("kingdomsFinal/");
            List<string> directories = new List<string>(Directory.EnumerateDirectories("kingdomsIntermediate/"));

            foreach (var dir in directories)
            {
                List<string> leaderboardFiles = new List<string>(Directory.EnumerateFiles(dir + "/leaderboard", "*.txt"));
                foreach (var f in leaderboardFiles)
                {
                    if (f.EndsWith(".txt") && !File.Exists(f.Replace(".txt", ".png")))
                    {
                        DominionVisualization vis = new DominionVisualization(database, f, f.Replace(".txt", ".png"));
                    }
                }

                List<string> progressionFiles = new List<string>(Directory.EnumerateFiles(dir + "/progression", "*.txt"));
                foreach (var f in progressionFiles)
                {
                    if (f.EndsWith(".txt") && !File.Exists(f.Replace(".txt", ".png")))
                    {
                        DominionVisualization vis = new DominionVisualization(database, f, f.Replace(".txt", ".png"));
                    }
                }
            }

            VisualizeFinal();
        }
Пример #11
0
        private void buttonCompareAIs_Click(object sender, EventArgs e)
        {
            String parameters = AIString();

            if (parameters.Contains("Human"))
            {
                MessageBox.Show("Humans are not valid test subjects.", "Error");
                return;
            }

            DLLInterface.ProcessCommand("testAIs@" + parameters);
            parentWindow.InitializeSupply();
            parentWindow.UpdateAllState();

            labelSampleGameInfo.Visible = true;
            labelSampleGameInfo.Text    = "The main window contains a sample game between the two AIs.";

            double result = DLLInterface.GetDouble("AITestResult");

            labelResult.Text = "Player 1 wins " + result.ToString("P").Replace(" %", "%") + " of games for a spread of " + DominionVisualization.FormatPercentage((result * 100.0 - 50.0) * 2.0) + ".";
        }