Loading...
 

PogamutUT2004


How to bind parser?

Okay I'm using eclipse instead of netbeans so I don't have the priveledge of enjoying the sarcasm in user documentation:

"Before logic thread is started you must be sure, that you've bind a parser to the bot (well NetBeans plugin does that for you :-). Check out methods cz.cuni.Client.Agent.connectToLocalParser() / connectToRemoteParser(). "

Well I've tryed it but for some reason the agent class doesn't have the bindRemoteParser() or bindLocalParser() method implemented. Can I implement this myself and how? is it because the version I'm using is outdated or something third I didn't know?

Help much appreciated!
Just realised I've been looking at old java doc :-(. But my problem still stands: how do I control which server the bots join?
Well been trying to figure it out but still stuck. I gather I must do something with IUT2004Server or UT2004Server but the correct way of setting it up is hard to figure out as the documentation isn't clear. Again any help is much appreciated.
Hi!

Not sure if this will be an answer to your question, but if you want your bot to join particular server, just fill in UT2004BotRunner construtor string address and port. Example of EmptyBot connected to localhost at port 3000:

/**
     * This method is called when the bot is started either from IDE or from command line.
     * It connects the bot to the game server.
     * @param args
     */
    public static void main(String args[]) throws PogamutException {
        UT2004BotModule myModule = new UT2004BotModule(
                EmptyBot.class);
        
        UT2004BotFactory factory = new UT2004BotFactory(myModule);

        // TODO here you can rename your bot, the name of the class is used now
        UT2004BotRunner botRunner = new UT2004BotRunner(factory, "PogamutJavaBot", "localhost",3000);
        IAgent agent = botRunner.startAgent();

        // wait until the bot finishes and close Pogamut platform
        new WaitForAgentStateChange(agent.getState(), IAgentStateStopped.class).await();
        Pogamut.getPlatform().close();
    }


Does this answer your question?

best,
michal
What you are offering is probarbly in the right direction but for now I can't make it work. The following line crashes:

IAgent agent = botRunner.startAgent();

and I get a bunch of errors ;) but think the main one is a class not found exception.

Just to give a little detail about what I'm doing. I'm doing a thesis about creating behaviours for bots using neural networks and I'm going to have multiple bots running on multiple different servers. I hope this approach you are offering would suit those needs.
That's odd. I understood you are using Eclipse for agent running. Well it seems that some library is missing in your bot project. Check in properties/libraries which jars has your project in classpath.

Pogamut 3 needs these jars:
  • PogamutCore.jar
  • PogamutUT2004.jar
  • guice-2.0.jar
  • Introspection.jar
  • vecmath-1_5_1.jar
  • j3d-org-geom=core-0_9.jar
  • afsm.jar
  • xstream-1.3.1.jar
  • aopalliance.jar
  • guice-assistedinject-2.0.jar
  • guice-mltibindings-2.0.jar

If you checkout our repository found at Download page, all these jars will be in brachnes/devel/project/Core/Lib . You get PogamutCore.jar and PogamutUT2004.jar by building the projects Core and PogamutUT2004. If you add all these jars to your project, you should get rid of ClassDefNotFound error. Alternatively you can download and install netbeans and install there Pogamut plugin. (you can turn on eclipse key shortcuts in Tools/Options/KeyMap :-) ) In NetBeans all these jars are included in PogamutUT2004 library, that is automatically added to all pogamut bot projects.

Anyway, I'll ask our Eclipse Pogamut delevloper (Jakub) about caveat there. :-)

Next thing. In Pogamut 2 our team mate Rudolf Kadlec developed project Pogamut GRID - that was aimed on running and evolving the bots on more computers:

It is possible to refactor this project onto Pogamut 3. Honestly, I do not know how much work it will be, or if Rudolf is planning to do it. However, you can check it out, perhaps you'll find some inspiration there. I let Rudolf know, there is another Pogamut genetic programmer in the town. :-)

Best,
michal
Okay so I tryed updating to latest version of pogamut but I can only find the following jars in my lib folders:

PogamutUT2004.jar
afsm.jar
guice-2.0.jar
Introspection.jar
j3d-org-geom-core-0_9.jar
jgrapht-jdk1.5.jar
PogamutCore.jar
vecmath-1_5_1.jar
xstream-1.3.1.jar

The following is missing from mine compared to yours:

aopalliance.jar
guice-assistedinject-2.0.jar
guice-mltibindings-2.0.jar

Reason for Eclipse is very simple as Netbeans sucks up 100% cpu power because of some kind of error and I don't want to waste time setting up another IDE. Also I'll be staring at code and not the interface so the Netbeans platform doesn't offer anything usefull for me.

Genetic Bots project sounds interesting but I'm afraid I've already got my hands full ;) I'm going to interface my NEAT/rtNEAT framework with a program so I can train bot behaviours and I don't have too much time at the moment.

