writing robot in Jython?

2009-08-18
2012-09-15
  • Jurgis Pralgauskis

    Hello,
    I'm a fan of python syntax,
    as it is quite easier than java (especially for beginners).

    I tried the method proposed in http://thread.gmane.org/gmane.comp.java.robocode/760
    it compiles, but then doesn't get accepted into robot database :/

    I found interfaces (for creating robot types ... with other programming languages)
    http://robocode.sourceforge.net/docs/robocode/robocode/robotinterfaces/package-summary.html
    but without tutorial I have insufficient competence/time to understand, how.. :/

    There is some tutorial combining Jython with Java apps,
    http://jythonpodcast.hostjava.net/jythonbook/chapter10.html
    but it creates java class'es from jython runtime, not compiletime.

    maybe this could be hacked into controller when robots are added to battle,
    but this is again is too much for me :/

     
    • Jurgis Pralgauskis

      Ok, finally I can use python for http://robocode.sf.net
      with the help of <jinq0123.at.163.com> I managed to run it on ubuntu 8.04 and 9.04.

      • install jython2.2 (not 2.5)

      • install robocode (1.7 was better for me than 1.6 in one aspect )

      • write yourbot.py and put it in robots directory
        there are several types of robots, for example
        http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
        when writing jython version, don't forget "self" keywords defining your own methods or calling Robot methods ;)

      • edit compyle-jy221.sh to your needs
        (on win some path syntax canges are needed and name compile-jy221.bat)

      • it adds robocode.jar to shell classpath before compilation to java
      • and compiles using jythonc (indicating robot filename and package name)

      • find the new .java and .class files

      • make the appropriate .property file for your bot (not compulsory)

      • call robocode-jython.sh (adds: 1) NoSecurity option and 2) jython.jar in classpath )

      ftp://ftp.akl.lt/users/jurgis/robocode/jython-OK/
      copy files to your robocode directory

      ps.: with robocode 1.6 I had to restart the robocode before each battle,
      or otherwise jython bot's didn't work..
      1.7 didn't have this problem

      ps.: still haven't tried to implement more complex robot actions...
      just cloned MyFirstRobot and Wall
      by the way, JymboWall acts a bit strangely -- when figuring its direction,
      it usually is not perpendicular to walls :/

       
    • Pavel Šavara

      Pavel Šavara - 2009-08-18

      Hi Jurgis,

      Please see my answer to simillar question here.
      http://groups.google.com/group/robocode-developers/browse_thread/thread/351485511ccc6457?hl=en

      We are looking for someone strong enough to help us with that.

      Cheers Pavel

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks