forked from s452751/AI_PRO
graphserach v0.6
This commit is contained in:
parent
bb5eb51b1c
commit
430ca8dc05
14
FindPath.py
14
FindPath.py
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user