I'll try to see if I can get the packages from netbeans or if I can make this code work in netbeans. Don't know if it helps but here is the error code:

Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/aopalliance/intercept/MethodInterceptor;
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:78)
at com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:70)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:232)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at com.google.inject.util.Modules$RealOverriddenModuleBuilder$1.configure(Modules.java:142)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at com.google.inject.util.Modules$RealOverriddenModuleBuilder$1.configure(Modules.java:142)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at com.google.inject.util.Modules$RealOverriddenModuleBuilder$1.configure(Modules.java:142)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.AbstractModule.install(AbstractModule.java:118)
at cz.cuni.amis.pogamut.base.factory.guice.GuiceAgentModule.configure(GuiceAgentModule.java:174)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.InjectorShell$Builder.build(InjectorShell.java:135)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:102)
at com.google.inject.Guice.createInjector(Guice.java:92)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at cz.cuni.amis.pogamut.base.factory.guice.AbstractGuiceAgentFactory.getInjector(AbstractGuiceAgentFactory.java:28)
at cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotFactory.newAgent(UT2004BotFactory.java:23)
at cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotFactory.newAgent(UT2004BotFactory.java:9)
at cz.cuni.amis.pogamut.base.agent.utils.runner.impl.RemoteAgentRunner.startAgent(RemoteAgentRunner.java:63)
at bot.MainTest.main(MainTest.java:26)
Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 37 more
Tryed reinstalling netbeans and pogamut. Now netbeans doesn't crash but I can't run your code segment. Seems like the main error is: Can't start Probably game server is not running.

Which is funny as the game server has been set up and is running. I've even tryed renaming "localhost" to ut:/localhost ut:/localhost:3003 etc. and changed the final port aswell. I've set up a server with the following bat file: c:\\ut2004\system\ucc server DM-TrainingDay?game=GameBots2004.BotDeathMatch?timelimit=9999?BotServerPort=3003?ControlServerPort=3004

Again help is much appreciated as this probarbly will be one of the biggest hurdles for me to overcome ;)
Thats weird, for me I run the server with command you've sent, then run NetBeans, there - New Project, selecet EmptyBot, change the code in main method to :

public static void main(String args[]) throws PogamutException {
        UT2004BotModule myModule = new UT2004BotModule(
                EmptyBot.class);

        
        UT2004BotFactory factory = new UT2004BotFactory(myModule);

        // TODO here you can rename your bot, the name of the class is used now
        UT2004BotRunner botRunner = new UT2004BotRunner(factory, "PogamutJavaBot", "localhost",3003);
        IAgent agent = botRunner.startAgent();


        // wait until the bot finishes and close Pogamut platform
        new WaitForAgentStateChange(agent.getState(), IAgentStateStopped.class).await();
        Pogamut.getPlatform().close();
    }


and everything runs fine. Try installing new pogamut version - 3.0.5, there you can have bot running on different server with:

public static void main(String args[]) throws PogamutException {
    	new SingleUT2004BotRunner(EmptyBot.class, "EmptyBot","localhost",3003).startAgent();
    }

Maybe try "127.0.0.1" instead of localhost.
Ouch! That hurts! What you are refering to applies to Pogamut 2
(I mean that 'connectToLocalParser()'). This is OLD OLD!

Use:

public static void main(String args[]) throws PogamutException {
new SingleUT2004BotRunner(EmptyBot.class, "EmptyBot","localhost",3000).startAgent();
}

For Pogamut v3.0.5 forward.

Please - where did you dig up the Pogamut 2 documentation?

Cheers
Jakub aka Jimmy
Another thing,

if you're using Eclipse - it is probably the best to use public svn, checkout the Pogamut 3 for yourself
as we have already set up Eclipse projects inside 'Core' and 'PogamutUT2004' directory.

Would you fancy SVN - bleeding edge - version?

Cheers,
Jakub aka Jimmy
Much appreciate all the feedback. Will start from an end and test everything zealous and return with my results ;)
Be ready that the version inside repository might be unstable (more or less)... but it is getting usually better ;-)

Cheers,
Jimmy
Okay I've misunderstod which main method to use >_< we've been talking by each other ;) When I put following code segment inside the bots main method:

new SingleUT2004BotRunner(EmptyBot.class, "EmptyBot","localhost",3003).startAgent();

In Netbeans it runs. The problem is I tryed creating my own main class and putting the code segment in a main routine there. Well needless to say I fixed my problem by calling bots main from my own main routine.

Still class missing problem for Eclipse though but probarbly from missing packages. Will try to set svn up and see if that fixes the problem for eclipse.

Thanks for all the help so far, it's very much appreciated.
Yes, it is very likely that some lib is missing in your configuration :-)

Checkout:
svn://artemis.ms.mff.cuni.cz/branches/devel/project

Go into the 'project' forlder. There are plenty of dirs there. All you need is:
1) Core
2) PogamutUT2004
These two dirs are already set-uped Eclipse as well as Netbeans projects. It should suffice (under Eclipse)
to import the Core and then PogamutUT2004 ... maintain the order not to confuse the Eclipse ;-) as PogamutUT2004
links Core project.

Good luck!

Jimmy

P.S.: after you import these two projects, you may create new project that should have these two in its build path ... then you may use Pogamut freely :-)
(hopefully... if not try to add every lib these two projects have into your new project as well... usually fix all problems with libs).
Thanks jakub, that last post did the trick for eclipse ;) and thanks to michal as well for all the feedback :-)
Happy to hear it working!

Enjoy :-)

Jimmy
Okay in the same genre: When I have a main class with a main method running the bots main method the main class never gets control back like it used to do with pogamut 2 when you ran bots. Am I misunderstanding something with my bot setup or do I need to setup a thread for myself for each bot my system runs? Its just I can see in the debugger that running a bot already takes 2 threads ;) and I predict a thread hell ;)
I looked into the SingleUT2004BotRunner after reading about it here. Seemed like something I could use :-)

But I think Esben should be aware that it calls Pogamut.getPlatform().close() in the StartAgent() routine the moment the bot "goes down".
This might not be what you want, from what I understand :-)

I'm assuming that if you create multiple instances of the SingleUT2004BotRunner, connecting them all to the same server, the moment one bot quits, it spells trouble for all of them due to the platform closing?
Just looked at the Javadoc for the default platform and noticed that close() supposedly only closes the JMX connector. I'm not really sure what JMX is used for. I'm guessing it is to allow for the Netbeans plugin to get information about the servers currently running, etc? If that is the case, I suppose Esben could live with it ;)

I notice in the source that the MBeans sever is also being manhandled, although I have no idea what that is being used for.
Hi!

See javadoc for SingleUT2004BotRunner :-) ... it says you can use it for single purpose only ... run single bot inside JVM ;-)

One by one...

JMX -> yes it is used by NetBeans plugin to manage bot inside different JVM - note that the biggest feature of Pogamut 3 is the option to directly debug the bot inside NetBeans (you could not do that in Pogamut 2). Currently bots are run in different JVM than the plugin therefore we needed the way to control the bot -> JMX.

MBeans server -> yes it is man handled, blame the Sun (Oracle) company :-( ... if you start up the registry for MBean server, start the agent and then stop it and expect the JVM to exit as well ... surprise! ... The registry are still running inside deamon thread and JVM will run forever ... additionally, there is some issue with stopping the registry when some mxbean are still registered - we needed the way to unregister automatically or MBeans of the single agent. We're recording which mxbeans are being published on MBeanServer level (manhandling as you're writing).

All in all - to let JVM be closed, you must call Pogamut.getPlatform().close() in order to shutdown registry. Therefore you must somehow now the time when that moment comes. This can be achieved by different means / approaches - one of them is SingleUT2004BotRunner and MultipleUT2004BotRunner.

I advise you to check out the source of SingleUT2004BotRunner and see how the bot is being constructed and where it waits till the bot finishes. Cut these parts of the code into your main method and experiment. ... you will probably need to read javadoc for factory and modules.

We're using Guice IOC to assamble the agent - therefore you need to instantiate a module (see UT2004BotModule) that configures UT2004BotFactory (from ...guice... package). The factory can then construct a new agent for you that can be started via .start() method.

Note that the start() method has a nice behavior - even though the agent is multithreaded - start() method will finish when the bot is actually completely running. If any thread fails during start up - start() will throw an exception. (Thanks to "component design" and "ComponentBus" object that provides life-cycle for all agent components.).

Once the agent is started - you can observe its states via getState().getFlag() ... note that the stat is actually object of some class and the class is implementing various interfaces that serves as markers "what stat it is" ... there is a hierarchy between agent states ... see package cz.cuni.amis.pogamut.base.agent.state and see which interfaces are there ... if you want to check whether the agent is in particular state, you may use .inState() or .notInState() methods at Agent.

Phew - lot of infos ;-)

Good luck!

Jimmy
Actually my idea is to create as many servers as possible and then have 2 bots joining each server. For now I'll just have a thread starting a bot though there probarbly is a smarter way of doing this.
No problem ;-)

Hint: see UCCWrapper class

Jimmy
When I'm creating a new bot there will be created a new thread running the bot but the old thread starting the bot also stops. This wasn't a problem with pogamut 2, am I missing something in order to have both threads running at the same time?
Sorry for all the questions ;) and thanks for all the help.
Please, start a new topic :-)

Jimmy
 

News

News RSS RSS feed for News link



Pogamut

Quarterly RSS RSS feed for quarterly reports

Acknowledgement

This work is supported by GA UK 1053/2007/A-INF/MFF (2007-8), GA UK 351/2006/A-INF/MFF (2006-8), the Ministry of Education of the Czech Republic (grant MSM0021620838) (2008-9), by the Program "Information Society" under project 1ET100300517 (2006-9), and the project Integration of IT Tools into Education of Humanities (2006-8) and by the project CZ.2.17/3.1.00/31162, which are financed by the European Social Fund, the state budget of the Czech Republic, and by the budget of Municipal House Prague.