Loading...
 

PogamutUT2004


Preset objects/attributes being cleared. Why?

Okay I don't know if this is supposed to be or if it is an error but it's not possible to save attributes to the bot object before after it has been initialized. I'll probarbly figure a workaround but it just doesn't make sence to me.

Simple example:

dummy = new DummyBot();
dummy.prePogaInit(this);
dummy.testInt = 5;

BotThreadRunner runner = new BotThreadRunner(dummy);
Thread thread = new Thread(runner);
thread.start();

and then in the bots logic() method following:

System.out.println(testInt);

will give 0 and not 5 in output because the value has never been set.
Hi!

It doesn't make sense to me neither!

I would try to set breakpoint on 'testInt' modification and see, whether you accidentally reset the value back to 0.

Then I would check, whether the 'dummy' is really being used.

Is DummyBot descendant of UT2004BotController? (or ...LogicController or ModuleController) ?

Jakub
Descendant of UT2004BotLogicController. There is no possible place to reset it.
The main of DummyBot is following:

UT2004BotModule myModule = new UT2004BotModule(DummyBot.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, "DummyBot", "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();

I'm had a problem before where I had forgotten to change EmptyBot to DummyBot so it spawned the wrong bot. Changed the new module line to the correct and everything worked, I'm thinking it has something to do with how it makes new bots. This is the line:

new UT2004BotModule(DummyBot.class);

Will continue working on it =/
Oh neat figured out I could move everything from the main method out but I'm still not getting the right object. It's like I'm creating it only to create a new object that has no reference to the old one =/
Well didn't do much good for me either as I can't seem to grab the bot object that I need to get my hands on. Might have to create some kind og singleton that the bot objects can get their hands on and get their initialization parameters.
Hi,

you've written, that you have manually instantiated DummyBot

dummy = new DummyBot();
dummy.prePogaInit(this);
dummy.testInt = 5;

And after that, you're writing you're using UT2004BotRunner.

Actually UT2004BotRunner instantiate its own new controller for the bot - you can't instantiate your own DummyBot and expect UT2004BotRunner will use that instance. Or am I missing something?

I think you're trying to find a way how to easily parametrize your bot when starting them. Am I right?

Well - this is currently a bit hard to do with Pogamut 3 as you would need to alter UT2004BotModule and probably even make a descendant of UT2004BotLogicController. But I can pull it out if you need it.

Cheers!
Jakub
It is possible to parametrize bot with a simple hack. I use this in my main method. My agent class is "EmohawkAgent":
// factory object is used to construct new instances of bots
        UT2004BotModule module = new UT2004BotModule(EmohawkAgent.class);
        UT2004BotFactory factory = new UT2004BotFactory(module);
        // runner starts the bot constructed by factory and connects it to the server
        // address and the port of the server are specified in PogamutPlatformCustom.properties
        UT2004BotRunner botRunner = new UT2004BotRunner(factory, name) {
            @Override
            protected void preStartHook(UT2004Bot agent){
                EmohawkAgent cont = (EmohawkAgent) agent.getController();
                cont.agentName = name;
                cont.setStoryController(controller);
            }
        };
        botRunner.startAgent();


The key is to override preStartHook method. I set there bot name and StoryController (inside EmohawkAgent class).

Does this help?

Best,
michal
hmm can't make the preStartHook work. Seems like its missing from one of the parents =/ but if I could make it work it should solve my problem.
What I did to make it work was to make the bot register from the prepareBot() method to a singleton and get their information there. Works like a charm so will go with this. But you guys should make an easy way to get that bot object ;) and whole the initiation part. (Might just be me because I'm doing this thing with many servers and many bots)

Anyway again thanks for the feedback.
Yes, singleton would work too, but the parametrization is worse problem.

Technically - we're working with Guice and Guice allows you to inject arbitrary object to arbitrary constructed object.
My idea is to pass arbitrary "descendant of some IAgentParameters" object to the bot's factory (as optional argument)
that would allow anybody to pass arbitrary configuration object into the bot.

Such object could be instantiated from the property file then (for instance)...

Would it suffice for you to have UT2004BotRunner with method startAgent(myConfigObject) ?

Cheers,
Jakub
I'm not sure I follow you completely ;) what I was requesting was just a simple way to set attributes and references in the bot before the thread running the bot starts. This way it would be easier to set up the bot externally instead of setting up everything inside the bots build in methods.

What I am doing right now is after creation of the bot, the bot send itself to the singleton. Another object then contacts the singleton and grabs the bot object to set the initialization parameters. This solves my problem and my request was more for other users that might come into similar problems (though they could just surf the forum and find this topic now :-) ).
if your code is working than everything is OK (whether it works or not is usually all that counts :-)).

Cheers!
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.