File size: 954 Bytes
dcf6a2a
 
 
 
 
 
 
 
 
 
 
 
 
f387c51
 
dcf6a2a
4284543
 
dcf6a2a
 
 
ebc64ba
dcf6a2a
 
 
 
 
 
 
 
 
dcfdba7
dcf6a2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#from stockfish import Stockfish

#stockfish = Stockfish(path="./stockfish_14_x64_popcnt")/
import gradio as gr
import os
import chess
import chess.engine
import stat



def eval(fenstring):
    output = ""
    os.chmod("./counter-5.5-linux-amd64",0o0777)
    engine = chess.engine.SimpleEngine.popen_uci("./counter-5.5-linux-amd64" )
    
    
    # Score PovScore(Cp(+20), WHITE)

    board = chess.Board(fenstring)
    
    info = engine.analyse(board, chess.engine.Limit( depth = 1 ))
 
 
    # Score: PovScore(Mate(+1), WHITE)
    
    engine.quit()
    return info
iface = gr.Interface(fn=eval, title="Stockfish chessboard eval",
                    description="Stockfish 14 chess evaluation using pychess engine component. Enter in fen string to get the board eval and the 3 best moves with continuations\
       Stockfish 15 would not execute in huggingface due to glibc", inputs="text", outputs="text")
iface.queue(api_open=True)
iface.launch()