Hello, I am new in Robocode. I'm using the .NET api Robocode. I changed the location of the Robocode .net api installation directory. When I run the battle runner the following exception: Can not load java class for robocode.control.events.BattleEvent from ClassLoader sun.misc.Launcher$AppClassLoader@c387f44.
using System;
using Robocode;
using Robocode.Control;
using Robocode.Control.Events;
class BattleRunner
{
static void Main(string[] args)
{
// Create the RobocodeEngine
RobocodeEngine engine = new RobocodeEngine("C:\\Users\\auditorio\\Desktop\\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();
}
// Called when the battle is completed successfully with battle results
private static void BattleCompleted(BattleCompletedEvent e)
{
Console.WriteLine("-- Battle has completed --");
// Print out the sorted results with the robot names
Console.WriteLine("Battle results:");
foreach (BattleResults result in e.SortedResults)
{
Console.WriteLine(" " + result.TeamLeaderName + ": " + result.Score);
}
}
// Called when the game sends out an information message during the battle
private static void BattleMessage(BattleMessageEvent e)
{
Console.WriteLine("Msg> " + e.Message);
}
// Called when the game sends out an error message during the battle
private static void BattleError(BattleErrorEvent e)
{
Console.WriteLine("Err> " + e.Error);
}
}