Example #1
0
    def __init__(self, proto):
        self._proto = proto
        self.players: List[Player] = [
            Player.from_proto(p) for p in self._proto.player_info
        ]
        self.map_name: str = self._proto.map_name
        self.local_map_path: str = self._proto.local_map_path
        self.map_size: Size = Size.from_proto(self._proto.start_raw.map_size)

        # self.pathing_grid[point]: if 0, point is not pathable, if 1, point is pathable
        self.pathing_grid: PixelMap = PixelMap(
            self._proto.start_raw.pathing_grid, in_bits=True, mirrored=False)
        # self.terrain_height[point]: returns the height in range of 0 to 255 at that point
        self.terrain_height: PixelMap = PixelMap(
            self._proto.start_raw.terrain_height, mirrored=False)
        # self.placement_grid[point]: if 0, point is not placeable, if 1, point is pathable
        self.placement_grid: PixelMap = PixelMap(
            self._proto.start_raw.placement_grid, in_bits=True, mirrored=False)
        self.playable_area = Rect.from_proto(
            self._proto.start_raw.playable_area)
        self.map_center = self.playable_area.center
        self.map_ramps: List[
            Ramp] = None  # Filled later by BotAI._prepare_first_step
        self.vision_blockers: FrozenSet[
            Point2] = None  # Filled later by BotAI._prepare_first_step
        self.player_races: Dict[int, Race] = {
            p.player_id: p.race_actual or p.race_requested
            for p in self._proto.player_info
        }
        self.start_locations: List[Point2] = [
            Point2.from_proto(sl)
            for sl in self._proto.start_raw.start_locations
        ]
        self.player_start_location: Point2 = None  # Filled later by BotAI._prepare_first_step
Example #2
0
 def test_position_rect(self, bot: BotAI, x, y, w, h):
     rect = Rect((x, y, w, h))
     assert rect.x == x
     assert rect.y == y
     assert rect.width == w
     assert rect.height == h
     assert rect.size == Size((w, h))
     assert rect.center == Point2((rect.x + rect.width / 2, rect.y + rect.height / 2))
     assert rect.offset((1, 1)) == Rect((x + 1, y + 1, w, h))
Example #3
0
def test_position_size(w, h):
    size = Size((w, h))
    assert size.width == w
    assert size.height == h
Example #4
0
 def test_position_size(self, bot: BotAI, w, h):
     size = Size((w, h))
     assert size.width == w
     assert size.height == h