Commit Graph

53 Commits

Author SHA1 Message Date
Mark Towers
bf093c6890 Update the flake8 pre-commit ignores (#2778)
* Remove additional ignores from flake8

* Remove all unused imports

* Remove all unused imports

* Update flake8 and pyupgrade

* F841, removed unused variables

* E731, removed lambda assignment to variables

* Remove E731, F403, F405, F524

* Remove E722, bare exceptions

* Remove E712, compare variable == True or == False to is True or is False

* Remove E402, module level import not at top of file

* Added --pre-file-ignores

* Add --per-file-ignores removing E741, E302 and E704

* Add E741, do not use variables named ‘l’, ‘O’, or ‘I’ to ignore issues in classic control

* Fixed issues for pytest==6.2

* Remove unnecessary # noqa

* Edit comment with the removal of E302

* Added warnings and declared module, attr for pyright type hinting

* Remove unused import

* Removed flake8 E302

* Updated flake8 from 3.9.2 to 4.0.1

* Remove unused variable
2022-04-26 11:18:37 -04:00
Ariel Kwiatkowski
bc17d9f7e7 Make pygame optional in classic control and toy text envs (#2712)
* Moved pygame imports into render

* Formatting
2022-03-31 18:55:48 -04:00
Andrea PIERRÉ
e913bc81b8 Improve pre-commit workflow (#2602)
* feat: add `isort` to `pre-commit`

* ci: skip `__init__.py` file for `isort`

* ci: make `isort` mandatory in lint pipeline

* docs: add a section on Git hooks

* ci: check isort diff

* fix: isort from master branch

* docs: add pre-commit badge

* ci: update black + bandit versions

* feat: add PR template

* refactor: PR template

* ci: remove bandit

* docs: add Black badge

* ci: try to remove all `|| true` statements

* ci: remove lint_python job

- Remove `lint_python` CI job
- Move `pyupgrade` job to `pre-commit` workflow

* fix: avoid messing with typing

* docs: add a note on running `pre-cpmmit` manually

* ci: apply `pre-commit` to the whole codebase
2022-03-31 15:50:38 -04:00
Andrew Tan Jin Shen
6f1ec7cc1b Fix issues with pygame event handling (#2684)
* Fix issues with pygame event handling

* Fix display initialization and exit for jupyter
2022-03-11 11:37:04 -05:00
Markus
8d4dff1b66 Locked framerate in human-mode rendering with PyGame (#2649)
* Locked framerate in human-mode rendering for box2d and classic_control

* Fixed pyright errors

* Use the new metadata key for FPS, add toytext environments
2022-03-02 10:37:48 -05:00
trigaten
35b78ac0ab Rename render modes/fps (#2654)
* Update pendulum.py

* version warnings

* black

* try except

* update notices version

* Exception

* nosec

* black

* no loop, stderr

* black

* convert ## to ###

* correct subheader

* black

* despace

* spacing

* frozen lake fixes

* rename render modes/fps

* fix API test

* fix API test

* fix more API tests

* black

* add render fps
2022-02-28 15:54:03 -05:00
Rushiv Arora
649a245465 Fixed tests and precommit (#2653) 2022-02-28 08:54:16 -05:00
Andrew Tan Jin Shen
87abbcc787 Fix minor bug with Cartpole (#2609)
* Refactor Car Racing to use pygame

* Refactor to clean up code and minor issues

* Black reformat

* Fix bug with state
2022-02-11 11:16:48 -05:00
Andrew Tan Jin Shen
6eba48db95 Refactor classic control rendering to use pygame (#2599)
* refactor classic control rendering to use pygame

* Rebase from upstream

* Revert deletion from rebasing

* Remove pyglet
2022-02-11 10:48:42 -05:00
Ilya Kamen
2be9e60a4d Typecheck classic control environments (#2589)
* Typecheck classic control environments

* consistent imports + comments

* Don't use seed method

Although this code is exact duplication, we at least don't call deprecated method.

* Update core.py
2022-02-10 12:24:41 -05:00
John Balis
15049e22d7 Adding return_info argument to reset to allow for optional info dict as a second return value (#2546)
* initial draft of optional info dict in reset function, implemented for cartpole, tests seem to be passing

* merged core.py

* updated return type annotation for reset function in core.py

* optional metadata with return_info from reset added for all first party environments, with corresponding tests. Incomplete implementation for wrappers and vector wrappers

* removed Optional type for return_info arguments

* added tests for return_info to normalize wrapper and sync_vector_env

* autoformatted using black

* added optional reset metadata tests to several wrappers

* added return_info capability to async_vector_env.py and test to verify functionality

* added optional return_info test for record_video.py

* removed tests for mujoco environments

* autoformatted

* improved test coverage for optional reset return_info

* re-removed unit test envs accidentally reintroduced in merge

* removed unnecessary import

* changes based on code-review

* small fix to core wrapper typing and autoformatted record_epsisode_stats

* small change to pass flake8 style
2022-02-06 18:28:27 -05:00
trigaten
a149869bcb docs+credits (#2574)
* docs+credits

* docs: refactor box2d + comment version history

* fix mujoco line lengths

* fix more env line lengths

* black

* typos

Co-authored-by: Andrea PIERRÉ <andrea_pierre@brown.edu>
2022-01-26 16:02:42 -05:00
Ariel Kwiatkowski
925823661d Add options to the signature of env.reset (#2515)
* First find/replace, now tests

* Fixes to the vector env

* Make seed keyword only in wrappers

* (try to) fix the bug with old environments using new wrappers (with the seed keyword)

* black

* Change **kwargs to options, try to make it work; black

* Add OrderEnforcing wrapper to wrapper exports
Add a test for compatibility with old (pybullet-like) envs

* Add OrderEnforcing wrapper to wrapper exports
Add a test for compatibility with old (pybullet-like) envs
black

* Update the env checker

* Update the env checker

* Update the env checker to use inspect (might fail tests, let's see)

* Allow the signature to include kwargs in env_checker

* Minor fix
2022-01-19 17:28:59 -05:00
Carlos Luis
8a96440084 Move rendering.py to utils (#2551)
* Move rendering.py to utils

* Rename rendering.py to pyglet_rendering.py
2022-01-06 13:01:29 -05:00
Brendan King
9c0808eb9a Adding documentation for CartPole-v1 in docs/classic_control (#2509)
* Adding documentation for CartPole-v1 in docs/classic_control

* typo

Co-authored-by: J K Terry <justinkterry@gmail.com>
2021-12-20 02:06:24 -05:00
Ariel Kwiatkowski
c364506710 Seeding update (#2422)
* Ditch most of the seeding.py and replace np_random with the numpy default_rng. Let's see if tests pass

* Updated a bunch of RNG calls from the RandomState API to Generator API

* black; didn't expect that, did ya?

* Undo a typo

* blaaack

* More typo fixes

* Fixed setting/getting state in multidiscrete spaces

* Fix typo, fix a test to work with the new sampling

* Correctly (?) pass the randomly generated seed if np_random is called with None as seed

* Convert the Discrete sample to a python int (as opposed to np.int64)

* Remove some redundant imports

* First version of the compatibility layer for old-style RNG. Mainly to trigger tests.

* Removed redundant f-strings

* Style fixes, removing unused imports

* Try to make tests pass by removing atari from the dockerfile

* Try to make tests pass by removing atari from the setup

* Try to make tests pass by removing atari from the setup

* Try to make tests pass by removing atari from the setup

* First attempt at deprecating `env.seed` and supporting `env.reset(seed=seed)` instead. Tests should hopefully pass but throw up a million warnings.

* black; didn't expect that, didya?

* Rename the reset parameter in VecEnvs back to `seed`

* Updated tests to use the new seeding method

* Removed a bunch of old `seed` calls.

Fixed a bug in AsyncVectorEnv

* Stop Discrete envs from doing part of the setup (and using the randomness) in init (as opposed to reset)

* Add explicit seed to wrappers reset

* Remove an accidental return

* Re-add some legacy functions with a warning.

* Use deprecation instead of regular warnings for the newly deprecated methods/functions
2021-12-08 16:14:15 -05:00
Elijah K
eec6167440 Py36+ syntax in gym/envs: derived by running pyupgrade --py36-plus gym/envs/**.py and flynt gym --ll 120 (#2465)
Co-authored-by: Ilya Kamen <ilya.kamenshchikov@bosch.com>
2021-11-13 19:53:32 -05:00
Ariel Kwiatkowski
d7023500f3 Fix dtypes to be consistent with observation_space (#2340)
* Changed the dtypes of classic control envs to float32

* Fixed formatting via black

* Added dtype tests

* Formatting, and test error message

* Only test dtypes for Box space

* Fix Bipedal Walker and Car Racing

* Undo the car racing dtype change

* Redo the car racing dtype change - set to np.float32, and updated observation_space to reflect it
2021-08-21 18:11:19 -04:00
J K Terry
78d2b512d8 redo black (#2272) 2021-07-29 15:39:42 -04:00
Justin Terry
e9d2c41f2b redo black 2021-07-29 12:42:48 -04:00
Christian Clauss
bb81e141ea Blacken the codebase (#2265) 2021-07-28 20:26:34 -04:00
Benedikt S. Vogler
679f1a7aba Pole balancing documentation of observation matches code (#1914)
* documentation matches code

The returned angle is returned in the unit of radians and not degrees.

* use tabs for indent
2020-06-19 15:18:19 -07:00
Raphael Van Hofffelen
65ae8f8f6b changed "reward" to the correct term "return" (#1946) 2020-06-12 14:14:35 -07:00
Pierluigi Urru
6fd99ba8ba Change tabs into spaces (#1932)
Tabs were mixed up with spaces, resulting in the file being weirdly formatted in editors were tabs are not rendered with 4 spaces (e.g. GitHub https://github.com/openai/gym/edit/master/gym/envs/classic_control/mountain_car.py)
2020-05-29 14:02:22 -07:00
InstanceLabs
819f25c0e2 Clean up cartpole environment. (#1875)
Co-authored-by: Peter Zhokhov <peterz@openai.com>
2020-05-08 13:03:48 -07:00
Dan Timbrell
3bd5ef71c2 Clean some docstrings (#1854)
* add type of argument

* fix typos

* split lines for formatting

* reformat string, add ellipsis, remove r string

* make docstring stylistically consistent

* make docstrings a little more elaboratet

* reduce by 1 space

* make line wrap 120

* remove unnecessary line

* add returns to docstring

* add docstring, make code more pep8 and delete some unused print functions

* more pep8

* file docstring instead of comments

* delete unused variables, add file docstring and add some pep8 spring cleaning

* add file docstring, fix typos and add some pep8 correections

Co-authored-by: Dan <daniel.timbrell@ing.com>
2020-04-24 16:10:27 -05:00
Xingdong Zuo
a14e1c7292 Fix unnecessary warnings (#1800)
* Update pendulum.py

* Update continuous_mountain_car.py

* Update cartpole.py

* Update mujoco_env.py

* Update mountain_car.py

* Update acrobot.py
2020-02-29 01:11:29 +01:00
Benjamin Danek
57187307f1 Update cartpole.py (#1263) 2019-02-08 16:45:48 -08:00
pzhokhov
07e0c98f8e python27 tests (#1314)
* add py27 test environment (sans box2d and atari)

* skip mujoco tests if mujoco_py not present

* re-enable python3 tests

* remove unicode symbols

* remove more unicode symbols
2019-02-08 11:46:51 -08:00
Charles Packer
094e6b8e6a CartPole/Acrobot rendering fix (#1189)
* Fixed rendering to properly display modifications to length etc

* 'self.length is half the pole's length'

* Explicitly base viewer size on Acrobot link size

* Made correct polygon rendering work for different link lengths
2018-10-18 14:30:18 -07:00
Alex
42f9e14c00 Updated Calculation Order (#1019)
* Updated order Calculation

Updated order of `x` and `theta` calculations so that they are no longer one timestamp behind `x_dot` and `theta_dot`.

https://github.com/openai/gym/issues/1018

* Added semi-implicit euler option

* Got implicit and standard euler mixed up

* switched default option
2018-09-21 15:19:40 -07:00
Madhavun
3ff851fe21 Added explicit dtype to observation_space (#1084)
To suppress warning coming from line 31 of spaces.Box
2018-09-17 10:28:02 -07:00
cfperez
243226bee0 Fix env.close() to allow re-opening window (#1155) 2018-09-14 13:36:57 -07:00
pzhokhov
4fada72689 Update cartpole.py 2018-09-14 13:35:08 -07:00
Chris Miles
75f28faf9b Update docstrings of environment classes (#1123)
* update reference to Sutton and Barto in docstring of CliffWalkingEnv class

* update reference to Sutton and Barto in docstring of BlackjackEnv class

* added detailed description of taxi environment in doc string

* Fixed typo. I swapped north and south in actions list

* placed wiki description of cartpole to a docstring

* fixed formatting in docstring

* fixed formating in docstring
2018-08-24 16:30:17 -07:00
John Schulman
4c460ba6c8 Cleanup, removal of unmaintained code (#836)
* add dtype to Box

* remove board_game, debugging, safety, parameter_tuning environments

* massive set of breaking changes
- remove python logging module
- _step, _reset, _seed, _close => non underscored method
- remove benchmark and scoring folder

* Improve render("human"), now resizable, closable window.

* get rid of default step and reset in wrappers, so it doesn’t silently fail for people with underscore methods

* CubeCrash unit test environment

* followup fixes

* MemorizeDigits unit test envrionment

* refactored spaces a bit
fixed indentation
disabled test_env_semantics

* fix unit tests

* fixes

* CubeCrash, MemorizeDigits tested

* gym backwards compatibility patch

* gym backwards compatibility, followup fixes

* changelist, add spaces to main namespaces

* undo_logger_setup for backwards compat

* remove configuration.py
2018-01-25 18:20:14 -08:00
Sam Stites
92a17bdea2 Update links to Sutton's new homepage (perma where possible) (#577) 2017-06-14 13:27:42 -07:00
Trevor Blackwell
8c6468b34d Don't crash if render called before reset 2017-02-27 10:00:48 -08:00
John Schulman
a67653ccb1 cartpole fix (#457)
minor fixes related to configure() and cartpole
2017-01-03 23:19:14 -08:00
Rafael Cosman
1e86e73919 fixes cartpole observation_space (#210) 2016-06-20 13:42:06 -07:00
Jie Tang
8a545eeb59 Tighten assertions (#197) 2016-06-16 00:12:47 -07:00
Greg Brockman
2aa03d6088 Add configure method to Env, and support multiple displays in CartPole (#175)
* Add configure method to Env, and support multiple displays in CartPole

This allows people to pass runtime specification which doesn't affect
the environment semantics to environments created via `make`.

Also include an example of setting the display used for CartPole

* Provide full configure method

* Allow environments to require configuration

* Don't take arguments in make
2016-06-12 20:56:21 -07:00
Jie Tang
7605986f09 Push up x_threshold to silence warnings: fixes #88 2016-06-09 16:22:15 -07:00
Oleg Klimov
72d89cb22f Faster video recording (#119)
* Faster video recording

* rendering.py: return_rgb_array default to False, for other environments not to break
2016-06-06 00:06:26 -07:00
Greg Brockman
8a535ca6f2 Switch to a global PRNG for action/observation spaces (#144)
cf 58e6aa95e5 (commitcomment-17669277)
2016-05-30 18:07:59 -07:00
Greg Brockman
58e6aa95e5 [WIP] add support for seeding environments (#135)
* Make environments seedable

* Fix monitor bugs

- Set monitor_id before setting the infix. This was a bug that would yield incorrect results with multiple monitors.
- Remove extra pid from stats recorder filename. This should be purely cosmetic.

* Start uploading seeds in episode_batch

* Fix _bigint_from_bytes for python3

* Set seed explicitly in random_agent

* Pass through seed argument

* Also pass through random state to spaces

* Pass random state into the observation/action spaces

* Make all _seed methods return the list of used seeds

* Switch over to np.random where possible

* Start hashing seeds, and also seed doom engine

* Fixup seeding determinism in many cases

* Seed before loading the ROM

* Make seeding more Python3 friendly

* Make the MuJoCo skipping a bit more forgiving

* Remove debugging PDB calls

* Make setInt argument into raw bytes

* Validate and upload seeds

* Skip box2d

* Make seeds smaller, and change representation of seeds in upload

* Handle long seeds

* Fix RandomAgent example to be deterministic

* Handle integer types correctly in Python2 and Python3

* Try caching pip

* Try adding swap

* Add df and free calls

* Bump swap

* Bump swap size

* Try setting overcommit

* Try other sysctls

* Try fixing overcommit

* Try just setting overcommit_memory=1

* Add explanatory comment

* Add what's new section to readme

* BUG: Mark ElevatorAction-ram-v0 as non-deterministic for now

* Document seed

* Move nondetermistic check into spec
2016-05-29 09:07:09 -07:00
Greg Brockman
2ae0dbc846 Discard viewer object after render with close=True
Fixes #95
2016-05-15 17:22:38 -07:00
JKCooper2
d2d940bddb Cartpole observations can occur outside of observation space limits - Issue #88 (#89)
* Set restriction on selected actions

* Used self.action_space instead of custom set

* Move action validation to core.py

* Fix for Cartpole observations outside of observation_space
2016-05-11 14:50:35 +02:00
Josh Marlow
7908761a60 Removed legacy super() rendering calls (#78) 2016-05-09 18:06:48 -07:00
Josh Marlow
9529fa731b Replaced is string comparison with == (#77) 2016-05-09 17:51:04 -07:00