hydration
This commit is contained in:
parent
892c084bc1
commit
f2468f7555
@ -9,6 +9,6 @@ class Tomato(Plant):
|
|||||||
desoil_ratio = 0.8
|
desoil_ratio = 0.8
|
||||||
max_soil_lvl = 40
|
max_soil_lvl = 40
|
||||||
optimal_soil_ratio = 2
|
optimal_soil_ratio = 2
|
||||||
max_hydration_lvl = 40
|
max_hydration_lvl = 100
|
||||||
optimal_hydration_ratio = 2
|
optimal_hydration_ratio = 2
|
||||||
ready = 10
|
ready = 10
|
||||||
|
18
tractor.py
18
tractor.py
@ -2,6 +2,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
from Graph import Graph
|
from Graph import Graph
|
||||||
|
from Cucumber import Cucumber
|
||||||
|
from Tomato import Tomato
|
||||||
|
|
||||||
class Tractor:
|
class Tractor:
|
||||||
sleep_time = 0.1
|
sleep_time = 0.1
|
||||||
@ -26,7 +28,7 @@ class Tractor:
|
|||||||
time.sleep(self.sleep_time)
|
time.sleep(self.sleep_time)
|
||||||
writer.close()
|
writer.close()
|
||||||
|
|
||||||
async def look_at_plants(self):
|
async def look_at_plants(self, direction):
|
||||||
reader, writer = await asyncio.open_connection('127.0.0.1', 8888)
|
reader, writer = await asyncio.open_connection('127.0.0.1', 8888)
|
||||||
writer.write(("rotate " + direction + "\n").encode())
|
writer.write(("rotate " + direction + "\n").encode())
|
||||||
await reader.readline()
|
await reader.readline()
|
||||||
@ -187,6 +189,16 @@ class Tractor:
|
|||||||
|
|
||||||
await self.move_tractor(start_position)
|
await self.move_tractor(start_position)
|
||||||
|
|
||||||
|
def hydration(self, plant):
|
||||||
|
if type(plant) == Tomato:
|
||||||
|
if plant.hydration < 50:
|
||||||
|
plant.increase_hydration(plant.max_hydration_lvl - plant.hydration)
|
||||||
|
elif type(plant) == Cucumber:
|
||||||
|
if plant.hydration < 40:
|
||||||
|
plant.increase_hydration(plant.max_hydration_lvl - plant.hydration)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def service(self):
|
async def service(self):
|
||||||
"tutaj trzeba zapytac env z jakimi roslinami sie styka traktor i je obsłuzyc"
|
"tutaj trzeba zapytac env z jakimi roslinami sie styka traktor i je obsłuzyc"
|
||||||
pass
|
pass
|
||||||
@ -198,8 +210,8 @@ class Tractor:
|
|||||||
parsed_data = data.decode().split()
|
parsed_data = data.decode().split()
|
||||||
time.sleep(self.sleep_time)
|
time.sleep(self.sleep_time)
|
||||||
writer.close()
|
writer.close()
|
||||||
return {"ttl": parsed_data[0], "is_alive": parsed_data[1], "hydration": parsed_data[2], "soil_level": parsed_data[3],
|
return {"ttl": int(parsed_data[0]), "is_alive": int(parsed_data[1]), "hydration": int(parsed_data[2]), "soil_level": int(parsed_data[3]),
|
||||||
"ready": parsed_data[4]}
|
"ready": int(parsed_data[4])}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user