Updated server code.

This commit is contained in:
Alexander Munch-Hansen 2018-06-07 21:36:06 +02:00
parent 26c0b469eb
commit ea4efc5a2b

18
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)
board, _ = network.make_move(tuple(board), roll, 1) if use_pubeval:
# print("Boards!:",board) board, value = Eval.make_pubeval_move(tuple(board), 1, roll)
else:
board, _ = network.make_move(tuple(board), roll, 1)
# print("Board!:",board)
return ",".join([str(x) for x in list(board)]) return ",".join([str(x) for x in list(board)])