Flappy-Bird-Genetic-Algorithms icon indicating copy to clipboard operation
Flappy-Bird-Genetic-Algorithms copied to clipboard

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

Open ghost opened this issue 6 years ago • 1 comments

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 predict_action() 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

ghost avatar Dec 21 '17 05:12 ghost

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

AroMorin avatar May 25 '18 17:05 AroMorin