Exemple #1
0
import numpy as np
import os
import time
# os.environ["SDL_VIDEODRIVER"] = "dummy"
from collections import deque
from keras.models import Model, load_model, Sequential, load_model
from keras.layers import Input, Dense, Conv2D, Flatten
from keras.optimizers import Adam, RMSprop
import time
import keras
import matplotlib.pyplot as plt

from skimage.transform import resize
from skimage.color import rgb2gray
env = GameEnv()
stateSize = len(env.reset())
fakeState = env.reset()
print(stateSize)
env.getGameState()
# PREPROCESSING HYPERPARAMETERS
stack_size = 8  # Number of frames stacked
# MODEL HYPERPARAMETERS
action_size = 4  # 4 possible actions

# Initialize deque with zero-images one array for each image
stacked_frames = deque(
    [np.zeros((stateSize), dtype=np.int) for i in range(stack_size)],
    maxlen=stack_size)


def stack_frames(stacked_frames, state, is_new_episode):
Exemple #2
0
from game import GameEnv
import random

env = GameEnv(1 / 60)
env.stepReward = 0
env.playerShotReward = 0
env.enemyShotReward = 0
env.missedShotReward = 0
env.allDeadReward = 0
env.invasionReward = 0
env.bottomReward = 0
env.underReward = 0
env.anchorReward = 0
env.cornerReward = -0.001
env.reset()
actions = [i for i in range(4)]
done = False

# print(env.reset())
env.loop()


def randMove():
    done = False
    while not done:
        state, reward, done, win = env.step(random.sample(actions, 1)[0])


# for i in range(4):
#     env.reset()
#     randMove()