Re: Invalid robot or team - Adding Robots to RobotEngine

fnl <[email protected]> Sun, 25 Mar 2018 11:51:24 -0700 (PDT)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
Hi Tom,

I have had a look and tried out your code with my own robot located in 
C:\robocode\robots.
I ran into a minor issue with your code.

You point to the installation directory of Robocode with this statement:

RobocodeEngine engine = new RobocodeEngine(new java.io.File("*MY_ROOT*"));


You have written the My_ROOT surrounded with quote characters?!
Could this be the problem with your GameConfigurer?

If not. Perhaps you could send me a zip of your project including 
everything to fnl(at)users.sourceforge.net. Then I will have a look. :-)
I am very familiar with IntellyJ (and have it installed) if that the IDE 
you are using.

Best regards,
- Flemming

Den fredag den 23. marts 2018 kl. 12.27.32 UTC+1 skrev Tom Plum:
>
> Hi,
>
> I'm trying to add my own Robots to a battle via a RobotEngine.
> This is the class, basically just the template from the docs;
>
> package controller;
>
> import robocode.control.*;
>
> public class GameConfigurer {
>     private static final int BATTLEFIELD_W = 1000;
>     private static final int BATTLEFIELD_H = 1000;
>     private static final int NO_OF_ROUNDS = 5;
>
>     public static void startBattle() {
>         //Robocode Messages & Errors
>         RobocodeEngine.setLogMessagesEnabled(true);
>         RobocodeEngine.setLogErrorsEnabled(true);
>
>         // Create the RobocodeEngine
>         RobocodeEngine engine = new RobocodeEngine(new java.io.File("*MY_ROOT*"));
>         System.out.println("Running Robocode Version: " + engine.getVersion());
>
>         //Add BattleObserver To Engine
>         engine.addBattleListener(new BattleObserver());
>
>         //Show Robocode Battle View (GUI Window)
>         engine.setVisible(true);
>
>         System.out.println("Working Dir: " + RobocodeEngine.getCurrentWorkingDir());
>         System.out.println("Robots Dir: " + RobocodeEngine.getRobotsDir());
>
>         //Setup Battle Specification
>         BattlefieldSpecification battlefield = new BattlefieldSpecification(BATTLEFIELD_W, BATTLEFIELD_H);
>         RobotSpecification[] selectedRobots = engine.getLocalRepository("sample.Crazy, sample.TwitterRobot");
>
>         BattleSpecification battleSpec = new BattleSpecification(NO_OF_ROUNDS, battlefield, selectedRobots);
>
>         //Start Battle
>         engine.runBattle(battleSpec, true); //Wait Until Battle Finished
>
>         //Clean Up Our RobocodeEngine
>         engine.close();
>
>         //Ensure JVM Is Shut-Down Properly
>         System.exit(0);
>     }
> }
>
>
> Using sample robots work fine. But with my own, a BattleErrorEvent is 
> thrown showing "Can't load 'sample.TestRobot' because it is an invalid 
> robot or team.".
>
> I've even tried copying the source code from a sample bot into my own 
> class to no avail.
>
> Opening one of the compiled .class files of a sample robot tells me it was 
> compiled with JDK 6. I'm currently on 9.0.1, could this be the issue? What 
> is the latest version that will support this?
>
> *edit*:
> I've compiled another test robot class in JDK6, and copied the .class, 
> .java and created a .properties file. All this is in the sample folder so 
> the RobocodeEngine can see it. Still no luck!
> It cannot find robots in any directory other than sample. If the robot is 
> in sample, it has to *actually* be a sample robot for to be deemed valid.
>
> Kind Regards,
> Tom
>

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.