Route_planning_bfs #2
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
from crop_protection_product import CropProtectionProduct
|
from crop_protection_product import CropProtectionProduct
|
||||||
from area.constants import TILE_SIZE, DIRECTION_EAST, DIRECTION_SOUTH, DIRECTION_WEST, DIRECTION_NORTH, FIELD_WIDTH, FIELD_HEIGHT, WIDTH, HEIGHT
|
from area.constants import TILE_SIZE, DIRECTION_EAST, DIRECTION_SOUTH, DIRECTION_WEST, DIRECTION_NORTH, FIELD_WIDTH, FIELD_HEIGHT, WIDTH, HEIGHT
|
||||||
|
from area.field import fieldX, fieldY
|
||||||
import pygame
|
import pygame
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -108,13 +109,13 @@ class Tractor:
|
|||||||
|
|
||||||
#sprawdza czy mozna sie dalej poruszyc, czy nie wyjdziemy poza mape - do funkcji succ w bfs
|
#sprawdza czy mozna sie dalej poruszyc, czy nie wyjdziemy poza mape - do funkcji succ w bfs
|
||||||
def can_it_move_node(node):
|
def can_it_move_node(node):
|
||||||
if node.get_direction() == DIRECTION_EAST and node.get_x() + TILE_SIZE < FIELD_WIDTH:
|
if node.get_direction() == DIRECTION_EAST and node.get_x() + TILE_SIZE < 830: #last tile on the west has y:797
|
||||||
return "move east"
|
return "move east"
|
||||||
elif node.get_direction() == DIRECTION_WEST and node.get_x() - TILE_SIZE >=0:
|
elif node.get_direction() == DIRECTION_WEST and node.get_x() - TILE_SIZE >=fieldX:
|
||||||
return "move west"
|
return "move west"
|
||||||
elif node.get_direction() == DIRECTION_NORTH and node.get_y() - TILE_SIZE >=0:
|
elif node.get_direction() == DIRECTION_NORTH and node.get_y() - TILE_SIZE >=fieldY:
|
||||||
return "move north"
|
return "move north"
|
||||||
elif node.get_direction() == DIRECTION_SOUTH and node.get_y() + TILE_SIZE < FIELD_HEIGHT:
|
elif node.get_direction() == DIRECTION_SOUTH and node.get_y() + TILE_SIZE < 760: #last tile on the south has y:727
|
||||||
return "move south"
|
return "move south"
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -20,7 +20,7 @@ def main():
|
|||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
#getting coordinates of a certain tile - test:
|
#getting coordinates of a certain tile - test:
|
||||||
tile_index=30
|
tile_index=399
|
||||||
tile_x, tile_y = get_tile_coordinates(tile_index)
|
tile_x, tile_y = get_tile_coordinates(tile_index)
|
||||||
if tile_x is not None and tile_y is not None:
|
if tile_x is not None and tile_y is not None:
|
||||||
print(f"Coordinates of tile {tile_index} are: ({tile_x}, {tile_y})")
|
print(f"Coordinates of tile {tile_index} are: ({tile_x}, {tile_y})")
|
||||||
@ -54,7 +54,7 @@ def main():
|
|||||||
tractor.rect.y += fieldY
|
tractor.rect.y += fieldY
|
||||||
tractor.draw_tractor(WIN)
|
tractor.draw_tractor(WIN)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if moves != None:
|
if moves != False:
|
||||||
do_actions(tractor, WIN, moves)
|
do_actions(tractor, WIN, moves)
|
||||||
|
|
||||||
tractor.work_on_field(tile1, d1, p1)
|
tractor.work_on_field(tile1, d1, p1)
|
||||||
|
Loading…
Reference in New Issue
Block a user