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