<commit_before>__author__ = 'gilbert'

import gym
env = gym.make('CartPole-v0')
for i_episode in xrange(20):
    observation = env.reset()
    for t in xrange(100):
        env.render()
        print observation
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print "Episode finished after {} timesteps".format(t+1)
            break
<commit_msg>Creating base q learner class<commit_after>__author__ = 'gilbert'


"""
Based off of q controller from here:
http://pages.cs.wisc.edu/~finton/qcontroller.html
"""

import gym
import random
import numpy as np

class QAgent:

    def __init__(self):

        #Constants
        self.W_INIT = 0.0
        self.NUM_BOXES = 162

        self.ALPHA = 0.5 #Learning Rate Parameter
        self.BETA = 0.0 #Magnitude of noise added to choice
        self.GAMMA = 0.999 #Discount factor for future reinforcement

        self.random_seed = 1
        random.seed(self.random_seed)


        self.q_val = np.array([[self.NUM_BOXES],[self.NUM_BOXES]], np.float) #state-action values

        self.first_time = False

        self.cur_action = -1
        self.prev_action = -1
        self.cur_state = 0
        self.prev_state = 0

    def print_controller_information(self):
        print("Firing up controller with ALPHA to %f" % self.ALPHA)
        print("BETA: %f" % self.BETA)
        print("GAMMA: %f" % self.GAMMA)
        print("Random Seed: %d" % self.random_seed)

    def reset_controller(self):
        self.cur_state, self.prev_state = 0;
        self.cur_action, self.prev_action = -1

    def get_box(self):
        return 0


    def get_action(self, observation, reward):
        return 0








agent = QAgent()
agent.print_controller_information()

#env = gym.make('CartPole-v0')

{'fraction_non_alphanumeric': 0.10842047330764998, 'fraction_numerical': 0.01651073197578426, 'mean_word_length': 2.469465648854962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3444017', 'n_tokens_mistral': 633, 'n_tokens_neox': 581, 'n_words': 146}