Skip to content

Instantly share code, notes, and snippets.

View sunskyhsh's full-sized avatar

sunsky sunskyhsh

View GitHub Profile
@sunskyhsh
sunskyhsh / algorithm.py
Created December 29, 2016 13:22
qlearning algorithm to solve CartPole on openAI gym.
def qlearning(env, policy, num_iter1, alpha, gamma):
actions = policy.actions
for i in xrange(len(policy.theta)):
policy.theta[i] = 0.1
for iter1 in xrange(num_iter1):
s_f = env.reset()
a = policy.epsilon_greedy(s_f)
count = 0
t = False
# coding: utf-8
#
# This is a solution to
# https://chyyuu.gitbooks.io/os_course_exercises/content/all/04-1-spoc-discussion.html#虚拟页式存储的地址转换
#
# Author: github.com/sunskyhsh
import sys
def translate(va, pd):
#! /usr/bin/env python
# author: github.com/sunskyhsh
import sys
from optparse import OptionParser
import random
# process states
STATE_RUNNING = 'RUNNING'
STATE_READY = 'READY'