How to use Clojure with Robocode

129 views
Skip to first unread message

ubolonton

unread,
Mar 19, 2010, 3:56:17 AM3/19/10
to Clojure
Hi,

Has anyone been able to use Clojure with Robocode?
I've followed this http://www.fatvat.co.uk/2009/05/clojure-and-robocode.html
but got the error

Round 1 initializing..
Let the games begin!
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
net.sf.robocode.host.security.RobotClassLoader.createRobotInstance(RobotClassLoader.java:
272)
at
net.sf.robocode.host.proxies.HostingRobotProxy.loadRobotRound(HostingRobotProxy.java:
201)
at
net.sf.robocode.host.proxies.HostingRobotProxy.run(HostingRobotProxy.java:
242)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.lang.NullPointerException
at clojure.lang.Var.setMeta(Var.java:179)
at clojure.lang.Var.internPrivate(Var.java:96)
at ubolonton.MyRobot.<clinit>(Unknown Source)
... 10 more

Thanks

Jeff Foster

unread,
Mar 19, 2010, 9:19:14 AM3/19/10
to Clojure
Could you post the source code?

On Mar 19, 7:56 am, ubolonton <ubolon...@gmail.com> wrote:
> Hi,
>
> Has anyone been able to use Clojure with Robocode?

> I've followed thishttp://www.fatvat.co.uk/2009/05/clojure-and-robocode.html

Heinz N. Gies

unread,
Mar 20, 2010, 10:46:16 AM3/20/10
to clo...@googlegroups.com

On Mar 19, 2010, at 8:56 , ubolonton wrote:

> Hi,
>
> Has anyone been able to use Clojure with Robocode?
> I've followed this http://www.fatvat.co.uk/2009/05/clojure-and-robocode.html
> but got the error

Hi,
I hope that in a week or two I am able to release a 'mini game' as a tech demo for something some friends and me are working on, if you're interested in Robocode you might like it. It will be a tournament game where two fleets fight each other. The user will be able to assemble the ships from different modules and script their AI giving them a high level of customizability. Let me know if you're interesting, I'll be offering a few beta logins on the list too :) (the game will be 100% free and open source (at least at some point), no advertising or anything).

Regards,
Heinz

ubolonton

unread,
Mar 20, 2010, 1:41:07 PM3/20/10
to Clojure
On Mar 19, 8:19 pm, Jeff Foster <dr.jeff.fos...@gmail.com> wrote:
> Could you post the source code?
This is the Clojure code

(ns ubolonton.MyRobot
(:gen-class :extends robocode.Robot))
(defn -run
[robot]
(doto robot
(.ahead 100)
(.turnGunRight 360)
(.back 100))
(.turnGunRight 360)
(recur robot))
(defn -onScannedRobot
[robot event]
(doto robot
(.fire 1)))

It should be equivalent to this Java code

public class MyRobot extends Robot
{
public void run() {
while(true) {
ahead(100);
turnGunRight(360);
back(100);
turnGunRight(360);
}
}
public void onScannedRobot(ScannedRobotEvent e) {
fire(1);
}
}

I think Robocode uses ClassLoader to create instances of Robot, which
does not work with classes generated by gen-class

ubolonton

unread,
Mar 20, 2010, 1:46:12 PM3/20/10
to Clojure

On Mar 20, 9:46 pm, "Heinz N. Gies" <he...@licenser.net> wrote:
> Hi,
> I hope that in a week or two I am able to release a 'mini game' as a tech demo for something some friends and me are working on, if you're interested in Robocode you might like it. It will be a tournament game where two fleets fight each other. The user will be able to assemble the ships from different modules and script their AI giving them a high level of customizability. Let me know if you're interesting, I'll be offering a few beta logins on the list too :) (the game will be 100% free and open source (at least at some point), no advertising or anything).

I'll be very interested if it's in Clojure :)

nakkaya

unread,
Jun 19, 2010, 10:40:44 PM6/19/10
to ubolonton, clo...@googlegroups.com
This answer is couple months too late but I was messing with robocode
this weekend, had the same problem OP had. The solution is to unzip
clojure.jar into the folder where your compiled class files are. That
makes the error go away but it will also increase robocode's boot time
by 20-30 secs.

Hope this helps...
--
Nurullah Akkaya
http://nakkaya.com

On Mar 19, 10:56 am, ubolonton <ubolon...@gmail.com> wrote:
> Hi,
>
> Has anyone been able to use Clojure with Robocode?

> I've followed thishttp://www.fatvat.co.uk/2009/05/clojure-and-robocode.html


> but got the error
>
> Round 1 initializing..
> Let the games begin!
> java.lang.ExceptionInInitializerError
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>         at

> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce ssorImpl.java:
> 39)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru ctorAccessorImpl.java:

> 27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at java.lang.Class.newInstance0(Class.java:355)
>         at java.lang.Class.newInstance(Class.java:308)
>         at

> net.sf.robocode.host.security.RobotClassLoader.createRobotInstance(RobotCla ssLoader.java:
> 272)
>         at
> net.sf.robocode.host.proxies.HostingRobotProxy.loadRobotRound(HostingRobotP roxy.java:

Reply all
Reply to author
Forward
0 new messages