Zmiany env i tractor

This commit is contained in:
Pikusia 2019-05-31 14:24:37 +02:00
parent a369f12928
commit 29632d3693
2 changed files with 18 additions and 1 deletions

11
env.py
View File

@ -92,6 +92,11 @@ def try_move(field, tractor):
return True return True
return False return False
def look_at_plats(field, location):
wsp = []
if __name__ == "__main__": if __name__ == "__main__":
@ -110,9 +115,13 @@ if __name__ == "__main__":
writer.write("OK\n".encode()) writer.write("OK\n".encode())
else: else:
writer.write("FAIL\n".encode()) writer.write("FAIL\n".encode())
else: elif message[0] == "move":
tractor.move() tractor.move()
writer.write(("OK\n").encode()) writer.write(("OK\n").encode())
elif message[0] == "look":
tractor.move()
writer.write(("OK\n").encode())
print_field(field, tractor) print_field(field, tractor)
# print(tractor.get_position().get_x()) # print(tractor.get_position().get_x())

View File

@ -26,6 +26,14 @@ class Tractor:
time.sleep(self.sleep_time) time.sleep(self.sleep_time)
writer.close() writer.close()
async def look_at_plants(self):
reader, writer = await asyncio.open_connection('127.0.0.1', 8888)
writer.write(("rotate " + direction + "\n").encode())
await reader.readline()
time.sleep(self.sleep_time)
writer.close()
async def try_move(self): async def try_move(self):
reader, writer = await asyncio.open_connection('127.0.0.1', 8888) reader, writer = await asyncio.open_connection('127.0.0.1', 8888)
writer.write("try\n".encode()) writer.write("try\n".encode())