Пример #1
0
def legal_moves(history, player_is_white):
    """"Generates a list of legal moves. Missing castling, en-passant."""
    board = ai.to_array(history)[-1]
    moves = list(ai.legal_moves(board, player_is_white))
    assert type(moves[0][0]) == array
    moves = [ai.from_array(move) for move, _score in moves]
    return moves
Пример #2
0
def main(given_history, _, __):
    history = ai.to_array(given_history)
    player_is_white = len(history) % 2 == 1
    current_board = history[-1]
    best_score = -10**10
    for move, diff in ai.legal_moves(current_board, player_is_white):
        score = ai.evaluate(move)
        if not player_is_white:
            score = -score
        if score > best_score:
            best_score = score
            best_move = move
    print(f'search depth: 1')
    print(f'expected score: {best_score}')
    return ai.from_array(best_move)
Пример #3
0
def main(history, _, __):
    possible_moves = list(
        ai.legal_moves(ai.to_array(history[-1]),
                       len(history) % 2))
    move = random.choice(possible_moves)[0]
    return ai.from_array(move)