Ejemplo n.º 1
0
def reg2msg():
    # ans=[[(game.mapHeight(),game.mapWidth())]]
    # ans.append([(i.getBoundsTop(),i.getBoundsBottom(),i.getBoundsLeft(),i.getBoundsRight(),i.isAccessible(),i.isHigherGround()) for i in game.getAllRegions()])
    ans = numpy.zeros([game.mapHeight() * 4, game.mapWidth() * 4])
    for i in range(game.mapHeight() * 4):
        for j in range(game.mapWidth() * 4):
            ans[i, j] = game.isWalkable([i, j])
    return ans
Ejemplo n.º 2
0
def init():
    global terrain, hground
    terrain = numpy.zeros([game.mapHeight() * 32, game.mapWidth() * 32])
    hground = numpy.zeros([game.mapHeight() * 32, game.mapWidth() * 32])
    for i in game.getAllRegions():
        terrain[i.getBoundsTop():i.getBoundsBottom(),
                i.getBoundsLeft():i.getBoundsRight()] = i.isAccessible()
        hground[i.getBoundsTop():i.getBoundsBottom(),
                i.getBoundsLeft():i.getBoundsRight()] = i.isHigherGround()
Ejemplo n.º 3
0
 def prepare(self):
     print('Map {} {}'.format(game.mapFileName(), game.mapHash()))
     shape = (game.mapWidth(), game.mapHeight())
     self.failed_tiles = []
     for y in range(shape[1]):
         for x in range(shape[0]):
             if not game.isBuildable(x, y):
                 continue
             try:
                 for wy in range(y * BWS, (y + 1) * BWS):
                     for wx in range(x * BWS, (x + 1) * BWS):
                         if not game.isWalkable(wx, wy):
                             raise NotWalkable
             except NotWalkable:
                 self.failed_tiles.append((x, y))
     with open('output.txt', 'a') as f:
         f.write('#########\n')
         f.write(
             json.dumps({
                 'hash': game.mapHash(),
                 'pathname': game.mapPathName(),
                 'filename': game.mapFileName(),
                 'failed_tiles': self.failed_tiles,
             }) + '\n')
     print(self.failed_tiles)
Ejemplo n.º 4
0
 def prepare(self):
     print(game.mapHeight() * 32, game.mapWidth() * 32)
     ans = numpy.zeros([game.mapHeight() * 32, game.mapWidth() * 32])
     for i in range(game.mapHeight() * 4):
         for j in range(game.mapWidth() * 4):
             ans[i * 8:i * 8 + 8, j * 8:j * 8 + 8] = game.isWalkable([i, j])
     #fig=plt.figure(figsize=(1,2))
     #fig.add_subplot(1,2,1)
     plt.imshow(ans * 255, cmap=plt.cm.gray)
     plt.show()
     ans = numpy.zeros([game.mapHeight() * 32, game.mapWidth() * 32])
     for r in game.getAllRegions():
         ans[r.getBoundsTop():r.getBoundsBottom(),
             r.getBoundsLeft():r.getBoundsRight()] = r.isHigherGround()
     #fig.add_subplot(1,2,2)
     plt.imshow(ans * 255, cmap=plt.cm.gray)
     plt.show()
Ejemplo n.º 5
0
 def can_control(self, unit, playerMe):
     if (unit.getType() in self.unitTypes and unit.getPlayer() == playerMe
             and unit.getPosition()[0] <= game.mapHeight() * 32
             and unit.getPosition()[1] <= game.mapWidth() * 32):
         return True
     return False