Route_planning_bfs #2

Merged
s481894 merged 12 commits from Route_planning_bfs into master 2024-04-20 14:51:35 +02:00
5 changed files with 7 additions and 6 deletions
Showing only changes of commit f10a60063d - Show all commits

View File

@ -1,5 +1,6 @@
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.field import fieldX, fieldY
import pygame
import time
@ -108,13 +109,13 @@ class Tractor:
#sprawdza czy mozna sie dalej poruszyc, czy nie wyjdziemy poza mape - do funkcji succ w bfs
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"
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"
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"
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"
else:
return False

View File

@ -20,7 +20,7 @@ def main():
pygame.display.update()
#getting coordinates of a certain tile - test:
tile_index=30
tile_index=399
tile_x, tile_y = get_tile_coordinates(tile_index)
if tile_x is not None and tile_y is not None:
print(f"Coordinates of tile {tile_index} are: ({tile_x}, {tile_y})")
@ -54,7 +54,7 @@ def main():
tractor.rect.y += fieldY
tractor.draw_tractor(WIN)
time.sleep(1)
if moves != None:
if moves != False:
do_actions(tractor, WIN, moves)
tractor.work_on_field(tile1, d1, p1)