Compare commits

...

1 Commits

Author SHA1 Message Date
ea4efc5a2b Updated server code. 2018-06-07 21:36:06 +02:00

16
app.py
View File

@ -2,6 +2,7 @@ from flask import Flask, request, jsonify
from flask_json import FlaskJSON, as_json_p from flask_json import FlaskJSON, as_json_p
from flask_cors import CORS from flask_cors import CORS
from board import Board from board import Board
from eval import Eval
import main import main
import random import random
from network import Network from network import Network
@ -17,8 +18,8 @@ CORS(app)
config = main.config.copy() config = main.config.copy()
config['model'] = "player_testings" config['model'] = "player_testings"
config['ply'] = "1" config['ply'] = "0"
config['board_representation'] = 'quack-fat' config['board_representation'] = 'tesauro'
network = Network(config, config['model']) network = Network(config, config['model'])
network.restore_model() network.restore_model()
@ -90,11 +91,16 @@ def bot_move():
data = request.get_json(force=True) data = request.get_json(force=True)
board = [int(x) for x in data['board'].split(',')] board = [int(x) for x in data['board'].split(',')]
use_pubeval = bool(data['pubeval'])
roll = (random.randrange(1,7), random.randrange(1,7)) roll = (random.randrange(1, 7), random.randrange(1, 7))
# print(roll)
if use_pubeval:
board, value = Eval.make_pubeval_move(tuple(board), 1, roll)
else:
board, _ = network.make_move(tuple(board), roll, 1) board, _ = network.make_move(tuple(board), roll, 1)
# print("Boards!:",board)
# print("Board!:",board)
return ",".join([str(x) for x in list(board)]) return ",".join([str(x) for x in list(board)])