Env - > look_at_plants (v2)
This commit is contained in:
parent
875d3e4473
commit
7994cc70ae
96
env.py
96
env.py
@ -93,52 +93,56 @@ def try_move(field, tractor):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def look_at_plats(field, location):
|
def look_at_plats(field, location):
|
||||||
wsp = [(location[0] + 1, location[1]), (location[0] - 1, location[1]), (location[0], location[1] - 1), (location[0], location[1] + 1)]
|
wsp = [
|
||||||
|
(location[0] + 1, location[1]),
|
||||||
|
(location[0] - 1, location[1]),
|
||||||
|
(location[0], location[1] - 1),
|
||||||
|
(location[0], location[1] + 1)
|
||||||
|
]
|
||||||
|
|
||||||
return wsp
|
return wsp
|
||||||
|
|
||||||
# if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#
|
|
||||||
# field = initialize_field()
|
field = initialize_field()
|
||||||
# tractor = Trac('N', (0,0))
|
tractor = Trac('N', (0,0))
|
||||||
#
|
|
||||||
# async def handle_echo(reader, writer):
|
async def handle_echo(reader, writer):
|
||||||
# data = await reader.readline()
|
data = await reader.readline()
|
||||||
# message = data.decode().split()
|
message = data.decode().split()
|
||||||
#
|
|
||||||
# if message[0] == "rotate":
|
if message[0] == "rotate":
|
||||||
# tractor.set_rotation(message[1])
|
tractor.set_rotation(message[1])
|
||||||
# writer.write("OK\n".encode())
|
writer.write("OK\n".encode())
|
||||||
# elif message[0] == "try":
|
elif message[0] == "try":
|
||||||
# if try_move(field, tractor):
|
if try_move(field, tractor):
|
||||||
# writer.write("OK\n".encode())
|
writer.write("OK\n".encode())
|
||||||
# else:
|
else:
|
||||||
# writer.write("FAIL\n".encode())
|
writer.write("FAIL\n".encode())
|
||||||
# elif message[0] == "move":
|
elif message[0] == "move":
|
||||||
# tractor.move()
|
tractor.move()
|
||||||
# writer.write(("OK\n").encode())
|
writer.write(("OK\n").encode())
|
||||||
# elif message[0] == "look":
|
elif message[0] == "look":
|
||||||
# tractor.move()
|
tractor.move()
|
||||||
# writer.write(("OK\n").encode())
|
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())
|
||||||
# # print(tractor.get_position().get_y())
|
# print(tractor.get_position().get_y())
|
||||||
# # print(tractor.get_rotation())
|
# print(tractor.get_rotation())
|
||||||
# update_state(field)
|
update_state(field)
|
||||||
# await writer.drain()
|
await writer.drain()
|
||||||
#
|
|
||||||
# writer.close()
|
writer.close()
|
||||||
#
|
|
||||||
# async def main():
|
async def main():
|
||||||
# server = await asyncio.start_server(
|
server = await asyncio.start_server(
|
||||||
# handle_echo, '127.0.0.1', 8888)
|
handle_echo, '127.0.0.1', 8888)
|
||||||
#
|
|
||||||
# addr = server.sockets[0].getsockname()
|
addr = server.sockets[0].getsockname()
|
||||||
#
|
|
||||||
# async with server:
|
async with server:
|
||||||
# await server.serve_forever()
|
await server.serve_forever()
|
||||||
#
|
|
||||||
# asyncio.run(main())
|
asyncio.run(main())
|
||||||
print(look_at_plats([], (5, 5)))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user