mzimm003 commited on
Commit
b3c5de3
·
1 Parent(s): be8ef18

Acheived MVP

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -3,14 +3,29 @@ from my_chess.learner.environments import Chess
3
 
4
  from chessmodels import DCMinMax
5
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  def play(bot_select):
8
- modelminmax = DCMinMax.from_pretrained("mzimm003/{}".format(bot_select))
9
- play = HumanVsBot(
10
- model=modelminmax,
11
- environment=Chess(render_mode="rgb_array"),
12
- extra_model_environment_context=lambda env: {"board":env.board}
13
  )
 
14
  play.run()
15
 
16
  def main(kwargs=None):
 
3
 
4
  from chessmodels import DCMinMax
5
  import streamlit as st
6
+ from streamlit_image_coordinates import streamlit_image_coordinates
7
+
8
+ class HvB(HumanVsBot):
9
+ @staticmethod
10
+ @st.cache_resource()
11
+ def get_hvb_manager(
12
+ _model,
13
+ _environment,
14
+ _extra_model_environment_context,
15
+ **kwargs):
16
+ return HvB(
17
+ model = _model,
18
+ environment = _environment,
19
+ extra_model_environment_context = _extra_model_environment_context,
20
+ **kwargs)
21
 
22
  def play(bot_select):
23
+ play = HvB.get_hvb_manager(
24
+ _model=DCMinMax.from_pretrained("mzimm003/{}".format(bot_select)),
25
+ _environment=Chess(render_mode="rgb_array"),
26
+ _extra_model_environment_context=lambda env: {"board":env.board}
 
27
  )
28
+ st.session_state["board"] = streamlit_image_coordinates(play.render_board(), key="brd", click_and_drag=True)
29
  play.run()
30
 
31
  def main(kwargs=None):