-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
42 lines (31 loc) · 978 Bytes
/
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
import pygame
import argparser
import lib
import ai.neatinterface.neatcore
pygame.init()
if __name__ == "__main__":
args = argparser.get_args()
# pygame initialization
pygame.init()
# initialize properly and make links make them as common resources
# for other modules
# I admit this looks pretty hideous but python has no good way of
# handling singletons
lib.common.settings = settings = lib.Settings(args)
lib.common.display = display = lib.Display()
lib.common.clock = clock = lib.Clock()
lib.common.events = events = lib.Events()
# setting game mode
if args.ai == "neat":
lib.common.core = core = ai.neatinterface.neatcore.NeatCore()
else:
lib.common.core = core = lib.Core()
core.new_game()
# main loop
while True:
clock.tick()
core.update()
if core.game_over():
core.new_game()
continue
display.draw(core.get_surface())