Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
#!/usr/bin/env python
"""
Train an agent on Sonic using an open source Rainbow DQN
implementation.
"""
import tensorflow as tf
from anyrl.algos import DQN
#!/usr/bin/python
import sys
import retro
from os import listdir
from os.path import isfile, join, isdir
def render(file):
movie = retro.Movie(file)
from retro.scripts.playback_movie import main
main()
export DOCKER_REGISTRY="retrocontestxxxxxxxxxxxxxx"
docker login $DOCKER_REGISTRY \
--username "xxxxxxxxxxxxx" \
--password "xxxxxxxxxxxxx"
docker build -f rainbow-agent.docker -t $DOCKER_REGISTRY/rainbow-agent:v1 .
docker push $DOCKER_REGISTRY/rainbow-agent:v1
retro-contest run --agent $DOCKER_REGISTRY/rainbow-agent:v1 \
def step(self, a):
# ... does all the stuff
rew, done, info = self.compute_step(ob)
return ob, float(rew), bool(done), dict(info)
def move(env, num_steps, left=False, jump_prob=1.0 / 10.0, jump_repeat=4):
"""
Move right or left for a certain number of steps,
jumping periodically.
"""
_, rew, done, _ = env.step(action)
total_rew += rew
steps_taken += 1
return total_rew, done
while True:
# ...
rew, new_ep = move(env, 100)
if not new_ep and rew <= 0:
print('backtracking due to negative reward: %f' % rew)
_, new_ep = move(env, 70, left=True)
def merge(*args, quiet=True):
import retro
known_hashes = {}
for game in retro.list_games():
shafile = os.path.join(retro.get_game_path(game), 'rom.sha')
with open(shafile) as f:
shas = f.read().strip().split('\n')
for ext, platform in retro.EMU_EXTENSIONS.items():
if game.endswith('-' + platform):
break
def main():
potential_roms = []
for path in sys.argv[1:]:
for base, _, files in os.walk(sys.argv[1]):
potential_roms.extend([os.path.join(base, file) for file in files])
print('Importing %i potential games...' % len(potential_roms))
retro.data.merge(*potential_roms, quiet=False)
<?php
require_once('./connect-php-sdk-master/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\LocationsApi();
try {
$result = $api_instance->listLocations();