private void Runbattle(Battle battle) { string[] players = new string[2]; players[0] = battle.Team1.Application; players[1] = battle.Team2.Application; Referee referee = new Referee(players); referee.Seed = battle.Seed; referee.PlayGame(null); battle.Replay = referee.GetFrames(); Frame frame = battle.Replay.LastOrDefault(); if (frame != null) { battle.Score1 = frame.Players[0].Score; battle.Score2 = frame.Players[1].Score; if (battle.Score1 == battle.Score2) { battle.Points1 = 1; battle.Points2 = 1; } else if (battle.Score1 > battle.Score2) { battle.Points2 = 0; if (battle.Score2 == 0) { battle.Points1 = 3; } else { battle.Points1 = 2; } } else { battle.Points1 = 0; if (battle.Score1 == 0) { battle.Points2 = 3; } else { battle.Points2 = 2; } } } }
static void Main(string[] args) { string applicationName = "ConsoleApplication1"; string filePath = $".\\{applicationName}.exe"; //Settings.Seed = 0; //Settings.FactoryCount = 5; //Settings.InitalUnitcount = 30; Settings.Timeout = 1000; // unlimitid Referee referee = new Referee(new string[] { filePath, filePath }); referee.PlayGame(null); List <Frame> frames = referee.GetFrames(); }
private void button1_Click(object sender, EventArgs e) { _outputEvents = new ConcurrentQueue <ConsoleOutputEventArgs>(); string filePath = textBox1.Text; if (!File.Exists(filePath)) { MessageBox.Show("Player program not found"); return; } string opponentAI = ConfigurationManager.AppSettings[$"AI{cbLevel.SelectedIndex}"]; if (!File.Exists(opponentAI)) { MessageBox.Show("Oponent program not found"); return; } string[] playerNames = new string[2]; string[] players = new string[2]; if (rbtnBlue.Checked) { players[0] = filePath; playerNames[0] = "User application"; players[1] = opponentAI; playerNames[1] = "Boss program"; } else { players[1] = filePath; playerNames[1] = "User application"; players[0] = opponentAI; playerNames[0] = "Boss program"; } int index = Leage.SelectedIndex; if (index == 2) { index = 3; } HackathonWork.Settings.SetLeageLevel(index); Referee referee = new Referee(players); int seed; if (int.TryParse(SeedTb.Text, out seed)) { referee.Seed = seed; } DebugBreak debugMethod = null; if (chbxDebug.Checked) { HackathonWork.Settings.UseTimeOut = false; debugMethod = this.Debug; } else { HackathonWork.Settings.UseTimeOut = true; } try { if (rbtnBlue.Checked) { referee.ConsoleErrorOutputPlayer1 += ConsoleErrorOutputPlayer; } else { referee.ConsoleErrorOutputPlayer2 += ConsoleErrorOutputPlayer; } referee.ConsoleOutputPlayer += ConsoleErrorOutputPlayer; referee.PlayGame(debugMethod); } catch (Exception ex) { // who throw the exception? } _frames = referee.GetFrames(); MatchData md = new MatchData() { Frames = _frames, PlayerNames = playerNames, }; Viewer v = new Viewer(md); v.Show(); PrintConsoleOUtput(); }