forked from xathis/AI-Challenge-2011-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathType.java
54 lines (45 loc) · 1.03 KB
/
Type.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
public enum Type {
UNSEEN (-4, '?'),
WATER (-3, '%'),
FOOD (-2, '*'),
LAND (-1, '.'),
MY_ANT (0, 'A'),
PLAYER1 (1, 'B'),
PLAYER2 (2, 'C'),
PLAYER3 (3, 'D'),
PLAYER4 (4, 'E'),
PLAYER5 (5, 'F'),
PLAYER6 (6, 'G'),
PLAYER7 (7, 'H'),
PLAYER8 (8, 'I'),
PLAYER9 (9, 'J');
private static final Map<Integer, Type> idLookup = new HashMap<Integer, Type>();
private static final Map<Character, Type> symbolLookup = new HashMap<Character, Type>();
static {
for (Type i : EnumSet.allOf(Type.class)) {
idLookup.put(i.id, i);
symbolLookup.put(i.symbol, i);
}
}
public final int id;
public final char symbol;
private Type(int id, char symbol) {
this.id = id;
this.symbol = symbol;
}
public boolean isFree() {
return id == LAND.id;
}
public boolean isEnemy() {
return id > MY_ANT.id;
}
public static Type fromId(int id) {
return idLookup.get(id);
}
public static Type fromSymbol(char symbol) {
return symbolLookup.get(symbol);
}
}