Exemplo n.º 1
0
    def getValidMoves(self):
        ret = [
            # One space away
            (self.x, self.y+2),
            (self.x, self.y-2),
            (self.x-1, self.y-1),
            (self.x-1, self.y+1),
            (self.x+1, self.y-1),
            (self.x+1, self.y+1),

            # Two spaces away
            (self.x, self.y+4),
            (self.x, self.y-4),

            (self.x+1, self.y+3),
            (self.x+1, self.y-3),
            (self.x-1, self.y+3),
            (self.x-1, self.y-3),

            (self.x-2, self.y),
            (self.x+2, self.y),

            (self.x+2, self.y-2),
            (self.x+2, self.y+2),
            (self.x-2, self.y-2),
            (self.x-2, self.y+2)
        ]

        ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
        ret = filterBlockedSpots(ret, Piece.getState())
        ret.append((self.x, self.y))

        return ret
Exemplo n.º 2
0
    def getValidMoves(self):
        ret = [ # Static list is easy
            (self.x, self.y+2),
            (self.x, self.y-2),
            (self.x-1, self.y-1),
            (self.x-1, self.y+1),
            (self.x+1, self.y-1),
            (self.x+1, self.y+1)
        ]

        ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
        ret = filterBlockedSpots(ret, Piece.getState())
        ret.append((self.x, self.y))
        return ret
Exemplo n.º 3
0
    def getValidAttacks(self):
        ret = [ # Static list is easy.  Keep this sorted in order by direction
            (self.x, self.y-2),   # 0
            (self.x+1, self.y-1), # 1
            (self.x+1, self.y+1), # 2
            (self.x, self.y+2),   # 3
            (self.x-1, self.y+1), # 4
            (self.x-1, self.y-1)  # 5
        ]

        ret2 = [
            # Two spaces away
            (self.x, self.y-4),   # 0
            (self.x+1, self.y-3), # 0.5
            (self.x+2, self.y-2), # 1
            (self.x+2, self.y),   # 1.5
            (self.x+2, self.y+2), # 2
            (self.x+1, self.y+3), # 2.5
            (self.x, self.y+4),   # 3
            (self.x-1, self.y+3),   # 3.5
            (self.x-2, self.y+2), # 4
            (self.x-2, self.y), # 4.5
            (self.x-2, self.y-2), # 5
            (self.x-1, self.y-3)  # 5.5
        ]

        # Get current dir + other two adjacent ones
        ret = [
            # One square away
            ret[self.direction],
            ret[(self.direction+1)%6],
            ret[(self.direction-1)%6],

            # Two squares away
            ret2[self.direction*2],
            ret2[(self.direction*2+1)%12],
            ret2[(self.direction*2+2)%12],
            ret2[(self.direction*2-1)%12],
            ret2[(self.direction*2-2)%12],
        ]

        # Filter to only spots on board and that are blocked
        ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
        ret = filterUnblockedSpots(ret, Piece.getState())
        ret = filterMyPieces(ret, Piece.getState(), self.player)

        # NOTE: Currently possible to attack your own troops
        
        return ret
Exemplo n.º 4
0
    def getValidAttacks(self):
        ret = [ # Static list is easy.  Keep this sorted in order by direction
            (self.x, self.y-2),   # 0
            (self.x+1, self.y-1), # 1
            (self.x+1, self.y+1), # 2
            (self.x, self.y+2),   # 3
            (self.x-1, self.y+1), # 4
            (self.x-1, self.y-1)  # 5
        ]

        # Get current dir + other two adjacent ones
        ret = [ret[self.direction],
            ret[(self.direction+1)%6],
            ret[(self.direction-1)%6]]

        # Filter to only spots on board and that are blocked
        ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
        ret = filterUnblockedSpots(ret, Piece.getState())
        ret = filterMyPieces(ret, Piece.getState(), self.player)

        # NOTE: Currently possible to attack your own troops
        
        return ret