-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
51 lines (43 loc) · 1.23 KB
/
game.py
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
import graphics
import pocketgl
import grid
import ant, antType
import time
"""
Améliorations:
- Ajouter un compteur de coup + % de chaque couleur
- Nombre de col et ligne dynamique
- Optimisation de l'affichage
"""
def antsWalks(grid):
for a in ant.getAnts():
x = a.getX()
y = a.getY()
colorAnt = a.getType()[0]
colorCase = grid.getValue(x, y)
a.walk(grid)
if colorCase != colorAnt:
grid.setValue(x, y, colorAnt) # setColor on last tile
else:
grid.setValue(x, y, "white")
graphics.updateGraphics(grid)
def spawnAnt(color, x, y):
ant.Ant(color, x, y)
if __name__ == '__main__':
caseX = 40
caseY = 40
grid = grid.Grid(caseX, caseY)
grid.fillGrid('white')
antType.initAntType("antType.txt")
spawnAnt("red", 25, 25)
spawnAnt("blue", 20, 15)
spawnAnt("yellow", 15, 20)
spawnAnt("green", 20, 25)
graphics.initGL("Fourmi de Langton", caseX, caseY)
walkTimeNeeded = 10000
timePerWalk = 0.00000002 # in seconds
while walkTimeNeeded != 0:
walkTimeNeeded -= 1
time.sleep(timePerWalk)
antsWalks(grid)
pocketgl.main_loop()