Example #1
0
def getHeuristicBlack(current_board):
    board.getListOfMoves(current_board)
    
    current_board = board.known_boards[current_board]

    num_of_black_moves, num_of_white_moves = board.getListOfMoves(board)[0:1]
    num_of_black_moves = len(num_of_black_moves)
    mun_of_white_moves = len(num_of_white_moves)
    
    # Weight results
    if num_of_black_moves == 0 and turns_color == "white":
        num_of_white_moves += 100
    elif num_of_white_moves == 0 and turn_color == "black":
        num_of_black_moves += 100

    heuristic = num_of_black_moves - num_of_white_moves

    return
Example #2
0
    def movePiece(self, g_board):
        print "Random {0} player's turn ----".format(self.color)
        print board.toString(g_board)

        choices = board.getListOfMoves(g_board)
        if self.color == 'black':
            choices = choices[0]
        else:
            choices = choices[1]
        
        return random.choice(choices)
Example #3
0
def minmax_Decision(state):
    state = board.getListOfMoves(state)

    num_moves_black = len(state[0])
    num_moves_white = len(state[1])
    
    value = num_moves_black - num_moves_white
    
    # weight results if at terminal
    if num_moves_white == 0:
        value += 50
        state[3] = value

    if num_moves_black == 0:
        value -= 50
        state[4] = value

    return value