// Playe command string private static string PlayerCommand(Bot bot) { string playerCmd = string.Empty; string ext = bot.BotFileInfo().Extension; foreach (BotExtension be in botExtensions) { string beExt = be.BotExt(); string beCmd = be.BotCommandLine(); if (beExt == ext) { if (!string.IsNullOrEmpty(beCmd)) { playerCmd = "\"" + beCmd + " \\\"" + bot.BotFileInfo().FullName + "\\\"\""; } else { playerCmd = "\"" + bot.BotFileInfo().FullName + "\""; } break; } } return playerCmd; }
// 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; }