Example #1
0
    def __init__(self,
                 position: Hex,
                 terrain: Terrain,
                 geography: int,
                 objective: bool,
                 blockLos: bool,
                 color: str = 'white'):
        self.terrain = terrain
        self.geography = geography
        self.objective = objective
        self.blockLos = blockLos
        self.cube = position.cube()
        self.color = color

        self.i, self.j = position.tuple()
        self.x, self.y = pos_to_xy((self.i, self.j))
Example #2
0
def scroll(board: GameBoard):
    x, y = board.shape

    objectiveMarks = board.getObjectiveMark()

    for i in range(0, x):
        for j in range(0, y):
            p = Hex(i, j)
            x = p.tuple()

            index = board.terrain[x]
            tt = TYPE_TERRAIN[index]

            h = Hexagon(p, tt, board.geography[x],
                        p.cube() in objectiveMarks, tt.blockLos, tt.color)

            yield h
Example #3
0
    def __init__(self,
                 team: str,
                 shape: tuple,
                 objectives: List[tuple or Hex or Cube],
                 turns: int = 1):
        """
        # TODO: this version support 1 turn maximum!
        """
        super().__init__(team)

        self.objectives: List[Cube] = []

        self.values: np.ndarray = np.zeros(shape)

        self.turns = turns
        # self.entered: Dict[(Cube, int), int] = {}

        for o in objectives:
            if isinstance(o, Hex):
                o = o.cube()
            elif isinstance(o, tuple):
                o = Hex(t=o).cube()
            self.objectives.append(o)

        for x, y in np.ndindex(shape):
            xy = Hex(x, y).cube()
            for o in self.objectives:
                self.values[x, y] = xy.distance(o)

        maxBV = np.max(self.values)

        for x, y in np.ndindex(shape):
            self.values[x, y] = 1 - self.values[x, y] / maxBV

        for o in self.objectives:
            self.values[o.tuple()] = 5