From: C. P. B. <cpo...@ho...> - 2001-09-11 15:48:47
|
I have been trying to get jython working with a game called robocode, http://robocode.alphaworks.ibm.com/home/home.html The basic idea is that you write a class that inherits from a base class. You write a run function for the default actions, as well as functions such as onScannedRobot that process messages. These virtual robots get put in an arena and try to destroy each other. I have *no* java experience, so I decided to try to get this working with jython. First of all, here's a very simple .java robot: package porter; import robocode.*; public class CPB extends Robot { public void run() while(true) ahead(100); turnGunRight(360); back(100); turnGunRight(360); } } public void onScannedRobot(ScannedRobotEvent e) { fire(1); } } I have no idea what the package porter; line is for, so I ignored it. I added the robocode.jar to my classpath, and tried to translate this java code to python. Here's my python file: from robocode import * class pyrobot(Robot): def run(self): while(1): ahead(100) turnGunRight(360) back(100) turnGunRight(360) def onScannedRobot(self, event): fire(1) I ran that through jythonc, and it compiled, but I got a depracation warning. I recompiled with -deprecation, and here's the output from jythonc: 0932:PWORK://d/robocode/robots/porter$ jythonc pyrobot.py processing pyrobot Required packages: robocode.dialog robocode.jdk13bugfix robocode.editor robocode* Creating adapters: Creating .java files: pyrobot module pyrobot extends robocode.Robot Compiling .java to .class... Compiling with args: ['c://jdk1.3.1_01/bin/javac.exe', '-deprecation', '-classpath', 'C:\\jython-2.0\\jython.jar;.;C:\\Program Files\\proe2000i2\\modchk\\java\\xml\\xml4j.jar;c:\\jython-2.0\\jython.jar;d :\\robocode\\robocode.jar;.\\jpywork;;C:\\jython-2.0\\Tools\\jythonc;d:\\rob ocode\\robots\\porter\\.;C:\\jython-2.0\\Lib;c:\\jython\\lib;C:\\jython-2.0' , '.\\jpywork\\pyrobot.java'] 0 .\jpywork\pyrobot.java:100: warning: jfindattr(org.python.core.PyProxy,java.lang.String) in org.python.core.Py has been deprecated PyObject inst = Py.jfindattr(this, "onScannedRobot"); ^ .\jpywork\pyrobot.java:110: warning: jfindattr(org.python.core.PyProxy,java.lang.String) in org.python.core.Py has been deprecated PyObject inst = Py.jfindattr(this, "run"); ^ 2 warnings When I try to run a robocode battle with this robot, the robocode console gives me the following error: java.lang.NoClassDefFoundError: porter/jpywork/pyrobot (wrong name: pyrobot) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at robocode.JBotsClassLoader.loadRobotClass(JBotsClassLoader.java:55) at robocode.Battle.initialize(Battle.java:350) at robocode.Battle.run(Battle.java:42) at java.lang.Thread.run(Unknown Source) Because of my utter lack of java knowledge, I am completely stuck. Is it even possible to do what I am trying to do? If so, what should I try next? -------------------------------------------------------------------------- C. Porter Bassett cporter at byu dot edu www.et.byu.edu/~porter odigo #: 3854128 ICQ #:38435505 AIM ID: cporterbassett -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- |