Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# @Author: fyr91 | |
# @Date: 2019-10-22 15:05:15 | |
# @Last Modified by: fyr91 | |
# @Last Modified time: 2019-10-30 11:25:26 | |
import cv2 | |
import numpy as np | |
import onnx | |
import onnxruntime as ort | |
from onnx_tf.backend import prepare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DZBEnv(gym.Env): | |
metadata = {'render.modes': ['human']} | |
default_settings = { | |
'map_name': "DefeatZerglingsAndBanelings", | |
'players': [sc2_env.Agent(sc2_env.Race.terran), | |
sc2_env.Bot(sc2_env.Race.zerg, sc2_env.Difficulty.hard)], | |
'agent_interface_format': features.AgentInterfaceFormat( | |
action_space=actions.ActionSpace.RAW, | |
use_raw_units=True, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
from gym import spaces | |
from pysc2.env import sc2_env | |
from pysc2.lib import actions, features, units | |
import logging | |
import numpy as np | |
logger = logging.getLogger(__name__) | |
class DZBEnv(gym.Env): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
from gym import error, spaces, utils | |
from gym.utils import seeding | |
class FooEnv(gym.Env): | |
metadata = {'render.modes': ['human']} | |
def __init__(self): | |
# usually action and observation space will be defined here | |
# self.action_space = spaces.Discrete() ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'name': 'surly-chestnut-dachsbracke', 'gene': '10011011100101100101', 'combat_power': 12, 'score': 51} | |
{'name': 'wimpy-indigo-falcon', 'gene': '00111010101110011111', 'combat_power': 12, 'score': 51} | |
{'name': 'stinky-tomato-kingfisher', 'gene': '10011011100101100101', 'combat_power': 11, 'score': 51} | |
{'name': 'hazy-russet-lizard', 'gene': '00111010101110011111', 'combat_power': 13, 'score': 51} | |
{'name': 'seedy-apricot-yak', 'gene': '10011011110100001000', 'combat_power': 9, 'score': 51} | |
{'name': 'tasty-chartreuse-chinchilla', 'gene': '00011001101001010000', 'combat_power': 7, 'score': 51} | |
{'name': 'chummy-emerald-mayfly', 'gene': '00000100001101101101', 'combat_power': 8, 'score': 51} | |
{'name': 'homey-amethyst-rhinoceros', 'gene': '00000010011000111100', 'combat_power': 7, 'score': 51} | |
{'name': 'cranky-harlequin-tetra', 'gene': '00000000101110110000', 'combat_power': 6, 'score': 51} | |
{'name': 'squirrely-bistre-wasp', 'gene': '01110001100010101010', 'combat_power': 9, 'score': 51} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'name': 'surly-chestnut-dachsbracke', 'gene': '10011011100101100101', 'combat_power': 12, 'score': 51} | |
{'name': 'wimpy-indigo-falcon', 'gene': '00111010101110011111', 'combat_power': 12, 'score': 51} | |
{'name': 'stinky-tomato-kingfisher', 'gene': '10011011100101100101', 'combat_power': 11, 'score': 51} | |
{'name': 'hazy-russet-lizard', 'gene': '00111010101110011111', 'combat_power': 13, 'score': 51} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutates = [] | |
cutoff_score = mutation_pool[-1].score | |
for lineup in mutation_pool: | |
mutates.append(mutate(lineup, cutoff_score)) | |
population.extend(mutates) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mutation | |
def mutate(lineup, score, prob=0.9): | |
gene = deepcopy(lineup.gene) | |
# if probability not greater than 0.9 | |
# flip 0s | |
if np.random.random(1)[0] <= prob: | |
zero_idx = np.where(gene==0)[0] | |
if len(zero_idx) > 0: | |
idx = np.random.choice(zero_idx) | |
gene[idx] = 1 |
NewerOlder