1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package nl.tudelft.goal.emohawk.environment;
22
23 import java.util.HashMap;
24
25 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController;
26
27 import nl.tudelft.goal.EIS2Java.handlers.ActionHandler;
28 import nl.tudelft.goal.EIS2Java.handlers.AsynchronousEntity;
29 import nl.tudelft.goal.EIS2Java.handlers.PerceptHandler;
30 import nl.tudelft.goal.EIS2Java.handlers.SynchronizedActionHandler;
31 import nl.tudelft.goal.EIS2Java.handlers.SynchronizedPerceptHandler;
32 import nl.tudelft.goal.EIS2Java.translation.Translator;
33 import nl.tudelft.goal.emohawk.agent.EmohawkBotBehavior;
34 import nl.tudelft.goal.emohawk.translators.AgentInfoTranslator;
35 import nl.tudelft.goal.emohawk.translators.AnimTypeTranslator;
36 import nl.tudelft.goal.emohawk.translators.EmoticonTypeTranslator;
37 import nl.tudelft.goal.emohawk.translators.GameTranslator;
38 import nl.tudelft.goal.emohawk.translators.PlaceTranslator;
39 import nl.tudelft.goal.emohawk.translators.PlayerTranslator;
40 import nl.tudelft.goal.emohawk.translators.UnrealIdOrLocationTranslator;
41 import nl.tudelft.goal.unreal.environment.AbstractUnrealEnvironment;
42 import nl.tudelft.goal.unreal.translators.LocationTranslator;
43 import nl.tudelft.goal.unreal.translators.NavPointTranslator;
44 import nl.tudelft.goal.unreal.translators.RotationTranslator;
45 import nl.tudelft.goal.unreal.translators.TeamTranslator;
46 import nl.tudelft.goal.unreal.translators.UnrealIdTranslator;
47 import nl.tudelft.goal.unreal.translators.VelocityTranslator;
48 import eis.exceptions.EntityException;
49 import eis.exceptions.ManagementException;
50 import eis.iilang.Identifier;
51 import eis.iilang.Parameter;
52 import eis.iilang.ParameterList;
53
54 public class EmohawkEnvironment extends AbstractUnrealEnvironment {
55
56
57
58
59 private static final long serialVersionUID = 8240549393243585632L;
60
61 @Override
62 protected void registerTranslators() {
63
64 Translator translator = Translator.getInstance();
65
66
67
68
69
70
71
72 LocationTranslator locationTranslator = new LocationTranslator();
73 translator.registerJava2ParameterTranslator(locationTranslator);
74 translator.registerParameter2JavaTranslator(locationTranslator);
75
76
77
78
79
80
81
82 NavPointTranslator navPointTranslator = new NavPointTranslator();
83 translator.registerJava2ParameterTranslator(navPointTranslator);
84 translator.registerParameter2JavaTranslator(navPointTranslator);
85
86 RotationTranslator rotationTranslator = new RotationTranslator();
87 translator.registerJava2ParameterTranslator(rotationTranslator);
88 translator.registerParameter2JavaTranslator(rotationTranslator);
89
90 TeamTranslator teamTranslator = new TeamTranslator();
91 translator.registerJava2ParameterTranslator(teamTranslator);
92 translator.registerParameter2JavaTranslator(teamTranslator);
93
94 UnrealIdTranslator unrealIdTranslator = new UnrealIdTranslator();
95 translator.registerJava2ParameterTranslator(unrealIdTranslator);
96 translator.registerParameter2JavaTranslator(unrealIdTranslator);
97
98 VelocityTranslator velocityTranslator = new VelocityTranslator();
99 translator.registerJava2ParameterTranslator(velocityTranslator);
100 translator.registerParameter2JavaTranslator(velocityTranslator);
101
102
103
104
105
106
107 AgentInfoTranslator agentInfoTranslator = new AgentInfoTranslator();
108 translator.registerJava2ParameterTranslator(agentInfoTranslator);
109
110 AnimTypeTranslator animTypeTranslator = new AnimTypeTranslator();
111 translator.registerJava2ParameterTranslator(animTypeTranslator);
112 translator.registerParameter2JavaTranslator(animTypeTranslator);
113
114 EmoticonTypeTranslator emoticonTypeTranslator = new EmoticonTypeTranslator();
115 translator.registerJava2ParameterTranslator(emoticonTypeTranslator);
116 translator.registerParameter2JavaTranslator(emoticonTypeTranslator);
117
118 GameTranslator gameTranslator = new GameTranslator();
119 translator.registerJava2ParameterTranslator(gameTranslator);
120
121 PlaceTranslator placeTranslator = new PlaceTranslator();
122 translator.registerJava2ParameterTranslator(placeTranslator);
123
124 PlayerTranslator playerTranslator = new PlayerTranslator();
125 translator.registerJava2ParameterTranslator(playerTranslator);
126
127 UnrealIdOrLocationTranslator unrealIdOrLocationTranslator = new UnrealIdOrLocationTranslator();
128 translator.registerParameter2JavaTranslator(unrealIdOrLocationTranslator);
129
130 }
131
132 public static void main(String[] args) throws ManagementException {
133 HashMap<String, Parameter> map = new HashMap<String, Parameter>();
134 map.put("botNames", new ParameterList(new Identifier("Test")));
135 new EmohawkEnvironment().init(map);
136
137 }
138
139 @Override
140 protected Class<EmohawkBotBehavior> getControlerClass() {
141 return EmohawkBotBehavior.class;
142 }
143
144 @Override
145 protected PerceptHandler createPerceptHandler(UT2004BotController controller) throws EntityException {
146 return new SynchronizedPerceptHandler((AsynchronousEntity) controller);
147 }
148
149 @Override
150 protected ActionHandler createActionHandler(UT2004BotController controller) throws EntityException {
151 return new SynchronizedActionHandler((AsynchronousEntity) controller);
152 }
153
154 }