fixes after merge

This commit is contained in:
Konrad 2021-06-15 13:44:07 +02:00
parent 834b80454d
commit 95c5a01749
3 changed files with 32 additions and 70 deletions

6
.idea/.gitignore vendored
View File

@ -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/

54
Main.py
View File

@ -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()

42
main.py
View File

@ -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()