-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptc_web.py
37 lines (32 loc) · 930 Bytes
/
ptc_web.py
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
34
35
36
import chess as c
import pyturochamp, bare, bernstein, plan, shannon, soma
from flask import Flask, request, render_template
app = Flask(__name__, static_url_path = '')
@app.route("/ptcmove", methods = ['POST'])
def ptcmove():
content = request.get_json()
fen = content['fen']
engine = content['engine']
print(fen)
print(engine)
d = c.Board(fen)
if len(list(d.legal_moves)) == 0:
return ""
if engine == "Bare":
t, r = bare.getmove(d, silent = True)
elif engine == "Bernstein":
t, r = bernstein.getmove(d, silent = True)
elif engine == "Plankalkül":
t, r = plan.getmove(d, silent = True)
elif engine == "Shannon":
t, r = shannon.getmove(d, silent = True)
elif engine == "SOMA":
t, r = soma.getmove(d, silent = True)
else:
t, r = pyturochamp.getmove(d, silent = True)
print(r[0])
return r[0]
@app.route("/")
def main():
return render_template("index.html")
app.run(host = '0.0.0.0', port = 5000)