+ if not world_data["look_mode"]:
+ world_data["look_mode"] = True
+ else:
+ world_data["look_mode"] = False
+ world_data["map_center"] = world_data["avatar_position"]
+
+
+def command_sender(string):
+ def command_send():
+ io["file_out"].write(string + "\n")
+ io["file_out"].flush()
+ return command_send
+
+
+def command_looker(string):
+ def command_look():
+ if string == "west" \
+ and world_data["map_center"][1] > 0:
+ world_data["map_center"][1] -= 1
+ elif string == "east" \
+ and world_data["map_center"][1] < world_data["map_size"] - 1:
+ world_data["map_center"][1] += 1
+ else:
+ y_unevenness = world_data["map_center"][0] % 2
+ y_evenness = int(not(y_unevenness))
+ if string[6:] == "west" and \
+ world_data["map_center"][1] > -y_unevenness:
+ if string[:5] == "north" and world_data["map_center"][0] > 0:
+ world_data["map_center"][0] -= 1
+ world_data["map_center"][1] -= y_evenness
+ if string[:5] == "south" and world_data["map_center"][0] \
+ < world_data["map_size"] - 1:
+ world_data["map_center"][0] += 1
+ world_data["map_center"][1] -= y_evenness
+ elif string[6:] == "east" and world_data["map_center"][1] \
+ < world_data["map_size"] - y_unevenness:
+ if string[:5] == "north" and world_data["map_center"][0] > 0:
+ world_data["map_center"][0] -= 1
+ world_data["map_center"][1] += y_unevenness
+ if string[:5] == "south" and world_data["map_center"][0] \
+ < world_data["map_size"] - 1:
+ world_data["map_center"][0] += 1
+ world_data["map_center"][1] += y_unevenness
+ return command_look