|
@@ -2,16 +2,22 @@ from xyworld.display.object.pygame.PygameImage import PygameImage
|
2
|
2
|
from xyworld.display.object.pygame.DirectionnedImage import DirectionnedImage
|
3
|
3
|
from socialintengine.synergy.object.Bug import Bug
|
4
|
4
|
from socialintengine.synergy.object.ant.Ant import Ant
|
|
5
|
+from socialintengine.sandbox.redblue.BlueAnt import BlueAnt
|
|
6
|
+from socialintengine.sandbox.redblue.RedAnt import RedAnt
|
5
|
7
|
from socialintengine.synergy.object.Rock import Rock
|
6
|
8
|
from os import getcwd
|
7
|
9
|
from synergine.metas import metas
|
8
|
10
|
from socialintengine.cst import PREVIOUS_DIRECTION
|
9
|
11
|
|
10
|
12
|
ant = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/ant.png')
|
|
13
|
+red_ant = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/red_ant.png')
|
|
14
|
+blue_ant = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/blue_ant.png')
|
11
|
15
|
bug = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/ant.png')
|
12
|
16
|
rock = PygameImage.from_filepath(getcwd()+'/socialintengine/display/pygame/image/rock.png')
|
13
|
17
|
|
14
|
18
|
directions_ant = DirectionnedImage(ant)
|
|
19
|
+directions_red_ant = DirectionnedImage(red_ant)
|
|
20
|
+directions_blue_ant = DirectionnedImage(blue_ant)
|
15
|
21
|
|
16
|
22
|
def bug_direction(bug):
|
17
|
23
|
try:
|
|
@@ -20,9 +26,31 @@ def bug_direction(bug):
|
20
|
26
|
previous_direction = 14
|
21
|
27
|
return directions_ant.get_for_direction(previous_direction)
|
22
|
28
|
|
|
29
|
+def red_ant_direction(bug):
|
|
30
|
+ try:
|
|
31
|
+ previous_direction = metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
|
|
32
|
+ except KeyError:
|
|
33
|
+ previous_direction = 14
|
|
34
|
+ return directions_red_ant.get_for_direction(previous_direction)
|
|
35
|
+
|
|
36
|
+def blue_ant_direction(bug):
|
|
37
|
+ try:
|
|
38
|
+ previous_direction = metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
|
|
39
|
+ except KeyError:
|
|
40
|
+ previous_direction = 14
|
|
41
|
+ return directions_blue_ant.get_for_direction(previous_direction)
|
|
42
|
+
|
23
|
43
|
visualisation = {
|
24
|
44
|
'window': {},
|
25
|
45
|
'objects': {
|
|
46
|
+ RedAnt: {
|
|
47
|
+ 'default': red_ant,
|
|
48
|
+ 'callbacks': [red_ant_direction]
|
|
49
|
+ },
|
|
50
|
+ BlueAnt: {
|
|
51
|
+ 'default': blue_ant,
|
|
52
|
+ 'callbacks': [blue_ant_direction]
|
|
53
|
+ },
|
26
|
54
|
Ant: {
|
27
|
55
|
'default': ant,
|
28
|
56
|
'callbacks': [bug_direction]
|