MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / get_map

Function get_map

battlecode-manager/battlecode_cli.py:168–205  ·  view source on GitHub ↗

Read a map of a given name, and return a GameMap.

(map_name)

Source from the content-addressed store, hash-verified

166
167
168def get_map(map_name):
169 '''
170 Read a map of a given name, and return a GameMap.
171 '''
172
173 try:
174 with open(map_name) as f:
175 contents = f.read()
176 print("Loading map " + map_name)
177 if map_name.endswith('.bc18map'):
178 return bc.GameMap.from_json(contents)
179 elif map_name.endswith('.bc18t'):
180 return bc.GameMap.parse_text_map(contents)
181 except Exception as e:
182 if 'testmap' not in map_name:
183 print('failed to load map:', e)
184 try:
185 with open('/player/' + map_name) as f:
186 contents = f.read()
187 print("Loading map " + map_name)
188 if map_name.endswith('.bc18map'):
189 return bc.GameMap.from_json(contents)
190 elif map_name.endswith('.bc18t'):
191 return bc.GameMap.parse_text_map(contents)
192 except Exception as e:
193 if 'testmap' not in map_name:
194 print('failed to load map:', e)
195 try:
196 with open('/player/' + map_name) as f:
197 contents = f.read()
198 print("Loading map " + map_name)
199 if map_name.endswith('.bc18map'):
200 return bc.GameMap.from_json(contents)
201 elif map_name.endswith('.bc18t'):
202 return bc.GameMap.parse_text_map(contents)
203 except Exception as e:
204 print("Loading test map...")
205 return bc.GameMap.test_map()
206
207def create_game(args):
208 '''

Callers

nothing calls this directly

Calls 3

readMethod · 0.80
parse_text_mapMethod · 0.80
test_mapMethod · 0.80

Tested by

no test coverage detected