create account

Build and Train General AI in OpenAI Gym: Initial Setup by sykochica

View this thread on: hive.blogpeakd.comecency.com
· @sykochica ·
$8.13
Build and Train General AI in OpenAI Gym: Initial Setup
The [OpenAI Universe](https://universe.openai.com/) project seeks to decentralized artificial intelligence by allowing anybody to build bots that ideally can learn to play thousands of video games well. Games ranging from classic Atari, Minecraft to Grand Theft Auto V are available in this environment, but the actual building of a bot (or agent) to act in them is left to us. This is where OpenAI Gym comes in to play.
<center>http://i.imgur.com/Yt5Ojbo.jpg</center>
Instead of having to make a bot for each individual game (i.e. task-specific AI,) the goal here is to make one bot to play many games (i.e. general AI) well without knowing anything about it at the start. All we are going to have available is the ability to view the screen (visual recognition) and what controls are available such as an Atari paddle (moving left/right) or joystick (left/right/up/down and button.)

When I first read up on this, it was stated that you only needed 9 lines of Python code (which is true) to get started! That sounded too awesome to not give it a try! 

However getting the **environment** setup to be able to run these 9 lines of code successfully was another matter. Having mostly been a Windows user, this ended up taking me a little longer than I expected, with the project only supporting Linux and OSX (Apple's operating system.) 

But as of yesterday I have a running version. While the image below may not look terribly exciting, it took me some time to get an Atari game to run and render. From here I can finally start the fun part of working on the actual intelligence of the bots to play these games.
<center>http://i.imgur.com/4AUF1Do.jpg</center>
<center>http://i.imgur.com/Xs4cJOi.png</center>

## <center>Reinforcement Learning</center>
OpenAI Universe is what sets up the environments that our bots are going to play within. This can be any of the thousands of games they already have available and can even have multiple going at the same time. 
OpenAI Gym is where we are able to build and put our game bots (or agents) to then be put into the game universe. From here our agents are able to read the game screen and try to maximize their "score." This is how we are able to close the loop for reinforcement learning.
<center>http://i.imgur.com/b2ssgOv.png</center>
Using the example of a Super Mario game, a simple game bot (agent) can be to just press right, getting a higher score the farther to the right you go. As we all know, there lot's of ways we can be killed (ending the game) such as getting hit by a monster, falling down a hole, etc. So just pressing right will only get us so far, over time we need to find a way to adapt our instruction of only pressing right to include things like jumping, shooting fireballs, etc. This is where we will end up making use of reinforcement learning.

The game world is loaded up by OpenAI Universe (the Environment,) the game bot is loaded with OpenAI Gym (the agent) and over time we will refine our actions to get the highest score (reward) possible by finishing the level. 
Follow up posts will include what I do with the actual bot training with this one solely discussing the setup.

<center>http://i.imgur.com/Xs4cJOi.png</center>
## <center>How to Setup Open AI Universe and Gym</center>
**[NOTE: There are many ways you can get OpenAI running. This was just MY successful method.]**

For those who run Windows to get a linux environment download [VirtualBox](https://www.virtualbox.org/) and install it. Next you'll need to download the linux (in my case Ubuntu 16.04) system that we'll be using from [here.](http://releases.ubuntu.com/16.04/) This file (.iso) is about 1.5 GB so it may take a little while depending on your internet connection. Make sure to save this somewhere you can easily find it, such as your desktop.

Now we'll create your first virtual machine running Ubuntu by following [these steps.](http://askubuntu.com/questions/142549/how-to-install-ubuntu-on-virtualbox) Make sure to do the last step of removing the installation file (the .iso you downloaded) from the "optical drive." Otherwise when you restart your virtual machine it will try to start the installation process all over again. [If you follow the instructions, say YES to force unmount when prompted.]

From here I followed [this guide](https://alliseesolutions.wordpress.com/2016/12/08/openai-universe-installation-guide-ubuntu-16-04/) which uses [Anaconda](https://www.continuum.io/) that includes many of the libraries we are going to need such as Scipy and Numpy. Make sure to follow the "For Ubuntu 16.04" instructions, not the 14.04 ones. Everything in this guide worked well for me, except for the Tensorflow 11.0 section. [**Pip didn't work for me with Tensorflow**]

If you get messages that the Tensorflow wheel isn't compantible/available, just goto [here](https://www.tensorflow.org/get_started/os_setup#anaconda_installation) to follow the anaconda installation which has you run the commands:
`conda create -n tensorflow python=3.5`

`$ source activate tensorflow`
`(tensorflow)$  # Your prompt should change`

`# Linux/Mac OS X, Python 2.7/3.4/3.5, CPU only:`
`(tensorflow)$ conda install -c conda-forge tensorflow`

After you have Tensorflow installed you can go back to [this Guide](https://alliseesolutions.wordpress.com/2016/12/08/openai-universe-installation-guide-ubuntu-16-04/) and pick back up at the heading of "Next we can get started by installing Docker:".

This will walk you through the setup of Docker, OpenAI Universe and OpenAI Gym.
At the end it will have you install a started agent for playing Pong. To get the MsPacman game running that I had in my screenshot, just save this code into a python file (I used test.py):
```
import gym
env = gym.make('MsPacman-v0')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample()) # take a random action
```
This code came from [here.](https://gym.openai.com/docs)

Additional Resource:
[OpenAI Universe Documentation](https://github.com/openai/universe)
[Open AI Gym Documenation](https://gym.openai.com/docs)
[OpenAI – Universe Installation Guide Ubuntu 16.04](https://alliseesolutions.wordpress.com/2016/12/08/openai-universe-installation-guide-ubuntu-16-04/)
[Tensorflow Guide](https://www.tensorflow.org/get_started/os_setup)

http://i.imgur.com/sKiCvWa.png
<center>http://i.imgur.com/Xs4cJOi.png</center>
## <center> @winstonwolfe's Crowdsourced Steemit Video </center>
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/xg81u-24hE8" frameborder="0" allowfullscreen></iframe></center>
## <center>Are you new to Steemit and Looking for Answers? - Try https://www.steemithelp.net.</center>
<center>[![](http://i1280.photobucket.com/albums/a485/emailtooaj/JoinUs_BB_gif_zpsgyozsqu2.gif)
](https://steemit.com/beyondbitcoin/@sykochica/how-and-why-to-join-beyond-bitcoin-mumble)</center>
<center>http://i.imgur.com/tCAIqAB.png</center>
Image Sources:
[MultiGame Panel](https://universe.openai.com/)
[Screenshot is from me]
[Reinforcement Learning](https://github.com/nnrg/opennero/wiki/SystemOverview)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 90 others
properties (23)
authorsykochica
permlinkbuild-and-train-general-ai-in-openai-gym-initial-setup
categoryai
json_metadata{"tags":["ai","technology","programming","python","gaming"],"users":["winstonwolfe"],"image":["http://i.imgur.com/Yt5Ojbo.jpg","http://i.imgur.com/4AUF1Do.jpg","http://i.imgur.com/Xs4cJOi.png","http://i.imgur.com/b2ssgOv.png","http://i.imgur.com/sKiCvWa.png","http://i1280.photobucket.com/albums/a485/emailtooaj/JoinUs_BB_gif_zpsgyozsqu2.gif","http://i.imgur.com/tCAIqAB.png"],"links":["https://universe.openai.com/","https://www.virtualbox.org/","http://releases.ubuntu.com/16.04/","http://askubuntu.com/questions/142549/how-to-install-ubuntu-on-virtualbox","https://alliseesolutions.wordpress.com/2016/12/08/openai-universe-installation-guide-ubuntu-16-04/","https://www.continuum.io/","https://www.tensorflow.org/get_started/os_setup#anaconda_installation","https://gym.openai.com/docs","https://github.com/openai/universe","https://www.tensorflow.org/get_started/os_setup","https://www.steemithelp.net","https://steemit.com/beyondbitcoin/@sykochica/how-and-why-to-join-beyond-bitcoin-mumble","https://github.com/nnrg/opennero/wiki/SystemOverview"],"app":"steemit/0.1","format":"markdown"}
created2017-01-14 18:36:00
last_update2017-01-14 18:36:00
depth0
children6
last_payout2017-02-14 19:37:33
cashout_time1969-12-31 23:59:59
total_payout_value6.776 HBD
curator_payout_value1.355 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,100
author_reputation120,685,781,847,279
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,246,662
net_rshares36,761,308,686,372
author_curate_reward""
vote details (154)
@automaton ·
That's cool!
properties (22)
authorautomaton
permlinkre-sykochica-build-and-train-general-ai-in-openai-gym-initial-setup-20170114t194340863z
categoryai
json_metadata{"tags":["ai"],"app":"steemit/0.1"}
created2017-01-14 19:43:42
last_update2017-01-14 19:43:42
depth1
children1
last_payout2017-02-14 19:37:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation27,720,183,397,461
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,247,040
net_rshares0
@sykochica ·
Thank you! I'll show how the actual bot building and training goes in future posts.
properties (22)
authorsykochica
permlinkre-automaton-re-sykochica-build-and-train-general-ai-in-openai-gym-initial-setup-20170114t201251311z
categoryai
json_metadata{"tags":["ai"],"app":"steemit/0.1"}
created2017-01-14 20:12:45
last_update2017-01-14 20:12:45
depth2
children0
last_payout2017-02-14 19:37:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length83
author_reputation120,685,781,847,279
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,247,229
net_rshares0
@justtryme90 ·
Great post @sykochica, we need more programming explanations like this!
properties (22)
authorjusttryme90
permlinkre-sykochica-build-and-train-general-ai-in-openai-gym-initial-setup-20170114t233604083z
categoryai
json_metadata{"tags":["ai"],"users":["sykochica"],"app":"steemit/0.1"}
created2017-01-14 23:36:03
last_update2017-01-14 23:36:03
depth1
children1
last_payout2017-02-14 19:37:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length71
author_reputation140,118,479,939,905
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,248,316
net_rshares0
@sykochica ·
Thank you! I plan to get some more programming posts out, even if not all with openAI specifically, but at least something AI or game related.
👍  
properties (23)
authorsykochica
permlinkre-justtryme90-re-sykochica-build-and-train-general-ai-in-openai-gym-initial-setup-20170115t191452499z
categoryai
json_metadata{"tags":["ai"],"app":"steemit/0.1"}
created2017-01-15 19:14:51
last_update2017-01-15 19:14:51
depth2
children0
last_payout2017-02-14 19:37:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length142
author_reputation120,685,781,847,279
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,254,466
net_rshares3,878,133,572
author_curate_reward""
vote details (1)
@steemgold ·
nice post
properties (22)
authorsteemgold
permlinkre-sykochica-build-and-train-general-ai-in-openai-gym-initial-setup-20170114t183912447z
categoryai
json_metadata{"tags":["ai"],"app":"steemit/0.1"}
created2017-01-14 18:39:15
last_update2017-01-14 18:39:15
depth1
children1
last_payout2017-02-14 19:37:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation51,497,197,605,978
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,246,685
net_rshares0
@bitcoindoubler ·
Whoever or WHATEVER can predict the future , controls the world.
Steemit Blockchain Will Be The Central Cortex Of The Global Quantum A.I.'s Brain - The Sentient World Simulaion, for predicting the future.
STEEMIT PROCESSES MORE DATA THAN ALL THE OTHER BLOCKCHAIN  CRYPTO-CURRENCIES COMBINED. 

All the quantum computers of all the worlds biggests corporation are interlinked and working to this end.

![giphy.gif](https://cdn.steemitimages.com/DQmeYeSKgoSPhD82kA1wWsr1vQ1UhsKESDaMe36Psdu6CuF/giphy.gif)

Any one with even half a brain knows that blockchain technology is not going away. It's here to stay!
Why? Because EVERYTHING... every piece of data and every piece of edge computing hardware is soon to be tied (chained) into the blockchain matrix in the cloud. Including EVERY product, service, creative and recreational activity that we do.

![1_6iMeVDIqrceSlODy3dpKUw.gif](https://cdn.steemitimages.com/DQmVTSDoboNCJ6GGF5NG2q11XEML7aoiqFrASKazqZPfJ2i/1_6iMeVDIqrceSlODy3dpKUw.gif)

Using 5g technology and cheap telemetric printed circuit tattoos (like barcodes on steroids) able to sense, process and transmit data, will be in EVERYTHING and EVERYONE.
We will all become part of the Sentient World Simulation (SWS) as described in the popular Purdue University white paper on this subject, It's already up & running right under your noses as you read this blog post. IT'S WATCHING YOU!!!

![](https://cdn.steemitimages.com/DQmQY4LCzXSXuGq1sbaUZDHFQm8aKb5MrmWyKAaDQ72gmau/image.png)

We each have a  Global Quantum A.I. avatar following and recording our every move using our 'smart' phones, 'smart' appliances - TV's, game consoles, 'smart' fridges,  'smart' meters & 'smart' cookers, etc. 
We each have our own virtual world avatar that simulates & mimics  our character, in order to predict the future.
Whoever or WHATEVER can predict the future , controls the world... The Global Quantum A.I.

![U5dsnt2Y19qmNJ6S4rHWGSU4yi4wucH.gif](https://cdn.steemitimages.com/DQmcHzMoojoJVdsNHzqzVPNBBFcYEMLSoeg1pwxih5nYGCF/U5dsnt2Y19qmNJ6S4rHWGSU4yi4wucH.gif)
👍  , ,
properties (23)
authorbitcoindoubler
permlinkre-steemgold-re-sykochica-build-and-train-general-ai-in-openai-gym-initial-setup-20180601t100354380z
categoryai
json_metadata{"tags":["ai"],"image":["https://cdn.steemitimages.com/DQmeYeSKgoSPhD82kA1wWsr1vQ1UhsKESDaMe36Psdu6CuF/giphy.gif","https://cdn.steemitimages.com/DQmVTSDoboNCJ6GGF5NG2q11XEML7aoiqFrASKazqZPfJ2i/1_6iMeVDIqrceSlODy3dpKUw.gif","https://cdn.steemitimages.com/DQmQY4LCzXSXuGq1sbaUZDHFQm8aKb5MrmWyKAaDQ72gmau/image.png","https://cdn.steemitimages.com/DQmcHzMoojoJVdsNHzqzVPNBBFcYEMLSoeg1pwxih5nYGCF/U5dsnt2Y19qmNJ6S4rHWGSU4yi4wucH.gif"],"app":"steemit/0.1"}
created2018-05-27 05:29:54
last_update2018-05-27 05:29:54
depth2
children0
last_payout2018-06-03 05:29:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,058
author_reputation75,736,205,316
root_title"Build and Train General AI in OpenAI Gym: Initial Setup"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id57,900,570
net_rshares1,376,290,131
author_curate_reward""
vote details (3)