erilyth / Flappy-Bird-Genetic-Algorithms

Use genetic algorithms to train flappy bird
MIT License
89 stars 31 forks source link

How to port your neuroevolution code to OpenAI's Gym? #2

Open ghost opened 6 years ago

ghost commented 6 years ago

I code for hobby and want to learn about neuroevolution and came across your tutorial in google. But I have difficulty understanding what is happening with _predictaction() and showGameOverScreen() functions. I tried to read from your orginal code in github but was overwhelmed by it. It contains both the code for neuroevolution algorithm and flappy bird game engine together which makes the code unredable for a novice. I had earlier worked with OpenAI's Gym and I its easy to work with games in OpenAI's Gym especially very basic CartPole-v0. How can I port your flappy bird genetic algorithm to gym's CartPole-v0

import gym
env = gym.make('CartPole-v0')
for i_episode in range(20):
    observation = env.reset()
    for t in range(100):
        env.render()
        print(observation)
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break
AroMorin commented 6 years ago

Think about how the algorithm is evolving the weights. This will tell you how to implement the same algorithm to OpenAI Gym environment.