AI_PRO/FindPath.py

30 lines
1.3 KiB
Python

from constants import *
def whichStateLookingFor(tractor, TillageUnit):
searching_field = "none"
if tractor.header and tractor.hitch == "Crop Trailer":
searching_field = "toCut"
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Nothing":
searching_field = "toPlow"
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Water":
searching_field = "toWater"
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Seeds":
searching_field = "toSeed"
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Fertilizer":
searching_field = "toFertilize"
return searching_field
def nearestLookingField(board, 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 searching_field == field.state:
end_horizontal_index = field.horizontal_index / TILE_SIZE
end_vertical_index = field.vertical_index / TILE_SIZE
return end_horizontal_index, end_vertical_index
return end_horizontal_index, end_vertical_index