42 lines
1014 B
Python
42 lines
1014 B
Python
import pygame
|
|
|
|
from Engine.Game import Game
|
|
from Engine.Point import Point
|
|
from Engine.Population import Population
|
|
|
|
WIN = pygame.display.set_mode((800, 800))
|
|
FPS = 60
|
|
|
|
def getPopulation(game):
|
|
bombList = []
|
|
# bombList.append(Point(0,0))
|
|
for x in game.board.bombMap:
|
|
bombList.append(x)
|
|
return bombList
|
|
|
|
def main():
|
|
run = True
|
|
clock = pygame.time.Clock()
|
|
game = Game(WIN)
|
|
population = Population(game.board, game.dTree)
|
|
points = population.geneticAlgorithm(getPopulation(game), popSize=100, eliteSize=20, mutationRate=0.01, generations=500)
|
|
|
|
while run:
|
|
pygame.init()
|
|
clock.tick(FPS)
|
|
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
run = False
|
|
|
|
pygame.time.delay(200)
|
|
if game.finalState():
|
|
break
|
|
if len(game.getPath()) == 0:
|
|
path = game.getBombPath(points.pop(0))
|
|
game.savePath(path)
|
|
game.moveToNext()
|
|
game.update()
|
|
|
|
|
|
main() |