forked from openai/retro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,243 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
################################################################################ | ||
# | ||
# Copyright (C) 2024 retro.ai | ||
# This file is part of retro3 - https://github.com/retroai/retro3 | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
# See the file LICENSE for more information. | ||
# | ||
################################################################################ | ||
|
||
name: Python CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build-and-deploy: | ||
# The type of runner that the job will run on | ||
runs-on: ${{ matrix.os }} | ||
|
||
defaults: | ||
run: | ||
# Set the working directory to frontend folder | ||
working-directory: src/learning | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
python-version: '3.11' | ||
|
||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Configure Poetry | ||
run: | | ||
poetry config virtualenvs.create false | ||
- name: Install dependencies | ||
run: | | ||
poetry install --no-root | ||
- name: Check formatting with Black | ||
run: | | ||
poetry run black --check . | ||
- name: Lint with Flake8 | ||
run: | | ||
poetry run flake8 . | ||
- name: Sort imports with isort | ||
run: | | ||
poetry run isort . --check-only | ||
- name: Type check with mypy | ||
run: | | ||
poetry run mypy . |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
################################################################################ | ||
# | ||
# Copyright (C) 2023-2024 retro.ai | ||
# This file is part of retro3 - https://github.com/retroai/retro3 | ||
# | ||
# This file is derived from OpenAI's Gym Retro under the MIT license | ||
# Copyright (c) 2017-2018 OpenAI (http://openai.com) | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later AND MIT | ||
# See the file LICENSE for more information. | ||
# | ||
################################################################################ | ||
|
||
import retro.data # noqa: F401 | ||
import retroai.brute as brute_module | ||
import retroai.enums | ||
import retroai.retro_env | ||
|
||
|
||
def main(): | ||
game = "Airstriker-Genesis" | ||
state = retroai.enums.State.DEFAULT | ||
scenario = None | ||
max_episode_steps = 4500 | ||
timestep_limit = 1e8 | ||
|
||
env = retroai.retro_env.retro_make( | ||
game, | ||
state, | ||
use_restricted_actions=retroai.enums.Actions.DISCRETE, | ||
scenario=scenario, | ||
) | ||
|
||
env = brute_module.Frameskip(env) | ||
env = brute_module.TimeLimit(env, max_episode_steps=max_episode_steps) | ||
|
||
brute = brute_module.Brute(env, max_episode_steps=max_episode_steps) | ||
timesteps = 0 | ||
best_rew = float("-inf") | ||
while True: | ||
acts, rew = brute.run() | ||
timesteps += len(acts) | ||
|
||
if rew > best_rew: | ||
print("new best reward {} => {}".format(best_rew, rew)) | ||
best_rew = rew | ||
|
||
if timesteps > timestep_limit: | ||
print("timestep limit exceeded") | ||
break | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.