Spaces:
Sleeping
Sleeping
stateful interface
Browse files- .gitignore +140 -0
- src/play_interface.py +14 -1
.gitignore
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
pip-wheel-metadata/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
*.py,cover
|
51 |
+
.hypothesis/
|
52 |
+
.pytest_cache/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
target/
|
76 |
+
|
77 |
+
# Jupyter Notebook
|
78 |
+
.ipynb_checkpoints
|
79 |
+
|
80 |
+
# IPython
|
81 |
+
profile_default/
|
82 |
+
ipython_config.py
|
83 |
+
|
84 |
+
# pipenv
|
85 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
86 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
87 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
88 |
+
# install all needed dependencies.
|
89 |
+
#Pipfile.lock
|
90 |
+
|
91 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
92 |
+
__pypackages__/
|
93 |
+
|
94 |
+
# Celery stuff
|
95 |
+
celerybeat-schedule
|
96 |
+
celerybeat.pid
|
97 |
+
|
98 |
+
# SageMath parsed files
|
99 |
+
*.sage.py
|
100 |
+
|
101 |
+
# Environments
|
102 |
+
.env
|
103 |
+
.venv
|
104 |
+
env/
|
105 |
+
venv/
|
106 |
+
ENV/
|
107 |
+
env.bak/
|
108 |
+
venv.bak/
|
109 |
+
|
110 |
+
# Spyder project settings
|
111 |
+
.spyderproject
|
112 |
+
.spyproject
|
113 |
+
|
114 |
+
# Rope project settings
|
115 |
+
.ropeproject
|
116 |
+
|
117 |
+
# mkdocs documentation
|
118 |
+
/site
|
119 |
+
|
120 |
+
# mypy
|
121 |
+
.mypy_cache/
|
122 |
+
.dmypy.json
|
123 |
+
dmypy.json
|
124 |
+
|
125 |
+
# Pyre type checker
|
126 |
+
.pyre/
|
127 |
+
|
128 |
+
# Pickle files
|
129 |
+
*.pkl
|
130 |
+
|
131 |
+
# Various files
|
132 |
+
ignored
|
133 |
+
debug
|
134 |
+
*.zip
|
135 |
+
lc0
|
136 |
+
!bin/lc0
|
137 |
+
wandb
|
138 |
+
*.svg
|
139 |
+
|
140 |
+
*secret*
|
src/play_interface.py
CHANGED
@@ -63,6 +63,7 @@ def play_ai_move(
|
|
63 |
temperature: float = 0.1,
|
64 |
top_k: int = 3,
|
65 |
):
|
|
|
66 |
uci_move = inference_fn(
|
67 |
prompt=f"FEN: {current_board.fen()}\nMOVE:",
|
68 |
temperature=temperature,
|
@@ -139,6 +140,7 @@ with gr.Blocks() as interface:
|
|
139 |
value="",
|
140 |
)
|
141 |
play_button = gr.Button("Play")
|
|
|
142 |
with gr.Column():
|
143 |
image_board = gr.Image(label="Board")
|
144 |
|
@@ -159,6 +161,17 @@ with gr.Blocks() as interface:
|
|
159 |
play_button.click(
|
160 |
try_play_move,
|
161 |
inputs=[*static_inputs, state_board],
|
162 |
-
outputs=[*static_outputs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
)
|
164 |
interface.load(render_board, inputs=[state_board], outputs=[*static_outputs])
|
|
|
63 |
temperature: float = 0.1,
|
64 |
top_k: int = 3,
|
65 |
):
|
66 |
+
print(f"Playing AI move with temperature {temperature}")
|
67 |
uci_move = inference_fn(
|
68 |
prompt=f"FEN: {current_board.fen()}\nMOVE:",
|
69 |
temperature=temperature,
|
|
|
140 |
value="",
|
141 |
)
|
142 |
play_button = gr.Button("Play")
|
143 |
+
reset_button = gr.Button("Reset")
|
144 |
with gr.Column():
|
145 |
image_board = gr.Image(label="Board")
|
146 |
|
|
|
161 |
play_button.click(
|
162 |
try_play_move,
|
163 |
inputs=[*static_inputs, state_board],
|
164 |
+
outputs=[*static_outputs, state_board],
|
165 |
+
)
|
166 |
+
|
167 |
+
def reset_board():
|
168 |
+
board = chess.Board()
|
169 |
+
is_ai_white = random.choice([True, False])
|
170 |
+
if is_ai_white:
|
171 |
+
board = play_ai_move(board)
|
172 |
+
return *render_board(board), board
|
173 |
+
reset_button.click(
|
174 |
+
reset_board,
|
175 |
+
outputs=[*static_outputs, state_board],
|
176 |
)
|
177 |
interface.load(render_board, inputs=[state_board], outputs=[*static_outputs])
|