Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_map(env, map_size, goal_handle, handles, rnd):
# random message
font = FontProvider('data/font_8x8/basic.txt')
n_msg = random.randint(1, 4)
messages = []
for i in range(n_msg):
length = random.randint(2, 9)
tmp = []
for j in range(length):
tmp.append(random.randint(0x20, 0x7E))
messages.append(tmp)
center_x, center_y = map_size // 2, map_size // 2
# create maze: left pos, width, height
radius = 90
pos_list = create_maze([center_x - radius, center_y - radius], radius + 1, 15, 2, font_area=[radius * 2 - 28, radius * 2 - 28])
# pos_list = create_naive_maze([center_x - radius, center_y - radius], radius + 1, 15, 2, font_area=[radius * 2 - 28, radius * 2 - 28])
env.add_walls(method="custom", pos=pos_list)
def generate_map(env, map_size, goal_handle, handles):
# random message
font = FontProvider('data/font_8x8/basic.txt')
n_msg = random.randint(1, 4)
messages = []
for i in range(n_msg):
length = random.randint(2, 9)
tmp = []
for j in range(length):
tmp.append(random.randint(0x20, 0x7E))
messages.append(tmp)
center_x, center_y = map_size // 2, map_size // 2
# create maze: left pos, width, height
radius = 90
pos_list = create_maze([center_x - radius, center_y - radius], radius + 1, 15, 2, font_area=[radius * 2 - 28, radius * 2 - 28])
env.add_walls(method="custom", pos=pos_list)
def __init__(self, path="data/arrange_model", messages=None, mode=1):
# some parameter
map_size = 250
eps = 0.15
# init the game
env = magent.GridWorld(load_config(map_size))
font = FontProvider('data/font_8x8/basic.txt')
handles = env.get_handles()
food_handle, handles = handles[0], handles[1:]
models = []
models.append(DeepQNetwork(env, handles[0], 'arrange', use_conv=True))
# load model
models[0].load(path, 10)
# init environment
env.reset()
generate_map(mode, env, map_size, food_handle, handles, messages, font)
# save to member variable
self.env = env
self.food_handle = food_handle