Beispiel #1
0
    def __init__(self, rand_seed, display=False, no_op_max=7):
        self.env = gym.make(visual=VISUAL, game=GAME)
        self.state_size = self.env.observation_space_shape
        self.action_size = len(self.env.action_space)

        self._no_op_max = no_op_max

        if display:
            self._setup_display()
        self.reset()
Beispiel #2
0
import numpy as np
from game import mygym as gym
from training.ddqn import DQNAgent
import constants
import cv2

EPISODES = 5000

if __name__ == "__main__":
    visual = constants.VISUAL
    verbose = False
    env = gym.make(visual=visual, game='CDGame')
    state_size = env.observation_space_shape
    action_size = len(env.action_space)
    agent = DQNAgent(state_size, action_size)
    # agent.load("training/save/cd-ddqn.h5")
    done = False
    batch_size = 32
    max_step = 500

    for e in range(EPISODES):
        print('Episode {}/{}'.format(e + 1, EPISODES))
        state = env.reset()
        state = np.reshape(state,
                           [1, state_size[0], state_size[1], state_size[2]])

        for time in range(max_step):
            action = agent.act(state)
            next_state, reward, done, total_reward = env.step(action)

            if visual:
Beispiel #3
0
import numpy as np
from game import mygym as gym
from training.ddqn_gw import DQNAgent
import cv2

EPISODES = 5000

if __name__ == "__main__":
    visual = True
    verbose = False
    env = gym.make(visual=visual, game='GridWorld')
    state_size = env.observation_space_shape
    action_size = len(env.action_space)
    agent = DQNAgent(state_size, action_size)
    # agent.load("training/save/gw-ddqn.h5")
    done = False
    batch_size = 32
    max_step = 500

    for e in range(EPISODES):
        print('Episode {}/{}'.format(e + 1, EPISODES))
        state = env.reset()
        state = np.reshape(state, [1, state_size])

        for time in range(max_step):
            action = agent.act(state)
            next_state, reward, done, total_reward = env.step(action, agent)
            next_state = np.reshape(next_state, [1, state_size])
            if visual:
                cv2.imshow('state', next_state)
                cv2.waitKey(10)
Beispiel #4
0
import game.mygym as gym
import pygame
import cv2

if __name__ == '__main__':
    env = gym.make()
    state = env.reset()

    carryOn = True
    while carryOn:
        next_state, reward, done, _ = env.step(2)
    pygame.quit()