backgammon/network_test.py

59 lines
1.4 KiB
Python

from network import Network
import tensorflow as tf
import random
import numpy as np
from board import Board
import main
config = main.config.copy()
config['model'] = "tesauro_blah"
config['force_creation'] = True
network = Network(config, config['model'])
session = tf.Session()
session.run(tf.global_variables_initializer())
network.restore_model(session)
initial_state = Board.initial_state
initial_state_1 = ( 0,
0, 0, 0, 2, 0, -5,
0, -3, 0, 0, 0, 0,
-5, 0, 0, 0, 3, 5,
0, 0, 0, 0, 5, -2,
0 )
initial_state_2 = ( 0,
-5, -5, -3, -2, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 15, 0, 0,
0, 0, 0, 0, 0, 0,
0 )
boards = {initial_state,
initial_state_1,
initial_state_2 }
print("-"*30)
print(network.do_ply(session, boards, 1))
print(" "*10 + "network_test")
print(" "*20 + "Depth 1")
print(network.n_ply(1, session, boards, 1))
print(" "*20 + "Depth 2")
print(network.n_ply(2, session, boards, 1))
# #print(x.shape)
# with graph_lol.as_default():
# session_2 = tf.Session(graph = graph_lol)
# network_2 = Network(session_2)
# network_2.restore_model()
# print(network_2.eval_state(initial_state))
# print(network.eval_state(initial_state))