1 package cz.cuni.amis.pogamut.ut2004.utils;
2
3 import java.util.List;
4
5 import cz.cuni.amis.pogamut.base.agent.IAgentId;
6 import cz.cuni.amis.pogamut.base.agent.params.IAgentParameters;
7 import cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner;
8 import cz.cuni.amis.pogamut.base.communication.connection.impl.socket.SocketConnectionAddress;
9 import cz.cuni.amis.pogamut.base.factory.IAgentFactory;
10 import cz.cuni.amis.pogamut.base.utils.Pogamut;
11 import cz.cuni.amis.pogamut.base.utils.PogamutPlatform;
12 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004Bot;
13 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
14 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
15 import cz.cuni.amis.pogamut.ut2004.bot.params.UT2004BotParameters;
16 import cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotFactory;
17 import cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotModule;
18 import cz.cuni.amis.utils.NullCheck;
19 import cz.cuni.amis.utils.exception.PogamutException;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class UT2004BotRunner<BOT extends IUT2004Bot, PARAMS extends UT2004BotParameters>
39 extends UTBotRunner<BOT, PARAMS> {
40
41
42
43
44
45
46
47
48
49
50
51
52
53 public UT2004BotRunner(IAgentFactory<BOT, PARAMS> factory, String name,
54 String host, int port) {
55 super(factory, name, host, port);
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69
70 public UT2004BotRunner(IAgentFactory<BOT, PARAMS> factory, String name) {
71 super(factory, name);
72 }
73
74
75
76
77
78
79
80
81
82
83 public UT2004BotRunner(IAgentFactory<BOT, PARAMS> factory) {
84 this(factory, "UT2004Bot");
85 }
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 public UT2004BotRunner(UT2004BotModule module, String name, String host,
101 int port) {
102 this(new UT2004BotFactory<BOT, PARAMS>(module), name, host, port);
103 }
104
105
106
107
108
109
110
111
112
113
114
115 public UT2004BotRunner(UT2004BotModule module, String name) {
116 this(module, name, Pogamut.getPlatform().getProperty(
117 PogamutUT2004Property.POGAMUT_UT2004_BOT_HOST.getKey()),
118 Pogamut.getPlatform().getIntProperty(
119 PogamutUT2004Property.POGAMUT_UT2004_BOT_PORT.getKey()));
120 }
121
122
123
124
125
126
127
128
129
130
131 public UT2004BotRunner(UT2004BotModule module) {
132 this(module, "UT2004Bot");
133 }
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 public UT2004BotRunner(
150 Class<? extends IUT2004BotController> botControllerClass,
151 String name, String host, int port) {
152 this(new UT2004BotModule(botControllerClass), name, host, port);
153 }
154
155
156
157
158
159
160
161
162
163
164
165
166 public UT2004BotRunner(
167 Class<? extends IUT2004BotController> botControllerClass,
168 String name) {
169 this(
170 new UT2004BotModule(botControllerClass),
171 name,
172 Pogamut.getPlatform().getProperty(
173 PogamutUT2004Property.POGAMUT_UT2004_BOT_HOST.getKey()),
174 Pogamut.getPlatform().getIntProperty(
175 PogamutUT2004Property.POGAMUT_UT2004_BOT_PORT.getKey()));
176 }
177
178
179
180
181
182
183
184
185
186
187
188 public UT2004BotRunner(
189 Class<? extends IUT2004BotController> botControllerClass) {
190 this(new UT2004BotModule(botControllerClass), "UT2004Bot");
191 }
192
193 @Override
194 public BOT startAgent() throws PogamutException {
195 return super.startAgent();
196 }
197
198 @Override
199 public List<BOT> startAgents(int count) throws PogamutException {
200 return super.startAgents(count);
201 }
202
203 @Override
204 public List<BOT> startAgents(PARAMS... agentParameters)
205 throws PogamutException {
206 return super.startAgents(agentParameters);
207 };
208
209
210
211
212
213
214
215
216
217
218
219
220 public UT2004BotRunner<BOT, PARAMS> setName(String name) {
221 if (name == null)
222 name = "UT2004Bot";
223 super.setName(name);
224 return this;
225 }
226
227
228
229
230
231
232
233
234 public UT2004BotRunner<BOT, PARAMS> setHost(String host) {
235 super.setHost(host);
236 return this;
237 }
238
239
240
241
242
243
244
245
246
247 public UT2004BotRunner<BOT, PARAMS> setPort(int port) {
248 super.setPort(port);
249 return this;
250 }
251
252
253
254
255
256
257 @Override
258 protected IAgentParameters newDefaultAgentParameters() {
259 return new UT2004BotParameters().setAgentId(newAgentId(name))
260 .setWorldAddress(new SocketConnectionAddress(host, port));
261 }
262
263 @Override
264 public UT2004BotRunner<BOT, PARAMS> setMain(boolean state) {
265 super.setMain(state);
266 return this;
267 }
268
269 @Override
270 public UT2004BotRunner<BOT, PARAMS> setConsoleLogging(boolean enabled) {
271 super.setConsoleLogging(enabled);
272 return this;
273 }
274
275 }