engine.py
def computer_move(game_state):
    """Return a move that is computed with the minimax algorithm.
    This function is assumed to only be used if no moves
    have been made to the game_state object, since castling rights may not
    valid then."""

    global node_counter
    node_counter = 0

    moves = game_state.legal_moves_no_castlings() + game_state.castlings()

    number_of_pieces = 0
    for s in range(64):
        if game_state.board[s] != None:
            number_of_pieces += 1

    if number_of_pieces > 15:
        depth = 3
    else:
        depth = 4

    best_move = None

    # The move order is randomized in order to make opening move
    # selection more natural.
    random.shuffle(moves)

    if moves == []:
        return None

    alpha = -1000000
    beta = 1000000
    for move in moves:
        game_state.make_move(move)
        value = -negamax(game_state, depth, -beta, -alpha)
        if value > alpha:
            best_move = move
            alpha = value
        game_state.undo_move(move)

    #print(node_counter)

    return best_move
Return a move that is computed with the minimax algorithm.
    This function is assumed to only be used if no moves
    have been made to the game_state object, since castling rights may not
    valid then.
Return a move that is computed with the minimax algorithm.
This function is assumed to only be used if no moves
have been made to the game_state object, since castling rights may not
valid then.
Return a move that is computed with the minimax algorithm . This function is assumed to only be used if no moves have been made to the game_state object since castling rights may not valid then .
def computer_move(game_state):
    global node_counter
    node_counter = 0
    moves = game_state.legal_moves_no_castlings() + game_state.castlings()
    number_of_pieces = 0
    for s in range(64):
        if game_state.board[s] != None:
            number_of_pieces += 1
    if number_of_pieces > 15:
        depth = 3
    else:
        depth = 4
    best_move = None
    random.shuffle(moves)
    if moves == []:
        return None
    alpha = -1000000
    beta = 1000000
    for move in moves:
        game_state.make_move(move)
        value = -negamax(game_state, depth, -beta, -alpha)
        if value > alpha:
            best_move = move
            alpha = value
        game_state.undo_move(move)
    return best_move
def computer_move ( game_state ) : global node_counter node_counter = 0 moves = game_state . legal_moves_no_castlings ( ) + game_state . castlings ( ) number_of_pieces = 0 for s in range ( 64 ) : if game_state . board [ s ] != None : number_of_pieces += 1 if number_of_pieces > 15 : depth = 3 else : depth = 4 best_move = None random . shuffle ( moves ) if moves == [ ] : return None alpha = - 1000000 beta = 1000000 for move in moves : game_state . make_move ( move ) value = - negamax ( game_state , depth , - beta , - alpha ) if value > alpha : best_move = move alpha = value game_state . undo_move ( move ) return best_move
Return a move that is computed with the minimax algorithm.
Return a move that is computed with the minimax algorithm .
"""Return a move that is computed with the minimax algorithm.
    This function is assumed to only be used if no moves
    have been made to the game_state object, since castling rights may not
    valid then.""" # The move order is randomized in order to make opening move # selection more natural. #print(node_counter)
game_state