import tensorflow as tf
import numpy as np
import random
import os
from gym.monitoring import VideoRecorder
import datetime
import csv

from drl.replaybuffer import ReplayBuffer
from drl.nn import NN
from drl.utilities import print_dict, color_print

# Algorithm info
info = {
    'name': 'DQN'
}


class DQN_Options(object):
    NETWORK_TYPE = None  # Replace by 'conv' for convolution
    BATCH_SIZE = 32  # No. of training cases over each SGD update
    REPLAY_MEMORY_SIZE = 1000000  # SGD updates sampled from this number of most recent frames
    DISCOUNT_FACTOR = 0.99  # Gamma used in Q-learning update
    LEARNING_RATE = 0.00025  # Learning rate used by optimizer
    INITIAL_EPSILON = 1.0  # Initial value of epsilon in epsilon-greedy exploration
    CURRENT_EPSILON = INITIAL_EPSILON  # Initialize current epsilon to initial value
    FINAL_EPSILON = 0.01  # Final value of epsilon in epsilon-greedy exploration
    FINAL_EXPLORATION_FRAME = 100000  # No. of frames over which initial value of epsilon is linearly annealed to it's final value
    TARGET_NETWORK_UPDATE_FREQUENCY = 10000  # No. of parameter updates after which you should update the target network
    SCALE_OBSERVATIONS = False  # Set to true if you wish to scale your observations
    SCALING_LIST = []  # List containing scale that you want to apply to each observation

    def get_all_options_dict(self):
        dict = {
            'network_type': self.NETWORK_TYPE,
            'batch_size': self.BATCH_SIZE,
            'replay_memory_size': self.REPLAY_MEMORY_SIZE,