-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_simulation.py
46 lines (36 loc) · 1.24 KB
/
run_simulation.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
import os
import numpy as np
import pygame
import params as p
from algorithm import update_board
def main():
# Load images
smiley = pygame.image.load(os.path.join('img/smiley.png'))
smiley = pygame.transform.scale(smiley, (p.img_width, p.img_height))
skull = pygame.image.load(os.path.join('img/skull.png'))
skull = pygame.transform.scale(skull, (p.img_width, p.img_height))
# Initialize Pygame
pygame.init()
# Set caption to the game
pygame.display.set_caption('Game of Life')
# Create a screen
screen = pygame.display.set_mode((p.screen_width, p.screen_height))
screen.fill(p.screen_bg)
pygame.display.flip()
board_config = np.zeros((p.x_cells, p.y_cells))
running = True
while running:
print(p.step_counter)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Update board positions
board_config, img_positions = update_board(board_config, p)
screen.fill(p.screen_bg)
for sm_pos in img_positions:
screen.blit(skull, sm_pos)
pygame.display.flip()
pygame.time.wait(p.flip_time)
p.step_counter += 1
if __name__ == '__main__':
main()