[Pogamut-list] Experimental bot setup

jacob.schrum pogamut-forum at diana.ms.mff.cuni.cz
Fri Jul 9 05:57:55 CEST 2010


Re: Experimental bot setup

Author: jacob.schrum

Do you not want to reset the server because you would have to do it yourself? You can make the Java code do it for you automatically. The best way to do this is probably using the new ControlServer (see the sticky in this forum), but I have my own messy way. I'm pretty sure that a lot of this code is unnecessary, but it works for me:


        UCCWrapper.UCCWrapperConf config = new UCCWrapper.UCCWrapperConf();
        config.setMapName("DM-Junkyard");
        config.setGameBotsPack("GameBots2004");
        config.setGameType("BotDeathMatch");
        config.setOptions("?mutator=GameBots2004.BotPrizeMutator?timelimit=0?fraglimit=0?GoalScore=0?bAllowPrivateChat=False?bAllowTaunts=False?bEnableVoiceChat=False?bAllowLocalBroadcast=False");
        UCCWrapper ucc = new UCCWrapper(config);

        UT2004Server server = ucc.getUTServer();
        System.out.println("Confirming empty server");
        while (server.getAgents().size() > 0) {
            try {
                System.out.println("NOT EMPTY! RESET!");
                server.kill();
                ucc.stop();
                synchronized (this) {
                    this.wait(1000);
                }
            } catch (InterruptedException ex) {
                Logger.getLogger(LocalBaseExperimentExecutorImpl.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception e) {
                System.out.println(e);
            } finally {
                ucc = new MyUCCWrapper(config);
                server = ucc.getUTServer();
            }
        }
        //Server was launched?
        System.out.println("Launch bots on empty server");

        try {
       	    MultipleUT2004BotRunner.BotDescriptor scripted = new MultipleUT2004BotRunner.BotDescriptor(opponents, opponentClass, "Name");

            // Run bots
            MultipleUT2004BotRunner runner = new MultipleUT2004BotRunner(host, port, evolve, scripted);
            runner.setPausing(false).startAgent();
            // When done running
            System.out.println("KILL ALL AGENTS");
            runner.killAgents();
	} finally {
            server.kill();
            try {
                System.out.println("Kill Server");
                //server.stop();
                ucc.stop();
            } finally {
                try {
                    synchronized (this) {
                        this.wait(1000);
                    }
                } catch (InterruptedException ex) {
                    Logger.getLogger(LocalBaseExperimentExecutorImpl.class.getName()).log(Level.SEVERE, null, ex);
                    ex.printStackTrace();
                }
            }
        }

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=277&post_reply=1#form>





More information about the Pogamut-list mailing list