コード例 #1
0
    def move(self, pos):

        move = []
        temp = 0
        if self.colour == BLACK:
            if pos[0] == 1:
                self.moves = 2
                temp = logic.addT(pos, 2, 0)
                if temp[0] < 8 and temp[0] >= 0:
                    if temp[1] < 8 and temp[1] >= 0:
                        move.append(temp)
            temp = logic.addT(pos, 1, 0)
            if temp[0] < 8 and temp[0] >= 0:
                if temp[1] < 8 and temp[1] >= 0:
                    move.append(temp)
        else:
            if pos[0] == 6:
                self.moves = 2
                temp = logic.addT(pos, -2, 0)
                if temp[0] < 8 and temp[0] >= 0:
                    if temp[1] < 8 and temp[1] >= 0:
                        move.append(temp)
            temp = logic.addT(pos, -1, 0)
            if temp[0] < 8 and temp[0] >= 0:
                if temp[1] < 8 and temp[1] >= 0:
                    move.append(temp)
        return move
コード例 #2
0
    def move(self, pos):
        move = []
        temp = 0
        for i in range(0, 8):
            temp = logic.addT(pos, i, i)
            if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
                move.append(temp)

                self.moves += 1
            temp = logic.addT(pos, i, -i)
            if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
                move.append(temp)

                self.moves += 1
            temp = logic.addT(pos, -i, i)
            if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
                move.append(temp)

                self.moves += 1
            temp = logic.addT(pos, -i, -i)
            if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
                move.append(temp)

                self.moves += 1

        return move
コード例 #3
0
    def move(self, pos):
        move = []
        temp = 0
        for i in range(-1, 2, 2):
            temp = logic.addT(pos, i, 0)
            if temp[0] < 8 and temp[0] >= 0:
                move.append(temp)
                self.moves += 1
            temp = logic.addT(pos, 0, i)
            if temp[1] < 8 and temp[1] >= 0:
                move.append(temp)
                self.moves += 1

        return move
コード例 #4
0
    def move(self, pos):
        move = []
        temp = 0
        temp = logic.addT(pos, 2, 1)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, 2, -1)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, -2, 1)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, -2, -1)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, 1, 2)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, 1, -2)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, -1, 2)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1
        temp = logic.addT(pos, -1, -2)
        if temp[0] < 8 and temp[1] >= 0 and temp[0] >= 0 and temp[1] < 8:
            move.append(temp)
            self.moves += 1

        return move