diff --git a/.idea/.gitignore b/.idea/.gitignore index 9faa03f3..af21c367 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -2,11 +2,9 @@ /shelf/ /workspace.xml # Datasource local storage ignored files -<<<<<<< HEAD + /../../../../../../:\Users\Konrad\PycharmProjects\Projekt_AI-Automatyczny_saper\.idea/dataSources/ -======= -/../../../../../../:\Users\kratu\PycharmProjects\Projekt_AI-Automatyczny_saper\.idea/dataSources/ ->>>>>>> Bartek + /dataSources.local.xml # Editor-based HTTP Client requests /httpRequests/ diff --git a/Main.py b/Main.py index 2f4d481d..14ad3315 100644 --- a/Main.py +++ b/Main.py @@ -1,36 +1,42 @@ import pygame -from Board import draw_grid, redraw_window -from Constants import WIDTH, HEIGHT, ROWS - -from Agent import Agent - -WIN = pygame.display.set_mode((WIDTH, HEIGHT)) -start = [] +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(): - agent = Agent((255, 0, 0), 0, 0) - flag = True - + run = True clock = pygame.time.Clock() - while flag: + 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: - pygame.quit() + run = False - pygame.time.delay(50) - clock.tick(10) - draw_grid(WIN) - redraw_window(WIN, agent) - agent.move() - redraw_window(WIN, agent) + 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() +main() \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 14ad3315..00000000 --- a/main.py +++ /dev/null @@ -1,42 +0,0 @@ -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() \ No newline at end of file