2021-04-13 21:39:04 +02:00
|
|
|
from constants import *
|
|
|
|
|
|
|
|
def whichStateLookingFor(tractor, TillageUnit):
|
2021-05-19 04:01:26 +02:00
|
|
|
searching_field = "none"
|
2021-04-13 21:39:04 +02:00
|
|
|
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
|
|
|
|
|
2021-04-14 14:34:57 +02:00
|
|
|
|
2021-04-13 21:39:04 +02:00
|
|
|
def nearestLookingField(board, tractor, TillageUnit):
|
2021-04-13 21:50:08 +02:00
|
|
|
end_horizontal_index = 0
|
|
|
|
end_vertical_index = 0
|
|
|
|
searching_field = whichStateLookingFor(tractor, TillageUnit)
|
2021-05-19 04:01:26 +02:00
|
|
|
for i in range(0, int(HORIZONTAL_TILES_NUMBER)):
|
|
|
|
for j in range(0, int(VERTICAL_TILES_NUMBER)):
|
2021-04-13 21:39:04 +02:00
|
|
|
field = board[i][j]
|
2021-04-13 21:50:08 +02:00
|
|
|
if searching_field == field.state:
|
2021-05-19 04:01:26 +02:00
|
|
|
end_horizontal_index = field.horizontal_index / TILE_SIZE
|
|
|
|
end_vertical_index = field.vertical_index / TILE_SIZE
|
|
|
|
return end_horizontal_index, end_vertical_index
|
2021-04-14 14:34:57 +02:00
|
|
|
|
2021-05-19 04:01:26 +02:00
|
|
|
return end_horizontal_index, end_vertical_index
|