Spaces:
Paused
Paused
Commit ·
3fb4645
1
Parent(s): 30af058
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,29 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
-
def greet(name):
|
| 5 |
-
return "Hello " + name
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import chess
|
| 4 |
+
import chess.engine
|
| 5 |
+
import stat
|
| 6 |
|
| 7 |
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def eval(fenstring):
|
| 10 |
+
output = ""
|
| 11 |
+
os.chmod("./stockfish_14_x64_popcnt",0o0777)
|
| 12 |
+
engine = chess.engine.SimpleEngine.popen_uci("./stockfish_14_x64_popcnt")
|
| 13 |
+
|
| 14 |
|
| 15 |
+
# Score: PovScore(Cp(+20), WHITE)
|
| 16 |
|
| 17 |
+
board = chess.Board(fenstring)
|
| 18 |
+
|
| 19 |
+
info = engine.analyse(board, chess.engine.Limit(depth=20),multipv=3)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# Score: PovScore(Mate(+1), WHITE)
|
| 23 |
+
|
| 24 |
+
engine.quit()
|
| 25 |
+
return info
|
| 26 |
+
iface = gr.Interface(fn=eval, title="Stockfish chessboard eval",
|
| 27 |
+
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\
|
| 28 |
+
Stockfish 15 would not execute in huggingface due to glibc", inputs="text", outputs="text")
|
| 29 |
+
iface.launch()
|