<gh_stars>0
# AUTOGENERATED! DO NOT EDIT! File to edit: 02_ui.ipynb (unless otherwise specified).

__all__ = ['showGameUi']

# Cell
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from cheviz import core, data

# Cell
from typing import Callable
import chess

def showGameUi(games:list, games_id:int=0, move:int=0, echo:int=1):
    board = chess.Board()

    def gameUi(reduced:Callable, square_filter:Callable, game_id:int=0):
        curr = games[game_id]
        moves_list = list(curr[1])
        ms = data.makeMoveSequencer(moves_list)

        def applyMoves(move:int, echo:int):
            board.reset()

            for i in range(move):
                board.push(moves_list[i])

            display(board)
            if len(board.move_stack) > 0:
                adjusted_wm = move if not board.turn else move - 1
                adjusted_bm = move if board.turn else move - 1

                core.show(reduced(ms(range(adjusted_wm - echo, adjusted_wm), chess.WHITE, square_filter).result))
                core.show(reduced(ms(range(adjusted_bm - echo, adjusted_bm), chess.BLACK, square_filter).result))

        moves_slider = widgets.IntSlider(min=0, max=len(moves_list), step=1, value=move)
        echo_slider = widgets.IntSlider(min=1, max=len(moves_list), step=2, value=echo)
        display(widgets.interactive(applyMoves, move=moves_slider, echo=echo_slider))
        print(curr[2])

    metrics_dd = widgets.Dropdown(options=[data.diffReduce, sum], value=data.diffReduce, description='Metric:', disabled=False)
    square_filter_dd = widgets.Dropdown(options=[core.attack, core.defence], value=core.attack, description='Square filter:', disabled=False)
    games_slider = widgets.IntSlider(min=0, max=len(games)-1, step=1, value=games_id)
    display(widgets.interactive(gameUi, reduced=metrics_dd, square_filter=square_filter_dd, game_id=games_slider))
# AUTOGENERATED! DO NOT EDIT! File to edit: 02_ui.ipynb (unless otherwise specified).

__all__ = ['showGameUi']

# Cell
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from cheviz import core, data

# Cell
from typing import Callable
import chess

def showGameUi(games:list, games_id:int=0, move:int=0, echo:int=1):
    board = chess.Board()

    def gameUi(reduced:Callable, square_filter:Callable, game_id:int=0):
        curr = games[game_id]
        moves_list = list(curr[1])
        ms = data.makeMoveSequencer(moves_list)

        def applyMoves(move:int, echo:int):
            board.reset()

            for i in range(move):
                board.push(moves_list[i])

            display(board)
            if len(board.move_stack) > 0:
                adjusted_wm = move if not board.turn else move - 1
                adjusted_bm = move if board.turn else move - 1

                core.show(reduced(ms(range(adjusted_wm - echo, adjusted_wm), chess.WHITE, square_filter).result))
                core.show(reduced(ms(range(adjusted_bm - echo, adjusted_bm), chess.BLACK, square_filter).result))

        moves_slider = widgets.IntSlider(min=0, max=len(moves_list), step=1, value=move)
        echo_slider = widgets.IntSlider(min=1, max=len(moves_list), step=2, value=echo)
        display(widgets.interactive(applyMoves, move=moves_slider, echo=echo_slider))
        print(curr[2])

    metrics_dd = widgets.Dropdown(options=[data.diffReduce, sum], value=data.diffReduce, description='Metric:', disabled=False)
    square_filter_dd = widgets.Dropdown(options=[core.attack, core.defence], value=core.attack, description='Square filter:', disabled=False)
    games_slider = widgets.IntSlider(min=0, max=len(games)-1, step=1, value=games_id)
    display(widgets.interactive(gameUi, reduced=metrics_dd, square_filter=square_filter_dd, game_id=games_slider))
# AUTOGENERATED! DO NOT EDIT! File to edit: 02_ui.ipynb (unless otherwise specified). # Cell # Cell