Commit Graph

1804 Commits

Author SHA1 Message Date
Markus Krimmel
bf0113bfa1 Improve `play` (#2819)
* Add NOOP to play, allow for unordered key combination, strings as keys

* Extended type hint
2022-05-15 09:56:06 -04:00
Andrew Tan
58081edb41 Improve performance for car racing rendering (#2821)
* Improve performance for car racing rendering

This change eliminates unnecessary drawing by pygame if it is out of bounds

* Fix format with black

* Fix out of bounds condition
2022-05-14 15:54:03 -04:00
Mark Towers
bf688c3efe Pydocstyle wrappers docstrings (#2787) 2022-05-13 08:58:19 -04:00
Mark Towers
9a5db3b77a Remove try except from box2d __init__.py as the environment have try except natively (#2816) 2022-05-12 11:18:22 -04:00
Gianluca De Cola
350a082d2f Upgrade test_determinism. Refer to #2767 (#2814) 2022-05-12 09:33:48 -04:00
Markus Krimmel
745e7059e7 Pydocstyle spaces docstring (#2798)
* Added docstrings for spaces, WIP

* Formatting changes

* Use raw docstring for Box.sample

* Formatting fix

* Formatting fix

* Use :class:, :meth:, formatting fixes, resolve TODO, use Optional
2022-05-10 11:18:06 -04:00
Mark Towers
1c62d3c6ad Add Pydocstyle to CI (#2785)
* Added pydocstyle to pre-commit

* Added docstrings for tests and updated the tests for autoreset

* Add pydocstyle exclude folder to allow slowly adding new docstrings

* Add docstrings for setup.py and gym/__init__.py, core.py, error.py and logger.py

* Check that all unwrapped environment are of a particular wrapper type

* Reverted back to import gym.spaces.Space to gym.spaces

* Fixed the __init__.py docstring

* Fixed autoreset autoreset test

* Updated gym __init__.py top docstring

* Remove unnecessary import

* Removed "unused error" and make APIerror deprecated at gym 1.0

* Add pydocstyle description to CONTRIBUTING.md

* Added docstrings section to CONTRIBUTING.md

* Added :meth: and :attr: keywords to docstrings

* Added :meth: and :attr: keywords to docstrings

* Update the step docstring placing the return type in the as a note.

* Updated step return type to include each element

* Update maths notation to reward range

* Fixed infinity maths notation
2022-05-10 10:35:45 -04:00
Mark Towers
31e6f23e67 Add pyright to precommit (#2796) 2022-05-09 11:22:49 -04:00
Arjun KG
40c26ab9c6 BugFix - VecEnvWrapper doesn't forward call, set_attr to self.env (#2800)
* add call, set_attr, __del__ to VecEnvWrapper

* add docstring for test
2022-05-06 10:49:46 -04:00
Mark Towers
b044b9043c Fixed bug where the env could terminate while checking observations and actions (https://github.com/openai/gym/issues/2803) (#2804) 2022-05-06 09:36:35 -04:00
Ariel Kwiatkowski
971aea8502 Fixes to the new registration (#2771) 2022-05-05 09:43:53 -04:00
Gianluca De Cola
b4f40f5ab6 Add deprecation warning on PlayPlot. (#2792) 2022-05-02 11:58:23 -04:00
Mark Towers
2708d818a3 Changes the gym box2d, toy-text and classic-control entry points to their actual file not __init__.py import (#2791) 2022-05-02 11:40:20 -04:00
Mark Towers
b704d4660e Place try except around all imports of pygame (#2782)
* Place try except around all imports for pygame and optional modules in box2d, classic_control and toy_text

* Updated all ImportErrors to DependencyNotInstalled

* Re-add comment on why pygame is imported
2022-04-29 19:44:28 -04:00
Markus Krimmel
ae15f59d79 Added docstrings for wrappers, some typehints (#2784) 2022-04-29 19:43:59 -04:00
Jet
5c8ce49852 Add discrete action space for Carracing (#2761)
* fix impulse sample bug and add adjustable gravity

* revert weird sample thing

* assertation

* add wind

* fix wind to use applyforce

* black

* add tests for wind

* fix test bug

* run lunar lander tests over 10 runs

* reduce wind for heuristic landing

* made wind power kwarg

* reduce wind power for heuristic landing

* update doc

* remove wind power from kwarg

* fix tests by deleting tests ;)

* Add back wind power as kwarg

* the black sheep

* remove rogue plus

* slight doc fix and variable rename

* fix bug with track turn indicators

* black

* add discrete environment for carracing

* update docs

* reduce acceleration magnitude

* reduce wind power to near nothing for heuristic landings

* undo change on this branch

* change actions

* remove redundant import

* fix docs
2022-04-29 18:48:19 -04:00
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
Vairo Di Pasquale
4ecc2ad35a Improved taxi documentation (#2777)
* Improved documentation to specify decode state space

* Improve taxi documentation
2022-04-26 11:17:32 -04:00
Yuji Kanagawa
0c78ea5964 Avoid using deperecated distutils package (#2770) 2022-04-25 07:58:38 -04:00
efokschaner
feb7ec3bc2 Fix docstring format on seed arg to reset (#2775)
I have a copy of this string in another project and it failed the darglint docstring style check.
This fixes that, if it's something you care to fix.
2022-04-24 13:01:20 -04:00
Ilya Kamen
3f7de05801 Remove orphan comment (#2774)
* Remove orphan comment

The comment used to be due to the line that is not there anymore, like:
```python
from gym.envs.mujoco.mujoco_env import MujocoEnv

# ^^^^^ so that user gets the correct error
# message if mujoco is not installed correctly
```

Now the comment is useless.

* Update __init__.py
2022-04-24 12:15:16 -04:00
Mark Towers
3354451300 Fixed batch spaces where the original space's seed was ignored. Issue 2680 (#2727)
* Add a case for the Box shape where the low and high values are both scalars

* Add seeding.RandomNumberGenerator parameter to Dict seed. Modify __repr__ for the dictionary space string looks similar to an actual dictionary

* Add seeding.RandomNumberGenerator parameter to Multi Binary seed

* Add seeding.RandomNumberGenerator parameter to Multi Binary seed. Modify nvec typing to include np.ndarray

* Space seed typing can be a seeding.RandomNumberGenerator. If a seeding.RNG is provided then it is assigned to _np_random and .seed is not run

* Fixed the tuple seeding type as List[int] is not a valid Space seed type

* Added typing to batch_space. The batch_space seed is equal to the space's seeding

* Fixed the seeding type

* Add test for batch space seeds are identical to the original space's seeding

* Add equivalence function for RandomNumberGenerator comparing the bit_generator.state

* The batch_space functions uses a copy of the seed for the original space

* Set the action space seed for sync_vector_env seed testing

* Add test for the seeding of the sync vector environment

* Update the test_batch_space_seed to check the resulting sampling are equivalent for testing

* Revert representation back to the original version

* Remove additional Box shape initialisation

* Remove additional typing of MultiDiscrete

* Fixed bug of Space batch space where the original space's np_random is not a complete copy of the original space

* Add CustomSpace to the batched space seed test

* Modify the CustomSpace sample to produce a random number not a static value

* Fix CustomSpace to reflect the sample function

* Copy the space.np_random for the batched_space seed to ensure that the original space doesn't sampling doesn't effect the batched_space

* Parameterized the batch_space_seed, added testing for rng_different_at_each_index and test_deterministic

* Black and isort pre-commit changes

* Pre-commit fix

* MacOS, test_read_from_shared_memory throws an error that the inner _process_write function was unpicklable. Making the function a top-level function solves this error

* Fixed typing of seed where a space's seed function differs from Space.seed's typing

* Added check that the sample lengths are equal and explicitly provided the number of batched spaces n=1

* Removed relative imports for absolute imports

* Use deepcopy instead of copy

* Replaces `from numpy.testing._private.utils import assert_array_equal` with `from numpy.testing import assert_array_equal`

* Using the seeding `__eq__` function, replace `np_random.bit_generator.state` with `np_random`

* Added docstrings and comments to the tests to explain their purpose

* Remove __eq__ from RandomNumberGenerator and add to tests/vector/utils

* Add sync vector determinism test for issue #2680

* Fixed bug for 462101d384 (r850740825)

* Made the new seeds a list of integers
2022-04-24 12:14:33 -04:00
Gianluca De Cola
dcae553204 Remove magic numbers. Imports cleanup. Remove redudant test. (#2769) 2022-04-21 18:21:44 -04:00
Ariel Kwiatkowski
00a60e6cc8 Rewriting of the registration mechanism (#2748)
* First version of the new registration

* Almost done

* Hopefully final commit

* Minor fixes

* Missing error

* Type fixes

* Type fixes

* Add some type hinting stuff

* Fix an error?

* Fix literal import

* Add a comment

* Add some docstrings

Remove old tests

* Add some docstrings, rename helper functions

* Rename a function

* Registration check fix

* Consistently use `register` instead of `envs.register` in tests

* Fix the malformed registration error message to not use a write-only format

* Change an error back to a warning when double-registering an environment
2022-04-21 14:41:15 -04:00
Rushiv Arora
0a5f543d6a Vector Api for website (#2764)
* Rephrase

* Rephrase
2022-04-21 11:15:16 -04:00
Jet
3ee7420a84 reduce wind power further for heuristic landing (#2766)
* reduce wind power further for heuristic landing

* remove wind tests for lunar lander

* don't need to reduce wind for heuristic
2022-04-21 10:53:40 -04:00
Gianluca De Cola
36a7fe5a31 Add test gym utils play. Fix #2729 (#2743)
* refactoring play function. Tests for keys to action mapping.

* Add mocking pygame events.

* partial event processing in class.

* pre-commit.

* quit pygame after tests.

* fix typos in functions names.

* Add type hint.

* Add test for play function.

* remove mockKeyEvent.

* remove unused main code.

* Adding type hints.

* catch custom exception in tests.

* Fix magic numbers.

* Add test with an actual environment.

* fix comment.

* Add TODO memo on env.render.

* change map with list comprehension.

* remove unused imports.

* Add type hint.

* typo.

* docstring.
2022-04-18 11:30:56 -04:00
Jet
613892023a Fix turn indicators not working in Carracing (#2759)
* fix impulse sample bug and add adjustable gravity

* revert weird sample thing

* assertation

* add wind

* fix wind to use applyforce

* black

* add tests for wind

* fix test bug

* run lunar lander tests over 10 runs

* reduce wind for heuristic landing

* made wind power kwarg

* reduce wind power for heuristic landing

* update doc

* remove wind power from kwarg

* fix tests by deleting tests ;)

* Add back wind power as kwarg

* the black sheep

* remove rogue plus

* slight doc fix and variable rename

* fix bug with track turn indicators

* black
2022-04-17 10:36:37 -04:00
Jet
da7b8ae8fc Made documentation for carracing more descriptive, and renamed one of the variable names (#2755) 2022-04-15 11:18:14 -04:00
Jet
c6deb81ad3 Add mild domain randomization to Car Racing Env (#2749)
* first commit domain randomize

* black

* update doc

* add some type hints and internalized some functions

* we were told, the black bear is innocent; but I should not like to trust
myself wit him

* Don't need two color conventions

* don't multiply twice

* hardcore -> domain_randomize & register

* remove rogue decorator
2022-04-15 11:04:24 -04:00
Jet
681a99296e Add gravity and wind as kwarg in Lunar Lander (#2746)
* fix impulse sample bug and add adjustable gravity

* revert weird sample thing

* assertation

* add wind

* fix wind to use applyforce

* black

* add tests for wind

* fix test bug

* run lunar lander tests over 10 runs

* reduce wind for heuristic landing

* made wind power kwarg

* reduce wind power for heuristic landing

* update doc

* remove wind power from kwarg

* fix tests by deleting tests ;)

* Add back wind power as kwarg

* the black sheep

* remove rogue plus
2022-04-15 11:03:54 -04:00
Omar Younis
1a3a891b2a fix #2723 and remove unuseful board (#2754) 2022-04-15 11:03:22 -04:00
Jet
5ae6bf9634 Bipedal fix bounds and type hints (#2750)
* Add some missing typehints for bipedal walker

* fix bounds

* fix boudns
2022-04-13 20:23:07 -04:00
Jordan Terry
33970e2b1c Update README.md 2022-04-13 16:02:46 -04:00
Andrea PIERRÉ
06072ed2cb fix: type ignore from #2739 (#2744) 2022-04-11 13:27:23 -04:00
Mark Towers
b7179241ec Update the parametrize to show the ids of the specification to make debugging easier (#2740) 2022-04-10 13:36:23 -04:00
Markus Krimmel
2ac8553c67 Added kwarg documentation for BlackJack and LunarLander (#2742) 2022-04-10 00:37:22 -04:00
John Balis
d4cda255ea AutoResetWrapper integration with gym.make() (#2728)
* added autoreset wrapper and tests

* added basic inline documentation for autoreset wrapper

* changes to comply with flake8 style

* redid autoreset wrapper

* compliance with flake8

* added final_info to info

* removed unnecessary override from autoreset wrapper

* fixed ordering mistake

* fixed flake8 compliance

* improved clarify of inline documentation

* changes to address code review

* changed autoreset terminal state keys, added message to key overlap check assert statement, updated autoreset wrapper docstring

* auto-reset integration draft

* changed arg name to autoreset for consistency

* pre commit compliance

* formatting compliance

* addressed code review

* removed commented out line
2022-04-08 10:54:49 -04:00
Omar Younis
623dd8d6a5 fix #2736 (#2737) 2022-04-08 08:57:40 -04:00
Gianluca De Cola
227e246ff6 Pyright versioning update. Fix #2700 (#2739)
* Moved pygame imports into render

* Formatting

* Make pygame optional for box2d, try to make formatting work

* fix tests, fix pre-commit.

* Update ci linter config.

* fix type hints for latest pyright version and backward compatibility with numpy <= 1.21.5

* pre-commit.

Co-authored-by: Ariel Kwiatkowski <ariel.j.kwiatkowski@gmail.com>
Co-authored-by: Gianluca De Cola <gianluca.decola@ags-it.com>
2022-04-07 21:19:52 -04:00
Jordan Terry
3fd204dc95 Update README.md 2022-04-07 19:36:05 -04:00
Markus Krimmel
bfdd2596af Changed reward_threshold from int to float (#2735) 2022-04-06 15:14:12 -04:00
Manuel Goulão
658d4081c0 fix and complete docstrings to match the documentation page (#2697) 2022-04-06 15:12:55 -04:00
Gianluca De Cola
07fd227a4f Make pygame optional for Box2D. Fix ci. Closes #2712 (#2731)
* Moved pygame imports into render

* Formatting

* Make pygame optional for box2d, try to make formatting work

* fix tests, fix pre-commit.

Co-authored-by: Ariel Kwiatkowski <ariel.j.kwiatkowski@gmail.com>
Co-authored-by: Gianluca De Cola <gianluca.decola@ags-it.com>
2022-04-05 16:13:31 -04:00
Omar Younis
e11231d84f add pygame GUI render for taxi env (#2713) 2022-04-02 10:20:35 -04:00
trigaten
752af3c57d Fix black version (#2724)
* isort

* update pre commit
2022-04-01 09:01:34 -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
Alexis DUBURCQ
214a835e76 Wrapper should not overwrite default render mode (#2706) 2022-03-31 16:28:17 -04:00
Mark Towers
4f230499af Fixed warnings produced by test_record_video.py and test_video_recorder.py (#2703)
* Fixed warnings produced by test_record_video.py and test_video_recorder.py by using the self._frames_per_sec value as default value if video.frames_per_second is missing

* The default backward compatible values if video.frames_per_second and video.output_frames_per_seconds are the updated frames_per_sec and output_frames_per_sec values
2022-03-31 16:25:37 -04:00
Markus Krimmel
1285fed2f2 Update check_env (#2717)
* Added check for return_info, only warn about missing render_fps if human mode is available

* Require render_fps if any kind of rendering is implemented
2022-03-31 16:09:43 -04:00