1 package cz.cuni.amis.pogamut.ut2004multi.bot.impl;
2
3 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
4 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
5 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController;
6 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Item;
7 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
8 import cz.cuni.amis.pogamut.ut2004multi.communication.module.SharedKnowledgeDatabase;
9 import cz.cuni.amis.utils.flag.Flag;
10
11 public class UT2004BotMultiController extends UT2004BotModuleController<UT2004Bot> {
12
13 protected SharedKnowledgeDatabase shared;
14
15
16
17
18 @Override
19 public void finishControllerInitialization() {
20 super.finishControllerInitialization();
21 if ( info.getTeam() == AgentInfo.TEAM_RED
22 || info.getTeam() == AgentInfo.TEAM_BLUE
23 || info.getTeam() == AgentInfo.TEAM_GREEN
24 || info.getTeam() == AgentInfo.TEAM_GOLD
25 ) {
26 log.fine("Initializing shared knowledge database.");
27 shared = SharedKnowledgeDatabase.get(info.getTeam());
28 shared.addAgent(bot.getComponentId(), world, info.getTeam());
29 log.info("Shared knowledge database initialized.");
30 configureSharedKnowledgeDatabase();
31 } else {
32 log.warning("Shared knowledge database not initialized as the bot is not playing team game! It's team is neither RED, BLUE, GREEN nor GOLD.");
33 log.warning("Setting 'shared' field to NULL!");
34 shared = null;
35 }
36 }
37
38 protected void configureSharedKnowledgeDatabase() {
39 log.info("As default, shared knowledge database is initialized to share Player, Item and Flag objects.");
40 shared.addObjectClass(Player.class);
41 shared.addObjectClass(Item.class);
42 shared.addObjectClass(Flag.class);
43 }
44
45
46
47
48
49 public SharedKnowledgeDatabase getShared() {
50 return shared;
51 }
52
53 }