diff --git a/env.py b/env.py index e781fb1..c4ca3ef 100755 --- a/env.py +++ b/env.py @@ -93,52 +93,52 @@ def try_move(field, tractor): return False def look_at_plats(field, location): - wsp = [] + wsp = [(location[0] + 1, location[1]), (location[0] - 1, location[1]), (location[0], location[1] - 1), (location[0], location[1] + 1)] + return wsp - - -if __name__ == "__main__": - - field = initialize_field() - tractor = Trac('N', (0,0)) - - async def handle_echo(reader, writer): - data = await reader.readline() - message = data.decode().split() - - if message[0] == "rotate": - tractor.set_rotation(message[1]) - writer.write("OK\n".encode()) - elif message[0] == "try": - if try_move(field, tractor): - writer.write("OK\n".encode()) - else: - writer.write("FAIL\n".encode()) - 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()) - # print(tractor.get_position().get_y()) - # print(tractor.get_rotation()) - update_state(field) - await writer.drain() - - writer.close() - - async def main(): - server = await asyncio.start_server( - handle_echo, '127.0.0.1', 8888) - - addr = server.sockets[0].getsockname() - - async with server: - await server.serve_forever() - - asyncio.run(main()) +# if __name__ == "__main__": +# +# field = initialize_field() +# tractor = Trac('N', (0,0)) +# +# async def handle_echo(reader, writer): +# data = await reader.readline() +# message = data.decode().split() +# +# if message[0] == "rotate": +# tractor.set_rotation(message[1]) +# writer.write("OK\n".encode()) +# elif message[0] == "try": +# if try_move(field, tractor): +# writer.write("OK\n".encode()) +# else: +# writer.write("FAIL\n".encode()) +# 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()) +# # print(tractor.get_position().get_y()) +# # print(tractor.get_rotation()) +# update_state(field) +# await writer.drain() +# +# writer.close() +# +# async def main(): +# server = await asyncio.start_server( +# handle_echo, '127.0.0.1', 8888) +# +# addr = server.sockets[0].getsockname() +# +# async with server: +# await server.serve_forever() +# +# asyncio.run(main()) +print(look_at_plats([], (5, 5))) \ No newline at end of file