backgammon/network_test.py

58 lines
1.1 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'] = "eager_testings"
config['force_creation'] = True
config['board_representation'] = 'quack-fat'
network = Network(config, config['model'])
network.restore_model()
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 }
board = network.board_trans_func(Board.initial_state, 1)
pair = network.make_move(Board.initial_state, [3,2], 1)
print(pair[1])
network.do_backprop(board, 0.9)
network.print_variables()
network.save_model(2)