Ejemplo n.º 1
0
 def findAllNeighbours(self, position):
     neighbours = []
     positions = ([1, 2], [1, -2], [-1, 2], [-1, -2], [2, 1], [2, -1],
                  [-2, 1], [-2, -1])
     for pos in positions:
         newPosition = numpy.add(position, pos)
         if main.checkIfInBounds(newPosition):
             neighbours.append(newPosition)
     return neighbours
Ejemplo n.º 2
0
 def findNeighbours(self, position):
     neighbours = []
     positions = ([1, 2], [1, -2], [-1, 2], [-1, -2], [2, 1], [2, -1],
                  [-2, 1], [-2, -1])
     for pos in positions:
         newPosition = numpy.add(position, pos)
         if main.checkIfInBounds(newPosition) and [
                 newPosition[0], newPosition[1]
         ] not in self.obstacles:
             neighbours.append(numpy.add(position, pos))
     return neighbours
Ejemplo n.º 3
0
    def findNeighbours(self, position):
        i = position[0]
        j = position[1]

        neighbours = []

        while main.checkIfInBounds([i, j]):
            neighbours.append([i, j])
            i += 1
            j += 1

        i = position[0]
        j = position[1]

        while main.checkIfInBounds([i, j]):
            neighbours.append([i, j])
            i -= 1
            j -= 1

        i = position[0]
        j = position[1]

        while main.checkIfInBounds([i, j]):
            neighbours.append([i, j])
            i -= 1
            j += 1

        i = position[0]
        j = position[1]

        while main.checkIfInBounds([i, j]):
            neighbours.append([i, j])
            i += 1
            j -= 1

        return neighbours
Ejemplo n.º 4
0
 def move(self, direction):
     new_position = numpy.add(self.pos, direction)
     if main.checkIfInBounds(new_position):
         self.pos = new_position