Added missing files
This commit is contained in:
parent
0981dcb8cc
commit
d4cbe19f6e
@ -5,6 +5,7 @@ from DataModels.Dump import Dump
|
|||||||
from config import GRID_WIDTH, GRID_HEIGHT, DELAY
|
from config import GRID_WIDTH, GRID_HEIGHT, DELAY
|
||||||
from utilities import movement, check_moves
|
from utilities import movement, check_moves
|
||||||
from Traversal.DFS import DFS
|
from Traversal.DFS import DFS
|
||||||
|
from Traversal.BestFS import BestFS
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
class GC(Cell):
|
class GC(Cell):
|
||||||
@ -36,7 +37,7 @@ class GC(Cell):
|
|||||||
item.return_trash(self)
|
item.return_trash(self)
|
||||||
self.update_image()
|
self.update_image()
|
||||||
|
|
||||||
def get_moves_made(self):
|
def get_moves_count(self):
|
||||||
return self.moves_made
|
return self.moves_made
|
||||||
def find_houses(self,enviromnent, house_count):
|
def find_houses(self,enviromnent, house_count):
|
||||||
x = self.x
|
x = self.x
|
||||||
@ -48,6 +49,27 @@ class GC(Cell):
|
|||||||
self.moves.extend(result)
|
self.moves.extend(result)
|
||||||
self.moves.reverse()
|
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):
|
def make_actions_from_list(self,environment):
|
||||||
now = pygame.time.get_ticks()
|
now = pygame.time.get_ticks()
|
||||||
|
4
main.py
4
main.py
@ -96,6 +96,8 @@ while True:
|
|||||||
gc.collect(map_objects)
|
gc.collect(map_objects)
|
||||||
elif event.key == pygame.K_0:
|
elif event.key == pygame.K_0:
|
||||||
gc.find_houses(map_objects,house_count)
|
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)
|
gc.make_actions_from_list(map_objects)
|
||||||
pygame_sprites.update()
|
pygame_sprites.update()
|
||||||
@ -107,7 +109,7 @@ while True:
|
|||||||
GAME_WINDOW.blit(bg_rect, (0, WINDOW_HEIGHT-30))
|
GAME_WINDOW.blit(bg_rect, (0, WINDOW_HEIGHT-30))
|
||||||
|
|
||||||
font = pygame.font.SysFont("monospace", 15)
|
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))
|
GAME_WINDOW.blit(gc_moves, (10, WINDOW_HEIGHT - 25))
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
Loading…
Reference in New Issue
Block a user