static void Main(string[] args) { // Create the RobocodeEngine RobocodeEngine engine = new RobocodeEngine("C:\\robocode"); // Run from C:\Robocode // Add battle event handlers engine.BattleCompleted += new BattleCompletedEventHandler(BattleCompleted); engine.BattleMessage += new BattleMessageEventHandler(BattleMessage); engine.BattleError += new BattleErrorEventHandler(BattleError); // Show the Robocode battle view engine.Visible = true; // Disable log messages from Robocode RobocodeEngine.LogMessagesEnabled = false; // Setup the battle specification int numberOfRounds = 5; BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600 RobotSpecification[] selectedRobots = engine.GetLocalRepository("sample.RamFire,sample.Corners"); BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots); // Run our specified battle and let it run till it is over engine.RunBattle(battleSpec, true /* wait till the battle is over */); // Cleanup our RobocodeEngine engine.Close(); }
public BattleRunner(String roboPath = @"C:\robocode") { _engine = new RobocodeEngine(roboPath); // Show the Robocode battle view _engine.Visible = true; int numberOfRounds = 5; BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600 RobotSpecification[] selectedRobots = _engine.GetLocalRepository("sample.RamFire,sample.Corners"); BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots); // Run our specified battle and let it run till it is over _engine.RunBattle(battleSpec, true /* wait till the battle is over */); // Cleanup our RobocodeEngine _engine.Close(); }