Пример #1
0
        break
    else:
        print("Input number:")

# 学習
for i in xrange(iterations):
    game = Game(com_1, com_2)
    if i % 1000 == 0:
        print("training iterations: No.%d" % (i))
        game.start(True)
    else:
        game.start(False)

# com同士のデモンストレーション
com_1.training = False
com_1.verbose = True
com_2.training = False
com_2.verbose = True

game = Game(com_1, com_2)
game.start(True)

# モデルの保存
# NNのパラメータ保存に変更
#with open('tic_tac_toe_com_1_sarsa_r.pkl', 'wb') as f:
#    dill.dump(com_1, f)
#with open('tic_tac_toe_com_2_sarsa_r.pkl', 'wb') as f:
#    dill.dump(com_2, f)


        break
    elif input_line == "":
        break
    else:
        print("Input number:")

# 学習
for i in xrange(iterations):
    game = Game(com_1, com_2)
    if i % 1000 == 0:
        print("training iterations: No.%d" % (i))
        game.start(True)
    else:
        game.start(False)

# com同士のデモンストレーション
com_1.training = False
com_1.verbose = True
com_2.training = False
com_2.verbose = True

game = Game(com_1, com_2)
game.start(True)

# モデルの保存
# NNのパラメータ保存に変更
# with open('tic_tac_toe_com_1_sarsa_r.pkl', 'wb') as f:
#    dill.dump(com_1, f)
# with open('tic_tac_toe_com_2_sarsa_r.pkl', 'wb') as f:
#    dill.dump(com_2, f)
        break
    else:
        print("Input number:")

# 学習
for i in xrange(iterations):
    game = Game(com_1, com_2)
    if i % 1000 == 0:
        print("training iterations: No.%d" % (i))
        game.start(True)
    else:
        game.start(False)

# com同士のデモンストレーション
com_1.training = False
com_1.verbose = True
com_2.training = False
com_2.verbose = True

game = Game(com_1, com_2)
game.start(True)

# モデルの保存
with open('tic_tac_toe_com_1_sarsa_r.pkl', 'wb') as f:
    dill.dump(com_1, f)

with open('tic_tac_toe_com_2_sarsa_r.pkl', 'wb') as f:
    dill.dump(com_2, f)