コード例 #1
0
ファイル: board.py プロジェクト: nouwaarom/GameBot
    def getForcedMoves(self, colors, enemy):
        moves = []
        board = self.board

        for key, tile in enumerate(self.board):
            if tile in colors:
                #check down
                if key > 10:
                    #check left
                    if ((key-1) % 5) != 0:
                        if board[key-6] in enemy:
                            if board[key-11] == 'x':
                                moves.append(helperCreateMove((key-11, tile), [(key, tile), (key-6, board[key-6])]))

                    #check right
                    if ((key+2) % 5) != 0:
                        if board[key-4] in enemy:
                            if board[key-9] == 'x':
                                moves.append(helperCreateMove((key-9, tile), [(key, tile), (key-4, board[key-4])]))

                #check up
                if key < 40:
                    #check left
                    if ((key-1) % 5) != 0:
                        if board[key+4] in enemy:
                            if board[key+9] == 'x':
                                moves.append(helperCreateMove((key+9, tile), [(key, tile), (key+4, board[key+4])]))

                    #check right
                    if ((key+2) % 5) != 0:
                        if board[key+6] in enemy:
                            if board[key+11] == 'x':
                                moves.append(helperCreateMove((key+11, tile), [(key, tile), (key+6, board[key+6])]))

        return move
コード例 #2
0
ファイル: board.py プロジェクト: nouwaarom/GameBot
    def getMoves(self, colors):
        moves = []
        board = list(self.board)

        for key, tile in enumerate(board):
            if tile in colors:
                #check down
                if key > 5:
                    #check left
                    if (key % 5) != 0:
                        if board[key-6] == 'x':
                            moves.append(helperCreateMove((key-6, tile), [(key, tile)]))

                    #check right
                    if ((key+1) % 5) != 0:
                        if board[key-4] == 'x':
                            moves.append(helperCreateMove((key-4, tile), [(key, tile)]))

                #check up
                if key < 45:
                    #check left
                    if (key % 5) != 0:
                        if board[key+4] == 'x':
                            moves.append(helperCreateMove((key+4, tile), [(key, tile)]))

                    #check right
                    if ((key+1) % 5) != 0:
                        if board[key+6] == 'x':
                            moves.append(helperCreateMove((key+6, tile), [(key, tile)]))

        return moves
コード例 #3
0
    def getForcedMoves(self, colors, enemy):
        moves = []
        board = self.board

        for key, tile in enumerate(self.board):
            if tile in colors:
                #check down
                if key > 10:
                    #check left
                    if ((key - 1) % 5) != 0:
                        if board[key - 6] in enemy:
                            if board[key - 11] == 'x':
                                moves.append(
                                    helperCreateMove(
                                        (key - 11, tile),
                                        [(key, tile),
                                         (key - 6, board[key - 6])]))

                    #check right
                    if ((key + 2) % 5) != 0:
                        if board[key - 4] in enemy:
                            if board[key - 9] == 'x':
                                moves.append(
                                    helperCreateMove(
                                        (key - 9, tile),
                                        [(key, tile),
                                         (key - 4, board[key - 4])]))

                #check up
                if key < 40:
                    #check left
                    if ((key - 1) % 5) != 0:
                        if board[key + 4] in enemy:
                            if board[key + 9] == 'x':
                                moves.append(
                                    helperCreateMove(
                                        (key + 9, tile),
                                        [(key, tile),
                                         (key + 4, board[key + 4])]))

                    #check right
                    if ((key + 2) % 5) != 0:
                        if board[key + 6] in enemy:
                            if board[key + 11] == 'x':
                                moves.append(
                                    helperCreateMove(
                                        (key + 11, tile),
                                        [(key, tile),
                                         (key + 6, board[key + 6])]))

        return move
コード例 #4
0
    def getMoves(self, colors):
        moves = []
        board = list(self.board)

        for key, tile in enumerate(board):
            if tile in colors:
                #check down
                if key > 5:
                    #check left
                    if (key % 5) != 0:
                        if board[key - 6] == 'x':
                            moves.append(
                                helperCreateMove((key - 6, tile),
                                                 [(key, tile)]))

                    #check right
                    if ((key + 1) % 5) != 0:
                        if board[key - 4] == 'x':
                            moves.append(
                                helperCreateMove((key - 4, tile),
                                                 [(key, tile)]))

                #check up
                if key < 45:
                    #check left
                    if (key % 5) != 0:
                        if board[key + 4] == 'x':
                            moves.append(
                                helperCreateMove((key + 4, tile),
                                                 [(key, tile)]))

                    #check right
                    if ((key + 1) % 5) != 0:
                        if board[key + 6] == 'x':
                            moves.append(
                                helperCreateMove((key + 6, tile),
                                                 [(key, tile)]))

        return moves