Exemplo n.º 1
0
 public BotFight(int fightId, Map fightMap, Bot player1, Bot player2, int turnAmount, int timeAmount, FileInfo log, FileInfo result, FileInfo viewerInput, int status, string command)
 {
     this.fightId = fightId;
     this.fightMap = fightMap;
     this.player1 = player1;
     this.player2 = player2;
     this.turnAmount = turnAmount;
     this.timeAmount = timeAmount;
     this.log = log;
     this.result = result;
     this.viewerInput = viewerInput;
     this.status = status;
     this.command = command;
 }
Exemplo n.º 2
0
 public BotFight(int fightId, Map fightMap, Bot player1, Bot player2, int turnAmount, int timeAmount)
 {
     this.fightId = fightId;
     this.fightMap = fightMap;
     this.player1 = player1;
     this.player2 = player2;
     this.turnAmount = turnAmount;
     this.timeAmount = timeAmount;
     this.log = null ;
     this.result = null;
     this.viewerInput = null;
     this.status = 0;
     this.command = string.Empty;
 }
Exemplo n.º 3
0
        // Test fights
        private bool TestFightsPrepare()
        {
            bool prepareFlag = true;
            string logsPath = Application.StartupPath + "/logs";
            string resultsPath = Application.StartupPath + "/results";
            string viewerInputPath = Application.StartupPath + "/viewer_inputs";
            if (!Directory.Exists(logsPath))
                Directory.CreateDirectory(logsPath);
            if (!Directory.Exists(resultsPath))
                Directory.CreateDirectory(resultsPath);
            if (!Directory.Exists(viewerInputPath))
                Directory.CreateDirectory(viewerInputPath);

            //Prepare fight
            myBot = new Bot(0, (FileInfo)cmbChooseMyBot.SelectedItem, true);
            int botId = 1;
            List<Bot> opponentBots = new List<Bot>();
            if (cmbChooseOpponentBot.SelectedIndex == 0)
            {
                for (int i = 1; i < cmbChooseOpponentBot.Items.Count; i++)
                {
                    FileInfo fi = (FileInfo)cmbChooseOpponentBot.Items[i];
                    //if ((cbExampleBots.Checked) && (fi.DirectoryName == (starterPackagePath + "\\example_bots")))
                    //if ((cbExampleBots.Checked) && (fi.DirectoryName == (Path.GetFullPath(Path.Combine(starterPackagePath, "example_bots")))))
                    if ((cbExampleBots.Checked) && (fi.DirectoryName == Path.GetFullPath(exampleBotsPath)))
                    {
                        Bot opponentBot = new Bot(botId, fi);
                        opponentBots.Add(opponentBot);
                        botId++;
                    }

                    //if ((cbOtherMyBots.Checked) && (fi.DirectoryName == myBotsPath))
                    if ((cbOtherMyBots.Checked) && (fi.DirectoryName == Path.GetFullPath(myBotsPath)))
                    {
                        if ((cbMirror.Checked) || ((!cbMirror.Checked) && (fi.Name != myBot.BotFileInfo().Name)))
                        {
                            Bot opponentBot = new Bot(botId, fi);
                            opponentBots.Add(opponentBot);
                            botId++;
                        }
                    }
                }
            }
            else
            {
                Bot opponentBot = new Bot(botId, (FileInfo)cmbChooseOpponentBot.SelectedItem);
                opponentBots.Add(opponentBot);
            }

            List<Map> maps = new List<Map>();
            int mapId = 0;
            if (cmbMap.SelectedIndex == 0)
            {
                for (int i = 1; i < cmbMap.Items.Count; i++)
                {
                    FileInfo fi = (FileInfo)cmbMap.Items[i];
                    Map map = new Map(mapId, fi);
                    maps.Add(map);
                    mapId++;
                }
            }
            else
            {
                Map map = new Map(mapId, (FileInfo)cmbMap.SelectedItem);
                maps.Add(map);
            }

            //Fights
            if ((opponentBots.Count > 0) && (maps.Count > 0))
            {
                botFights = new List<BotFight>();
                int fightId = 1;
                for (int i = 0; i < opponentBots.Count; i++)
                {
                    for (int j = 0; j < maps.Count; j++)
                    {
                        BotFight botFight = new BotFight(fightId, maps[j], myBot, opponentBots[i], turnAmount, timeAmount);
                        botFights.Add(botFight);
                        fightId++;
                        if (cbSwapPlayers.Checked)
                        {
                            BotFight botFight2 = new BotFight(fightId, maps[j], opponentBots[i], myBot, turnAmount, timeAmount);
                            botFights.Add(botFight2);
                            fightId++;
                        }
                    }
                }
            }
            else
            {
                errorString = string.Empty;
                if (opponentBots.Count == 0)
                    errorString += "There no opponent bots in your current fight settings\n";

                if (maps.Count == 0)
                    errorString += "There no maps in your current fight settings.\n";
                prepareFlag = false;
                MessageBox.Show(errorString, "Fight Settings warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return prepareFlag;
        }
Exemplo n.º 4
0
 public void FightMap(Map newFightMap)
 {
     this.fightMap = newFightMap;
 }