Browse Source

sandbox: add green colony

Bastien Sevajol 9 years ago
parent
commit
ca25716535

+ 1 - 1
config.py View File

2
 from intelligine.synergy.Simulation import Simulation
2
 from intelligine.synergy.Simulation import Simulation
3
 from intelligine.display.Pygame import Pygame
3
 from intelligine.display.Pygame import Pygame
4
 from intelligine.display.pygame.visualisation import visualisation as pygame_visualisation
4
 from intelligine.display.pygame.visualisation import visualisation as pygame_visualisation
5
-from intelligine.sandbox.redblue.red_blue_colonys import collections
5
+from intelligine.sandbox.colored.colors_colonys import collections
6
 
6
 
7
 """
7
 """
8
  TODO:
8
  TODO:

BIN
intelligine/display/pygame/image/dead_green_ant.png View File


BIN
intelligine/display/pygame/image/green_ant.png View File


+ 19 - 2
intelligine/display/pygame/visualisation.py View File

2
 from xyworld.display.object.pygame.DirectionnedImage import DirectionnedImage
2
 from xyworld.display.object.pygame.DirectionnedImage import DirectionnedImage
3
 from intelligine.synergy.object.Bug import Bug
3
 from intelligine.synergy.object.Bug import Bug
4
 from intelligine.synergy.object.ant.Ant import Ant
4
 from intelligine.synergy.object.ant.Ant import Ant
5
-from intelligine.sandbox.redblue.BlueAnt import BlueAnt
6
-from intelligine.sandbox.redblue.RedAnt import RedAnt
5
+from intelligine.sandbox.colored.BlueAnt import BlueAnt
6
+from intelligine.sandbox.colored.RedAnt import RedAnt
7
+from intelligine.sandbox.colored.GreenAnt import GreenAnt
7
 from intelligine.synergy.object.Rock import Rock
8
 from intelligine.synergy.object.Rock import Rock
8
 from os import getcwd
9
 from os import getcwd
9
 from synergine.metas import metas
10
 from synergine.metas import metas
14
 ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
15
 ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
15
 dead_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_ant.png')
16
 dead_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_ant.png')
16
 red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/red_ant.png')
17
 red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/red_ant.png')
18
+green_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/green_ant.png')
17
 blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/blue_ant.png')
19
 blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/blue_ant.png')
18
 dead_red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_red_ant.png')
20
 dead_red_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_red_ant.png')
21
+dead_green_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_green_ant.png')
19
 dead_blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_blue_ant.png')
22
 dead_blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/dead_blue_ant.png')
20
 bug = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
23
 bug = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
21
 rock = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/rock.png')
24
 rock = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/rock.png')
23
 directions_ant = DirectionnedImage(ant)
26
 directions_ant = DirectionnedImage(ant)
24
 directions_red_ant = DirectionnedImage(red_ant)
27
 directions_red_ant = DirectionnedImage(red_ant)
25
 directions_blue_ant = DirectionnedImage(blue_ant)
28
 directions_blue_ant = DirectionnedImage(blue_ant)
29
+directions_green_ant = DirectionnedImage(green_ant)
26
 
30
 
27
 def bug_direction(bug):
31
 def bug_direction(bug):
28
     if bug.get_life_points() <= 0:
32
     if bug.get_life_points() <= 0:
51
         previous_direction = 14
55
         previous_direction = 14
52
     return directions_blue_ant.get_for_direction(previous_direction)
56
     return directions_blue_ant.get_for_direction(previous_direction)
53
 
57
 
