Skip to content

Instantly share code, notes, and snippets.

View tjacobs's full-sized avatar

Tom Jacobs tjacobs

View GitHub Profile
# OpenAI Gym Cartpole implementation.
# Using a Policy Gradient and a 2-node 2-layer network.
# By Tom Jacobs
#
# Runs on Python 3.
# Originally based on https://github.com/kvfrans/openai-cartpole
# You can submit it to the OpenAI Gym scoreboard by entering your OpenAI API key and enabling submit below.
# It will submit only if it is considered solved.
import tensorflow as tf
@tjacobs
tjacobs / cartpole-policygradient.py
Created May 29, 2017 03:12
Cartpole Policy Gradient
# OpenAI Cartpole implementation.
# Using a Policy Gradient.
# By Tom Jacobs
#
# Runs on Python 3.
# Originally based on https://github.com/kvfrans/openai-cartpole
# You can submit it to the OpenAI Gym scoreboard by entering your OpenAI API key and enabling submit below.
# It will submit only if it is considered solved.
@tjacobs
tjacobs / cartpole.py
Created May 28, 2017 07:37
Random Mutation Cartpole implementation
# OpenAI Cartpole implementations.
# By Tom Jacobs
#
# Two methods:
# 1. Random: It just tries random parameters, and picks the first one that gets a 200 score.
# 2. Mutation: It starts with random parameters, and adds a 50% mutation on the best parameters found, each time.
#
# Runs on Python 3.
# Originally based on https://github.com/kvfrans/openai-cartpole
@tjacobs
tjacobs / cartpole.py
Created May 28, 2017 06:01
Tom's Implementation
# Cartpole implementation.
# It just tries random parameters, and picks the first one that gets a 200 score.
# Runs on Python 3.
# You can switch submitting on and off.
# By Tom Jacobs
import gym
import numpy as np
import matplotlib.pyplot as plt