AI_PRO/TractorAction.py

46 lines
1.6 KiB
Python
Raw Normal View History

2021-03-29 20:51:47 +02:00
from TractorLoad import TillageUnit
2021-03-29 13:06:57 +02:00
2021-04-13 20:29:06 +02:00
def changeFieldState(field, tractor):
2021-03-29 14:33:16 +02:00
if tractor.header and tractor.hitch == "Crop Trailer" and field.state == "toCut":
2021-03-29 13:06:57 +02:00
return "toPlow"
2021-03-29 21:40:55 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Nothing" and field.state == "toPlow":
2021-03-29 13:06:57 +02:00
return "toWater"
2021-03-29 19:15:36 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Water" and field.state == "toWater":
2021-03-29 21:40:55 +02:00
return "toSeed"
2021-03-29 13:06:57 +02:00
2021-03-29 21:40:55 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Seeds" and field.state == "toSeed":
2021-03-29 13:06:57 +02:00
return "toFertilize"
2021-03-29 19:15:36 +02:00
2021-03-29 21:40:55 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Fertilizer" and field.state == "toFertilize":
return "toCut"
2021-03-29 19:15:36 +02:00
2021-03-29 21:59:19 +02:00
2021-04-13 20:29:06 +02:00
def autoToolsChange(tractor, tillageUnit, toolCounter):
2021-03-30 00:54:29 +02:00
if tractor.horizontal_index == 0 and tractor.vertical_index == 0:
toolCounter = (toolCounter + 1) % 5
tractor, tillageUnit = chooseToolset(tractor, tillageUnit, toolCounter)
tractor.fill_tank()
return tractor, tillageUnit, toolCounter
2021-03-29 19:15:36 +02:00
def chooseToolset(tractor, tillageUnit, set):
if set == 0:
tractor.hitch = tillageUnit
tractor.hitch.load = "Nothing"
if set == 1:
tractor.hitch = tillageUnit
2021-03-29 21:59:19 +02:00
tractor.hitch.load = "Water"
2021-03-29 19:15:36 +02:00
if set == 2:
tractor.hitch = tillageUnit
tractor.hitch.load = "Seeds"
if set == 3:
tractor.hitch = tillageUnit
2021-03-29 21:59:19 +02:00
tractor.hitch.load = "Fertilizer"
2021-03-29 19:15:36 +02:00
if set == 4:
tractor.header = True
tractor.hitch = "Crop Trailer"
return tractor, tillageUnit