This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecosystem.py
85 lines (51 loc) · 1.53 KB
/
ecosystem.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import pygame
import random
pygame.init()
display_width = 1280
display_height = 960
black = ( 0, 0, 0)
white = (255,255,255)
red = (255, 0, 0)
green = ( 0,255, 0)
blue = ( 0, 0,225)
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption("Neuro-Evolution")
clock = pygame.time.Clock()
plant_sprite = pygame.image.load("plant.png")
herbivore_sprite = pygame.image.load("herbivore.png")
carnivore_sprite = pygame.image.load("carnivore.png")
def position():
x = random.randint(0, display_width)
y = random.randint(0, display_height)
return (x, y)
def spawn_plant():
gameDisplay.blit(plant_sprite, position())
def spawn_herbivore():
gameDisplay.blit(herbivore_sprite, position())
def spawn_carnivore():
gameDisplay.blit(carnivore_sprite, position())
def run():
gameExit = False
while not gameExit:
for event in pygame.event.get():
print(event)
if event.type == pygame.QUIT:
gameExit = True
gameDisplay.fill(white)
spawn_plant()
spawn_herbivore()
spawn_carnivore()
pygame.display.update()
clock.tick(30)
run()
pygame.quit()
quit()
"""
for n in range(0,16):
if n%1 == 0:
spawn_plant()
if n%4 == 0:
spawn_herbivore()
if n%8 == 0:
spawn_carnivore()
"""