graphserach v0.6

This commit is contained in:
Łukasz 2021-04-13 21:50:08 +02:00
parent bb5eb51b1c
commit 430ca8dc05
2 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,7 @@
from constants import *
def whichStateLookingFor(tractor, TillageUnit):
searching_field = "toPlow"
if tractor.header and tractor.hitch == "Crop Trailer":
searching_field = "toCut"
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Nothing":
@ -14,19 +15,18 @@ def whichStateLookingFor(tractor, TillageUnit):
return searching_field
def nearestLookingField(board, tractor, TillageUnit):
x = whichStateLookingFor(tractor, TillageUnit)
end_horizontal_index = 0
end_vertical_index = 0
searching_field = whichStateLookingFor(tractor, TillageUnit)
for i in range(0, int(HORIZONTAL_TILES_NUMBER)):
for j in range(0, int(VERTICAL_TILES_NUMBER)):
field = board[i][j]
if x == field.state:
if searching_field == field.state:
end_horizontal_index = field.horizontal_index
end_vertical_index = field.vertical_index
break
else:
print('Wroc do bazy zmienic narzedzie')
end_horizontal_index = 0
end_vertical_index = 0
return(end_horizontal_index, end_vertical_index)
return end_horizontal_index, end_vertical_index
def graphsearch(tractor, board, TillageUnit):
start_horizontal_index = tractor.horizontal_index

View File

@ -58,5 +58,7 @@ while working:
clock.tick(FPS)
graphsearch(tractor, board, TillageUnit)
pygame.quit()
quit()