How to change the gravity direction in Unity3D. How to make the objects fly in Unity.
So let’s start with something simple.
We make our object fly up on space bar button click.
Today we are going to implement some camera settings for our game. We want the camera to follow the player.
There are many possibilities to achieve something like this, so we gonna try some of them.
The simplest approach of them all is to set the camera object behind our player object and make our object the parent.
How to make the player Object Jump when we press Space button on our Keyboard.
For Example, we got our player Object. The player Object ist just a simple Sphere Object with Red material on it.
The first approach in the OpenAI Retro Contest which I started to implement, test and modify was the JERK approach. Jerk agent is one of the baseline scripts for this contest.
You can find it here: https://github.com/openai/retro-baselines
I think it is the easiest algorithm to understand for programmers who doesn’t have any Machine Learning experience.
The pseudo-code for the JERK algorithm looks like this:
Why is this the easiest approach? Because this algorithm is based on rewards. But not the same kind of rewards like rainbow or ppo2. JERK algorithm has the moves already scripted before. It doesn’t learn the same way like the two others. Sonic runs forward and jumps and if it scores points or progresses on the level further it gets rewarded. It learns based on rewards and tries to not make the mistakes again, because making a mistake will cost him “reward points”. It’s somehow like with us, humans. We are motivated to do something if we get a possible reward at the end.
Installing Docker on Windows 10 for Education
We installed our gym retro and got our sonic game running with simple algorithm.
PS: It’s actually computer playing sonic by running this script:
import gym_remote.exceptions as gre import gym_remote.client as grc from retro import make def main(): print('connecting to remote environment') env = make(game='SonicTheHedgehog-Genesis', state='GreenHillZone.Act1') print('starting episode') env.reset() while True: env.render() action = env.action_space.sample() action = 1 ob, reward, done, _ = env.step(action) if done: print('episode complete') env.reset() if __name__ == '__main__': try: main() except gre.GymRemoteError as e: print('exception', e)
We want now to upload our agent to the server and we can do it through Docker.
PS2: The above example wont work on server because we use local enviroment!
from retro import make and env = make(game=’SonicTheHedgehog-Genesis’, state=’GreenHillZone.Act1′)
Follow the instructions on page:
Because of Personal Settings i would suggest to register account and log in first.
This way you get auto-fill of this form:
export DOCKER_REGISTRY=<docker registry url> docker login >$DOCKER_REGISTRY \ --username <docker registry username> \ --password <docker registry password>
For test purposes i would first curl the files:
mkdir simple-agent cd simple-agent curl -O https://contest.openai.com/static/simple-agent.py curl -O https://contest.openai.com/static/simple-agent.docker docker build -f simple-agent.docker -t $DOCKER_REGISTRY/simple-agent:v1 .
docker push $DOCKER_REGISTRY/simple-agent:v1
The next thing are local evaluations.
docker pull openai/retro-env docker tag openai/retro-env remote-env
and running the agent:
retro-contest run --agent $DOCKER_REGISTRY/simple-agent:v1 \ --results-dir results --no-nv --use-host-data \ SonicTheHedgehog-Genesis GreenHillZone.Act1
If you run all this in git-bash, there is a possibility that you can’t close the agent.
I would than open new terminal and wrote:
docker ps # get the id of the running container docker stop <container> # kill it (gracefully)
This way if you did something wrong you get an error message saying what went wrong.
You can see the scores and logs of the local evaluation if you open results folder and look at the log.csv and monitor.csv
If the local evaluation went good, we can upload the same agent on the page.
Go to “Jobs” on page and submit your agent:
If you want to upload your scenario.json with your jerk agent and include it in your agent i was told it is not possible. With the jerk agent from retro/baselines we can only edit the script. We can’t modify the scenario.json file.
To run the docker you need to have docker app installed.
Before configuration docker for windows i would suggest to create an account password. Account password is needed to configure docker app.
Other Blog posts on the same topic:
Tensorflow PPO2 Algorithm
Configuring on Mac:
Building your own Images: