Example #1
0
 def get_ladder_positions(self):
     """Returns the set of ladder Points"""
     points = set()
     points.update(self._find_all(Element('LADDER')))
     points.update(self._find_all(Element('HERO_LADDER')))
     points.update(self._find_all(Element('OTHER_HERO_LADDER')))
     points.update(self._find_all(Element('ENEMY_LADDER')))
     return list(points)
Example #2
0
 def get_other_hero_positions(self):
     """ Return the list of points for other heroes."""
     points = set()
     points.update(self._find_all(Element("OTHER_HERO_LADDER")))
     points.update(self._find_all(Element("OTHER_HERO_LEFT")))
     points.update(self._find_all(Element("OTHER_HERO_RIGHT")))
     points.update(self._find_all(Element("OTHER_HERO_PIPE_LEFT")))
     points.update(self._find_all(Element("OTHER_HERO_PIPE_RIGHT")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_LEFT")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_RIGHT")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_LADDER")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_PIPE_LEFT")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_PIPE_RIGHT")))
     return list(points)
Example #3
0
 def _find_all(self, element: Element):
     """ Returns the list of points for the given element type."""
     _points = []
     _a_char = element.get_char()
     for i, c in enumerate(self._string):
         if c == _a_char:
             _points.append(self._strpos2pt(i))
     return _points
Example #4
0
 def get_pipe_positions(self):
     """Returns the set of pipe Points"""
     points = set()
     points.update(self._find_all(Element('PIPE')))
     points.update(self._find_all(Element('HERO_PIPE_LEFT')))
     points.update(self._find_all(Element('HERO_PIPE_RIGHT')))
     points.update(self._find_all(Element('OTHER_HERO_PIPE_LEFT')))
     points.update(self._find_all(Element('OTHER_HERO_PIPE_RIGHT')))
     points.update(self._find_all(Element('ENEMY_PIPE_LEFT')))
     points.update(self._find_all(Element('ENEMY_PIPE_RIGHT')))
     return list(points)
Example #5
0
 def get_enemy_positions(self):
     """ Return the list of points for other heroes."""
     points = set()
     points.update(self._find_all(Element("ENEMY_LADDER")))
     points.update(self._find_all(Element("ENEMY_LEFT")))
     points.update(self._find_all(Element("ENEMY_PIPE_LEFT")))
     points.update(self._find_all(Element("ENEMY_PIPE_RIGHT")))
     points.update(self._find_all(Element("ENEMY_RIGHT")))
     points.update(self._find_all(Element("ENEMY_PIT")))
     return list(points)
Example #6
0
 def get_ladder_positions(self):
     """Returns the set of ladder Points"""
     points = set()
     points.update(self._find_all(Element("LADDER")))
     points.update(self._find_all(Element("HERO_LADDER")))
     points.update(self._find_all(Element("OTHER_HERO_LADDER")))
     points.update(self._find_all(Element("ENEMY_LADDER")))
     points.update(self._find_all(Element("HERO_SHADOW_LADDER")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_LADDER")))
     return list(points)
Example #7
0
import os.path
import pickle
from math import sqrt

from loderunnerclient.internals.actions import LoderunnerAction
from loderunnerclient.internals.board import Board
from loderunnerclient.internals.element import Element

# 1. сохранение и продолжение поиска
# 2. приоритетные действия - убегание от роботов (даже если не успевает завершить поиск)

# не имеет особого смысла, т.к. ценность золота меняется при последовательном подборе
goldValue = {'YELLOW_GOLD': 2, 'GREEN_GOLD': 7, 'RED_GOLD': 10}
# Element(''),

gold = [Element(g) for g in goldValue.keys()] + [Element('THE_SHADOW_PILL')]

realLadders = [
    Element('LADDER'),
    Element('HERO_LADDER'),
    Element('HERO_SHADOW_LADDER')
]

possibleLadders = realLadders + \
                  [ Element('ENEMY_LADDER'),
                    Element('OTHER_HERO_LADDER'),
                    Element('OTHER_HERO_SHADOW_LADDER') ]

realPipes = [
    Element('PIPE'),
    Element('HERO_PIPE_LEFT'),
Example #8
0
 def get_portals(self):
     points = set()
     points.update(self._find_all(Element("PORTAL")))
     return list(points)
Example #9
0
 def get_shadow_pills(self):
     points = set()
     points.update(self._find_all(Element("THE_SHADOW_PILL")))
     return list(points)
Example #10
0
 def get_at(self, x, y):
     """ Return an _ELEMENTS object at coordinates x,y."""
     return Element(self.char_at(x, y))
Example #11
0
 def is_game_over(self):
     """ Returns False if your hero still alive."""
     return Element("HERO_DIE").get_char() in self._string
Example #12
0
 def get_my_position(self):
     """ Return the point where your hero is."""
     points = set()
     points.update(self._find_all(Element("HERO_DIE")))
     points.update(self._find_all(Element("HERO_DRILL_LEFT")))
     points.update(self._find_all(Element("HERO_DRILL_RIGHT")))
     points.update(self._find_all(Element("HERO_FALL_RIGHT")))
     points.update(self._find_all(Element("HERO_FALL_LEFT")))
     points.update(self._find_all(Element("HERO_LADDER")))
     points.update(self._find_all(Element("HERO_LEFT")))
     points.update(self._find_all(Element("HERO_RIGHT")))
     points.update(self._find_all(Element("HERO_PIPE_LEFT")))
     points.update(self._find_all(Element("HERO_PIPE_RIGHT")))
     points.update(self._find_all(Element("HERO_SHADOW_DRILL_LEFT")))
     points.update(self._find_all(Element("HERO_SHADOW_DRILL_RIGHT")))
     points.update(self._find_all(Element("HERO_SHADOW_LADDER")))
     points.update(self._find_all(Element("HERO_SHADOW_LEFT")))
     points.update(self._find_all(Element("HERO_SHADOW_RIGHT")))
     points.update(self._find_all(Element("HERO_SHADOW_FALL_LEFT")))
     points.update(self._find_all(Element("HERO_SHADOW_FALL_RIGHT")))
     points.update(self._find_all(Element("HERO_SHADOW_PIPE_LEFT")))
     points.update(self._find_all(Element("HERO_SHADOW_PIPE_RIGHT")))
     assert len(points) <= 1, "There should be only one hero"
     return list(points)[0]
Example #13
0
 def get_at(self, x, y):
     """ Return an Element object at coordinates x,y."""
     return Element(self._string[self._xy2strpos(x, y)])
Example #14
0
 def get_pipe_positions(self):
     """Returns the set of pipe Points"""
     points = set()
     points.update(self._find_all(Element("PIPE")))
     points.update(self._find_all(Element("HERO_PIPE_LEFT")))
     points.update(self._find_all(Element("HERO_PIPE_RIGHT")))
     points.update(self._find_all(Element("OTHER_HERO_PIPE_LEFT")))
     points.update(self._find_all(Element("OTHER_HERO_PIPE_RIGHT")))
     points.update(self._find_all(Element("ENEMY_PIPE_LEFT")))
     points.update(self._find_all(Element("ENEMY_PIPE_RIGHT")))
     points.update(self._find_all(Element("HERO_SHADOW_PIPE_LEFT")))
     points.update(self._find_all(Element("HERO_SHADOW_PIPE_RIGHT")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_PIPE_LEFT")))
     points.update(self._find_all(Element("OTHER_HERO_SHADOW_PIPE_RIGHT")))
     return list(points)
Example #15
0
 def get_gold_positions(self):
     points = set()
     points.update(self._find_all(Element("YELLOW_GOLD")))
     points.update(self._find_all(Element("GREEN_GOLD")))
     points.update(self._find_all(Element("RED_GOLD")))
     return list(points)
Example #16
0
 def get_wall_positions(self):
     """ Returns the list of walls Element Points."""
     points = set()
     points.update(self._find_all(Element("BRICK")))
     points.update(self._find_all(Element("UNDESTROYABLE_WALL")))
     return list(points)
Example #17
0
    def __get_shadows(self):
        points = set()
        points.update(self._find_all(Element("HERO_SHADOW_DRILL_LEFT")))
        points.update(self._find_all(Element("HERO_SHADOW_DRILL_RIGHT")))
        points.update(self._find_all(Element("HERO_SHADOW_LADDER")))
        points.update(self._find_all(Element("HERO_SHADOW_LEFT")))
        points.update(self._find_all(Element("HERO_SHADOW_RIGHT")))
        points.update(self._find_all(Element("HERO_SHADOW_FALL_LEFT")))
        points.update(self._find_all(Element("HERO_SHADOW_FALL_RIGHT")))
        points.update(self._find_all(Element("HERO_SHADOW_PIPE_LEFT")))
        points.update(self._find_all(Element("HERO_SHADOW_PIPE_RIGHT")))

        points.update(self._find_all(Element("OTHER_HERO_SHADOW_LEFT")))
        points.update(self._find_all(Element("OTHER_HERO_SHADOW_RIGHT")))
        points.update(self._find_all(Element("OTHER_HERO_SHADOW_LADDER")))
        points.update(self._find_all(Element("OTHER_HERO_SHADOW_PIPE_LEFT")))
        points.update(self._find_all(Element("OTHER_HERO_SHADOW_PIPE_RIGHT")))
        return list(points)