Added missing files

This commit is contained in:
Magdalena Wilczynska 2019-05-13 10:29:34 +02:00
parent 0981dcb8cc
commit d4cbe19f6e
2 changed files with 26 additions and 2 deletions

View File

@ -5,6 +5,7 @@ from DataModels.Dump import Dump
from config import GRID_WIDTH, GRID_HEIGHT, DELAY
from utilities import movement, check_moves
from Traversal.DFS import DFS
from Traversal.BestFS import BestFS
import pygame
class GC(Cell):
@ -36,7 +37,7 @@ class GC(Cell):
item.return_trash(self)
self.update_image()
def get_moves_made(self):
def get_moves_count(self):
return self.moves_made
def find_houses(self,enviromnent, house_count):
x = self.x
@ -48,6 +49,27 @@ class GC(Cell):
self.moves.extend(result)
self.moves.reverse()
def find_houses_BestFS(self,enviromnent, house_count):
x = self.x
y = self.y
result = []
houses_list = []
a = 0
for row in enviromnent:
b = 0
for col in row:
print(col)
if (type(col) is House):
houses_list.append([col,[a,b]])
b += 1
a += 1
for home in range(house_count):
avalible_moves = check_moves(enviromnent, x,y)
[x,y],result = BestFS(enviromnent,avalible_moves,[[x,y]],houses_list)
self.moves.extend(result)
self.moves.reverse()
def make_actions_from_list(self,environment):
now = pygame.time.get_ticks()

View File

@ -96,6 +96,8 @@ while True:
gc.collect(map_objects)
elif event.key == pygame.K_0:
gc.find_houses(map_objects,house_count)
elif event.key == pygame.K_9:
gc.find_houses_BestFS(map_objects,house_count)
gc.make_actions_from_list(map_objects)
pygame_sprites.update()
@ -107,7 +109,7 @@ while True:
GAME_WINDOW.blit(bg_rect, (0, WINDOW_HEIGHT-30))
font = pygame.font.SysFont("monospace", 15)
gc_moves = font.render("Moves: " + str(gc.get_moves_made()), 1, (255,255,255))
gc_moves = font.render("Moves: " + str(gc.get_moves_count()), 1, (255,255,255))
GAME_WINDOW.blit(gc_moves, (10, WINDOW_HEIGHT - 25))
pygame.display.flip()