czerwone strzałki
This commit is contained in:
parent
5cb1a13327
commit
0ab10deda5
@ -73,7 +73,7 @@ class AI:
|
|||||||
self.saper.move()
|
self.saper.move()
|
||||||
|
|
||||||
def way_controls(self):
|
def way_controls(self):
|
||||||
if len(self.the_way)>0:
|
if type(self.the_way) is list and len(self.the_way)>0:
|
||||||
way = self.the_way.pop(0)
|
way = self.the_way.pop(0)
|
||||||
if way=="move":
|
if way=="move":
|
||||||
self.saper.move()
|
self.saper.move()
|
||||||
|
@ -171,7 +171,7 @@ class BFS:
|
|||||||
|
|
||||||
|
|
||||||
neighbours_list_of_our_node = self.successor(tmp_node_position) # lista możliwych akcij
|
neighbours_list_of_our_node = self.successor(tmp_node_position) # lista możliwych akcij
|
||||||
#print(neighbours_list_of_our_node)
|
print(neighbours_list_of_our_node)
|
||||||
|
|
||||||
for node_ in neighbours_list_of_our_node:
|
for node_ in neighbours_list_of_our_node:
|
||||||
# jesli pozucja wezla nie jest w fringe i nie jest w visited
|
# jesli pozucja wezla nie jest w fringe i nie jest w visited
|
||||||
@ -179,4 +179,4 @@ class BFS:
|
|||||||
counter += 1
|
counter += 1
|
||||||
x = node.Node(tmp_node, node_[0], node_[1]) # action
|
x = node.Node(tmp_node, node_[0], node_[1]) # action
|
||||||
heapq.heappush(fringe, (counter, x))
|
heapq.heappush(fringe, (counter, x))
|
||||||
self.window.draw_search([self.agent.position_x, self.agent.position_y], [node_[1][0], node_[1][1]])
|
self.window.draw_search([self.agent.position_x, self.agent.position_y], [node_[1][0], node_[1][1]], self.agent.current_map.tile_size, self.agent.current_map, self.agent)
|
||||||
|
@ -111,11 +111,11 @@ class Map:
|
|||||||
#od liczby zależy jaki teren, np. 0 - piasek
|
#od liczby zależy jaki teren, np. 0 - piasek
|
||||||
rng = randrange(10)
|
rng = randrange(10)
|
||||||
if ok and rng==0 and not (i<2 and j<3):
|
if ok and rng==0 and not (i<2 and j<3):
|
||||||
matrix[i].append(10)
|
matrix[i].append(10) #kamień
|
||||||
elif ok and rng>8 and not (i<2 and j<3):
|
elif ok and rng>8 and not (i<2 and j<3):
|
||||||
matrix[i].append(5)
|
matrix[i].append(5) #trawa
|
||||||
elif ok and rng<2 and not (i<2 and j<3):
|
elif ok and rng<2 and not (i<2 and j<3):
|
||||||
matrix[i].append(0)
|
matrix[i].append(0) #piasek
|
||||||
rand_rotate = 0#randrange(4)*90
|
rand_rotate = 0#randrange(4)*90
|
||||||
if rand_rotate==0 and j+3<self.tiles_x and not (i==0 or i==self.tiles_y-1 or j==0 or j==self.tiles_x-1):
|
if rand_rotate==0 and j+3<self.tiles_x and not (i==0 or i==self.tiles_y-1 or j==0 or j==self.tiles_x-1):
|
||||||
cliff = Cliff(j,i,self.tile_size, rand_rotate, type=2)
|
cliff = Cliff(j,i,self.tile_size, rand_rotate, type=2)
|
||||||
|
@ -45,13 +45,16 @@ class Window:
|
|||||||
if self.paused:
|
if self.paused:
|
||||||
self.window.blit(self.pause_menu,(0,0))
|
self.window.blit(self.pause_menu,(0,0))
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
#self.search.fill(pygame.Color(0,0,0,0))
|
|
||||||
|
|
||||||
def draw_search(self, pos1:list=[0,0], pos2:list=[0,0], tile_size:int=64):
|
def draw_search(self, pos1:list=[0,0], pos2:list=[0,0], tile_size:int=64, map=None, saper=None):
|
||||||
#self.search.fill(pygame.Color(0,0,0,0))
|
map.draw_tiles()
|
||||||
pos1 = [pos1[0]*tile_size, pos1[1]*tile_size]
|
map.draw_objects()
|
||||||
pos2 = [pos2[0]*tile_size, pos2[1]*tile_size]
|
saper.draw(self.window, 0.1)
|
||||||
|
self.window.blit(self.pause_menu,(0,0))
|
||||||
|
self.search = pygame.Surface((self.width, self.height), flags=pygame.SRCALPHA)
|
||||||
|
pos1 = [pos1[0]*tile_size+(tile_size/2), pos1[1]*tile_size+(tile_size/2)]
|
||||||
|
pos2 = [pos2[0]*tile_size+(tile_size/2), pos2[1]*tile_size+(tile_size/2)]
|
||||||
pygame.draw.line(self.search, pygame.Color(255,0,0), pos1, pos2, 5)
|
pygame.draw.line(self.search, pygame.Color(255,0,0), pos1, pos2, 5)
|
||||||
pygame.display.flip()
|
pygame.draw.circle(self.search, pygame.Color(255,0,0), pos2, 10)
|
||||||
self.search.blit(self.window, (0,0))
|
self.window.blit(self.search, (0,0))
|
||||||
pygame.display.update()
|
pygame.display.update()
|
Loading…
Reference in New Issue
Block a user