0

I'm attempting to use JESS in order to utilise a rule-based system for making a robot. I've got both robocode and the JESS .jar imported into Eclipse. Here's my code -

public class myRobot extends Robot {
    Rete r = new Rete();

    public void run() {
        try {
            String reset = "(reset)"; 
            r.executeCommand(reset); 
            String enemyInfo = "(deftemplate enemyInfo (slot present) (slot energy) (slot name))";
            r.executeCommand(enemyInfo);

            while (true) {
                String command = "(assert (enemyInfo (present no) (energy -1) (name none)))";
                r.executeCommand(command);
            }

        } catch (JessException ex) {
            System.err.println(ex);
        }
    }

    public void onScannedRobot(ScannedRobotEvent e) {
        try {
            String command = "(assert (enemyInfo (present yes) (energy " + e.getEnergy() + ") (name " + e.getName() + ")))";
            r.executeCommand(command); 
        } catch (JessException ex) {
            System.err.println(ex);
        }
    }
}

I haven't added in any rules yet because I just wanted to check that robocode and JESS run properly together. When I fire this up, the robocode application opens up. But when I try adding this robot in a battle and starting it, the application just freezes up completely.

I can't access the robot's console to see what's wrong since it hangs just immediately after I try and start a battle. Since all my System.out.println() debugging statements are printed to the robot's console as opposed to the main one, I can't even figure out what's wrong. Any suggestions to get this to work?

Juliano Alves
  • 2,006
  • 4
  • 35
  • 37

1 Answers1

0

The problem is, that the robocode application does not know the JESS library. You will need to include it in the jar of your exported robot.

How to include librarys to jars

Community
  • 1
  • 1
Philipp Sander
  • 10,139
  • 6
  • 45
  • 78