collect trash from one kind

This commit is contained in:
Maciej Sobkowiak 2019-06-09 13:25:00 +02:00
parent 21b874d089
commit 51bc22088c

View File

@ -1,15 +1,21 @@
import pygame as pg
import numpy as np
import random
import itertools as it
import math
from UI.grid import Grid, Node
from Logic.Apath import a_path
class Window():
def __init__(self, grid: Grid,start: (int,int),end: (int,int),mode: int):
pg.init() # pylint: disable=no-member
# setup window
pg.display.set_caption('Inteligentna śmieciarka')
self.start = start
self.end = end
@ -35,7 +41,7 @@ class Window():
def obstacles(self, grid: Grid,option: int):
if option == 1:
for x in range(len(grid.table)*8):
for x in range(len(grid.table)*2):
grid.generate_trash(random.randint(1,len(grid.table)-1),random.randint(1,len(grid.table)-1))
elif option == 2:
for x in range (13):
@ -49,13 +55,22 @@ class Window():
grid.change_field(start[0], start[1], 1)
grid.change_field(end[0], end[1], 2)
#draw starting map
self.grid.draw_map(self.screen)
#list of trash to collect
to_collect = grid.get_trash_possition(5)
print("to collect len: ",len(to_collect))
#sort list of tuples to get minimum distance betwen all of them
#fajnie jakby sie udalo to zrobic wydajniej ale narazie niech bedzie tak
sorted(to_collect)
print(to_collect)
pg.init() # pylint: disable=no-member
# setup window
pg.display.set_caption('Inteligentna śmieciarka')
#draw starting map
self.grid.draw_map(self.screen)
for ind, x in enumerate(to_collect):
#copy table