Commit 8827e60a authored by leswing's avatar leswing
Browse files

Merge branch 'a3c-tictactoe' into a3c-tictacote-lambda1

parents e346c00a 50af8f54
Loading
Loading
Loading
Loading
+17 −19
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ def eval_tic_tac_toe(value_weight, games=10 ** 4, rollouts=10 ** 5):
    a3c = dc.rl.A3C(env, policy, entropy_weight=0.01, value_weight=value_weight)
    a3c.optimizer = dc.models.tensorgraph.TFWrapper(
        tf.train.AdamOptimizer, learning_rate=0.01)
    avg_rewards = []
    for j in range(10):
        a3c.fit(rollouts)
        rewards = []
        for i in range(games):
@@ -168,19 +170,15 @@ def eval_tic_tac_toe(value_weight, games=10 ** 4, rollouts=10 ** 5):
                action = a3c.select_action(env._state)
                reward = env.step(action)
            rewards.append(reward)
    return np.mean(rewards)
        avg_rewards.append(((j+1) * rollouts, np.mean(rewards)))
    return avg_rewards


def main():
    scores = {}
    value_weight = 0.05
    while value_weight <= 1.0:
        print(value_weight)
    value_weight = 0.70
    score = eval_tic_tac_toe(value_weight)
        scores[value_weight] = score
        with open('tictactoe_value_search_lambda1.json', 'w') as fout:
            fout.write(json.dumps(scores))
        value_weight += 0.05
    with open('tictactoe_converge_lambda1.json', 'w') as fout:
        fout.write(json.dumps(score))