def run(self, num_trials):
        tot_reward = []
        tot_steps = []
        tri_reward = 0
        num_steps = 0
        for x in xrange(num_trials):
            if x%10==0 and x>=10:
                print 'Trial',x,(sum(tot_reward[x-10:x])/10),(sum(tot_steps[x-10:x])/10)
            self.curr_state = [random.randint(0,self.num_states[0]),random.randint(0,self.num_states[1])]
            #self.curr_state = [0,0]
            tri_reward = 0
            num_steps = 0
            not_done = True
            path = []
            while(not_done):
                num_steps+=1
                best_action = nonzero(self.Q_mat[self.num_states[0]*(self.curr_state[0]) + (self.curr_state[1])]==max(self.Q_mat[self.num_states[0]*(self.curr_state[0]) + (self.curr_state[1])]))[0]
                next_action = best_action[random.randint(0,len(best_action))] if random.random() <.9 else random.randint(0,self.num_actions)
                not_done = not self.execute_action(next_action)
                tri_reward += self.get_reward(self.curr_state)
                path.append(copy.deepcopy(self.curr_state))
            tot_reward.append(tri_reward)
            tot_steps.append(num_steps)
        fig1 = pyplot.figure(1)
#        pyplot.plot(xrange(num_trials),[(sum(tot_reward[x-100:x])/100) if x >=100 else (sum(tot_reward[0:x])/x) for x in xrange(num_trials)],'r--',xrange(num_trials),[(sum(tot_steps[x-100:x])/100) if x >=100 else (sum(tot_steps[0:x])/x) for x in xrange(num_trials)],'b--')
        pyplot.plot([(sum(tot_reward[x-100:x])/100) if x >=100 else (sum(tot_reward[0:x])/x) for x in xrange(num_trials)])
        fig1.suptitle("Rewards")
        fig2 = pyplot.figure(2)
        pyplot.plot([(sum(tot_steps[x-100:x])/100) if x >=100 else (sum(tot_steps[0:x])/x) for x in xrange(num_trials)])
        fig2.suptitle("Steps")
        pyplot.show()
dataset/ETHPy150Open posborne/mlcollection/mlcollection/lib/reinforcement/reinforcement_learning_example.py/simple_RL.run/original