I am using the following python code snippet in an attempt to scan for enemy shipyards; at some point it’ll be used for other cell-by-cell preprocessing before the turn-based portion of the code commences, as well. This code is called after
game = hlt.Game() and
game.ready("nightMiner"), but before anything else:
def scan_for_enemy_shipyards(game): # identify map data for Const storage and later retrieval glo.Misc.loggit('preprocessing', 'info', "Scanning for enemy shipyards") for x in range(0, game.game_map.width): glo.Misc.loggit('preprocessing', 'debug', " - scanning column: " + str(x)) for y in range(0, game.game_map.height): # check each map cell glo.Misc.loggit('preprocessing', 'debug', " - scanning cell: " + str(Position(x, y))) if game.game_map[Position(x, y)].has_structure: glo.Misc.loggit('preprocessing', 'debug', " -* _HAS_ structure") # NOTE: this only verifies that it's not our shipyard, as no drops would exist yet if game.game_map[Position(x, y)].structure_type is not None and \ game.me.shipyard.position != Position(x, y): # there is a structure that is not ours glo.Misc.loggit('preprocessing', 'debug', "Enemy shipyard at: " + str(Position(x, y))) glo.Const.Enemy_Drops.append(Position(x, y)) return
Unfortunately, I’m not even able to find any information regarding a structure on any of the positions in the entire map. I was wondering if this may be due to the fact that the
game_map has not been set up at this point, and if so, what point I will need to tuck it after, or if it’s something else, maybe not being able to use a newly created
Position() reference to index the
game_map, or something of the sort…
Also, I think that I scanned all of the relevant areas in the hlt.* library, but if there is some easier way to obtain a list of the shipyards, I’d really be interested in hearing about it.
Thanks in advance & happy coding!