From 29632d36935edfad7bd81dfc2b8884cec9b6bb61 Mon Sep 17 00:00:00 2001 From: Pikusia Date: Fri, 31 May 2019 14:24:37 +0200 Subject: [PATCH] Zmiany env i tractor --- env.py | 11 ++++++++++- tractor.py | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/env.py b/env.py index 1896dd9..e781fb1 100755 --- a/env.py +++ b/env.py @@ -92,6 +92,11 @@ def try_move(field, tractor): return True return False +def look_at_plats(field, location): + wsp = [] + + + if __name__ == "__main__": @@ -110,9 +115,13 @@ if __name__ == "__main__": writer.write("OK\n".encode()) else: writer.write("FAIL\n".encode()) - else: + elif message[0] == "move": tractor.move() writer.write(("OK\n").encode()) + elif message[0] == "look": + tractor.move() + writer.write(("OK\n").encode()) + print_field(field, tractor) # print(tractor.get_position().get_x()) diff --git a/tractor.py b/tractor.py index db689b8..2e8835e 100755 --- a/tractor.py +++ b/tractor.py @@ -26,6 +26,14 @@ class Tractor: time.sleep(self.sleep_time) 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): reader, writer = await asyncio.open_connection('127.0.0.1', 8888) writer.write("try\n".encode())