58
+def green_ant_direction(bug):
59
+    if bug.get_life_points() <= 0:
60
+        return dead_green_ant
61
+    try:
62
+        previous_direction = metas.value.get(PREVIOUS_DIRECTION, bug.get_id())
63
+    except KeyError:
64
+        previous_direction = 14
65
+    return directions_green_ant.get_for_direction(previous_direction)
66
+
54
 visualisation = {
67
 visualisation = {
55
     'window': {},
68
     'window': {},
56
     'objects': {
69
     'objects': {
62
             'default': blue_ant,
75
             'default': blue_ant,
63
             'callbacks': [blue_ant_direction]
76
             'callbacks': [blue_ant_direction]
64
         },
77
         },
78
+        GreenAnt: {
79
+            'default': green_ant,
80
+            'callbacks': [green_ant_direction]
81
+        },
65
         Ant: {
82
         Ant: {
66
             'default': ant,
83
             'default': ant,
67
             'callbacks': [bug_direction]
84
             'callbacks': [bug_direction]

intelligine/sandbox/redblue/BlueAnt.py → intelligine/sandbox/colored/BlueAnt.py View File


intelligine/sandbox/redblue/BlueColonyConfiguration.py → intelligine/sandbox/colored/BlueColonyConfiguration.py View File

1
 from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
1
 from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.sandbox.redblue.BlueAnt import BlueAnt
2
+from intelligine.sandbox.colored.BlueAnt import BlueAnt
3
 
3
 
4
 
4
 
5
 class BlueColonyConfiguration(ColonyConfiguration):
5
 class BlueColonyConfiguration(ColonyConfiguration):

+ 4 - 0
intelligine/sandbox/colored/GreenAnt.py View File

1
+from intelligine.synergy.object.ant.Ant import Ant
2
+
3
+class GreenAnt(Ant):
4
+    pass

+ 8 - 0
intelligine/sandbox/colored/GreenColonyConfiguration.py View File

1
+from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
+from intelligine.sandbox.colored.GreenAnt import GreenAnt
3
+
4
+
5
+class GreenColonyConfiguration(ColonyConfiguration):
6
+
7
+    _start_position = (0, 70, 70)
8
+    _ant_class = GreenAnt

intelligine/sandbox/redblue/RedAnt.py → intelligine/sandbox/colored/RedAnt.py View File


intelligine/sandbox/redblue/RedColonyConfiguration.py → intelligine/sandbox/colored/RedColonyConfiguration.py View File

1
 from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
1
 from intelligine.synergy.ColonyConfiguration import ColonyConfiguration
2
-from intelligine.sandbox.redblue.RedAnt import RedAnt
2
+from intelligine.sandbox.colored.RedAnt import RedAnt
3
 
3
 
4
 
4
 
5
 class RedColonyConfiguration(ColonyConfiguration):
5
 class RedColonyConfiguration(ColonyConfiguration):
6
 
6
 
7
-    _start_position = (0, 70, 20)
7
+    _start_position = (0, 20, 70)
8
     _ant_class = RedAnt
8
     _ant_class = RedAnt

+ 11 - 0
intelligine/sandbox/colored/colors_colonys.py View File

1
+from intelligine.sandbox.colored.RedColonyConfiguration import RedColonyConfiguration
2
+from intelligine.sandbox.colored.BlueColonyConfiguration import BlueColonyConfiguration
3
+from intelligine.sandbox.colored.GreenColonyConfiguration import GreenColonyConfiguration
4
+from intelligine.synergy.Colony import Colony
5
+from intelligine.synergy.Rocks import Rocks
6
+from intelligine.synergy.RocksConfiguration import RocksConfiguration
7
+
8
+collections = [Colony(BlueColonyConfiguration()), \
9
+               Colony(RedColonyConfiguration()), \
10
+               Colony(GreenColonyConfiguration()), \
11
+               Rocks(RocksConfiguration())]

+ 0 - 7
intelligine/sandbox/redblue/red_blue_colonys.py View File

1
-from intelligine.sandbox.redblue.RedColonyConfiguration import RedColonyConfiguration
2
-from intelligine.sandbox.redblue.BlueColonyConfiguration import BlueColonyConfiguration
3
-from intelligine.synergy.Colony import Colony
4
-from intelligine.synergy.Rocks import Rocks
5
-from intelligine.synergy.RocksConfiguration import RocksConfiguration
6
-
7
-collections = [Colony(BlueColonyConfiguration()), Colony(RedColonyConfiguration()), Rocks(RocksConfiguration())]

+ 7 - 1
intelligine/synergy/RocksConfiguration.py View File

11
 
11
 
12
       for i in range(100):
12
       for i in range(100):
13
           rocks_positions.append((0, 0+i, 0))
13
           rocks_positions.append((0, 0+i, 0))
14
-          rocks_positions.append((0, 0+i, 50))
14
+          if i is not 75:
15
+              rocks_positions.append((0, 0+i, 50))
16
+          rocks_positions.append((0, 0+i, 100))
15
 
17
 
16
       for i in range(50):
18
       for i in range(50):
17
           rocks_positions.append((0, 0, 0+i))
19
           rocks_positions.append((0, 0, 0+i))
18
           if i is not 25:
20
           if i is not 25:
19
               rocks_positions.append((0, 50, 0+i))
21
               rocks_positions.append((0, 50, 0+i))
22
+          rocks_positions.append((0, 100, 50+i))
23
+          rocks_positions.append((0, 0, 50+i))
24
+          rocks_positions.append((0, 50, 50+i))
20
           rocks_positions.append((0, 100, 0+i))
25
           rocks_positions.append((0, 100, 0+i))
21
 
26
 
22
       rocks_positions.append((0, 50, 50))
27
       rocks_positions.append((0, 50, 50))
23
       rocks_positions.append((0, 100, 50))
28
       rocks_positions.append((0, 100, 50))
29
+      rocks_positions.append((0, 100, 100))
24
 
30
 
25
       for rock_position in rocks_positions:
31
       for rock_position in rocks_positions:
26
           rock = Rock()
32
           rock = Rock()