nowe2
This commit is contained in:
commit
ce28016282
8
env.py
Normal file → Executable file
8
env.py
Normal file → Executable file
@ -109,7 +109,7 @@ def look_at_plats(field, location):
|
||||
def send_stats(field, location):
|
||||
x = location[0]
|
||||
y = location[1]
|
||||
stats = field[x][y]
|
||||
stats = field[x][y].get_stats()
|
||||
str_stats = str(stats["ttl"]) + " " + str(stats["is_alive"]) + " " + str(stats["hydration"]) + " " \
|
||||
+ str(stats["soil_level"]) + " " + str(stats["ready"]) + "\n"
|
||||
return str_stats
|
||||
@ -141,9 +141,9 @@ if __name__ == "__main__":
|
||||
for i in plants:
|
||||
plants_str += (" " + str(i[0]) + " " + str(i[1]))
|
||||
writer.write((plants_str + "\n").encode())
|
||||
elif message[0] == "get_stats":
|
||||
x = message[1]
|
||||
y = message[2]
|
||||
elif message[0] == "stats":
|
||||
x = int(message[1])
|
||||
y = int(message[2])
|
||||
stats = send_stats(field, (x, y)).encode()
|
||||
writer.write(stats)
|
||||
|
||||
|
6
tractor.py
Normal file → Executable file
6
tractor.py
Normal file → Executable file
@ -40,10 +40,10 @@ class Tractor(TreeClass):
|
||||
reader, writer = await asyncio.open_connection('127.0.0.1', 8887)
|
||||
writer.write(("look_at_plants " + str(location[0]) + " " + str(location[1]) + "\n").encode())
|
||||
xd = await reader.readline()
|
||||
xd = xd.split()
|
||||
l = len(xd)
|
||||
xd = xd.decode().split()
|
||||
ln = int(len(xd) /2)
|
||||
xd2 = []
|
||||
for i in range(l):
|
||||
for i in range(ln):
|
||||
xd2.append((int(xd[2*i]), int(xd[2*i+1])))
|
||||
|
||||
time.sleep(self.sleep_time)
|
||||
|
Loading…
Reference in New Issue
Block a user