Loading...
 

PogamutUT2004


Proper bot termination

What is the best way to remove multiple bots from a level started using the MultipleUT2004BotRunner? I'm doing evolution, and for every evaluation I'm starting up 3 bots, all of which need to be removed from the level before I launch the next three. However, my current method is resulting in some bots remaining stuck standing still in the level.

Bots are launched using MultipleUT2004BotRunner, and all of them share a common super class that contains this method.

@Override
public void logic() throws PogamutException {
if (limitedEvaluation) {
if (startTime < 0) {
startTime = this.game.getTime();
}
double elapsed = this.game.getTime();
if ((elapsed - startTime) > evalTime) { // Terminate evaluation
this.bot.kill();
}
}
}

The logic method of all the subclasses call super.logic(). The startTime is always initialized to negative so that it can be properly set once the bot realizes it is in the world. Afterwards, the bot should remove it self after evalTime has elapsed.

This might be a problem with UT not removing bots that suddenly get disconnected. That's why I'm asking if there's a better way to disconnect the bots than using this.bot.kill().
Hi! This is a common problem of UT2004 that sometimes leaves the body hanging up in the environment.

I would suggest you to use also UT2004Server instance (obtainable via UT2004ServerFactory) and after you kill your agents, kick them out using UT2004Server and Kick command.
That is, use server.getAct().act(new Kick(somePlayer.getId())); for every player that is still in the game.

This will take some time to tweak up as there will be some waiting involved (you will wait for the GB2004 to report you that the player has left,
note that UT2004Server has 'players' as observable collection, so you may hook up a listener for that).

Unfortunately - this functionality is not nicely wrapped yet.

Best,
Jimmy
But where does UT2004ServerFactory come from? If I launch my bot using MultipleUT2004BotRunner, then does an instance of UT2004ServerFactory even exist? I've been launching the server externally, not from within the code.

That being said, I would very much like to make my code launch the server instead, but this doesn't seem to be working very well, and I can't figure out how to do it. I would like to know how to get an active instance of UT2004ServerFactory and/or how to launch a UT server from my code (in which case I could simply kill the server and restart it to assure that no unwanted bots remain in the game).
Hi!

If you're using MultipleUT2004BotRunner than the correct place is just before the Multple... is used.

UT2004ServerFactory lies in the package cz.cuni.amis.pogamut.ut2004.factory.direct.remoteagent, thus import it
and instantiate using

factory = new UT2004ServerFactory();

UT2004Server server = factory.newAgent(new AgentId("MyServer"), new SocketConnectionAddress("localhost", 3001)); // or whatever port the control connection is running at

Than use your Multiple... to start the agents, after they finish, use the 'server' instance to iterate through its players kicking them out.

Hope it helps :-)

Cheers!
Jakub

P.S.: the main idea is to instantiate and use the UT2004Server in the very place where your bots are being executed.
 

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.