mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-06 07:51:43 +00:00
* Doom - Added reward_threshold and timestep_limit for all environments * Doom - Returning all available game variables * Doom - Moved _seed to doom_env to avoid repetition in every environment * Doom - Added ALT_ATTACK and made all action_space equivalent (same controls between environments). * Doom - Actions can either be a short list of allowed actions or the full list of 41 commands * Doom - Returning black observation space on error or is_finished, rather than empty list (which was triggering an error) * Doom - HighLow.sample() returns the small list. * Doom - Updated difficulty for some missions * Doom - Fixed inconsistency between controls.md and deathmatch.cfg * Doom - Issue #168 - Remove sleep statement from DoomEnv render * Doom - Only using full action space (43 keys) - Added 'normal', 'fast' and 'human' mode - Set non-deterministic to True - Set video.frames_per_second to 35 - Properly returning game variables * Replaced warnings.warn by logger.warn * Doom - Added NUM_ACTIONS and action_idx instead of x * Doom - Added NUM_ACTIONS and action_idx instead of x * Doom - reset() only calls game.new_episode() after first call * Doom is now deterministic * Doom - Partial fix for issue #167 - DoomDeathmatch environment crashes sporadically * Doom - Standardized envs, simplified _reset * Doom - Removed temporary fix for issue #167 * Doom - Added scoreboard summary and description
29 lines
750 B
Python
29 lines
750 B
Python
import numpy as np
|
|
|
|
import gym, time
|
|
from gym.spaces import prng
|
|
|
|
class Discrete(gym.Space):
|
|
"""
|
|
{0,1,...,n-1}
|
|
|
|
Example usage:
|
|
self.observation_space = spaces.Discrete(2)
|
|
"""
|
|
def __init__(self, n):
|
|
self.n = n
|
|
def sample(self):
|
|
return prng.np_random.randint(self.n)
|
|
def contains(self, x):
|
|
if isinstance(x, int):
|
|
as_int = x
|
|
elif isinstance(x, (np.generic, np.ndarray)) and (x.dtype.kind in np.typecodes['AllInteger'] and x.shape == ()):
|
|
as_int = int(x)
|
|
else:
|
|
return False
|
|
return as_int >= 0 and as_int < self.n
|
|
def __repr__(self):
|
|
return "Discrete(%d)" % self.n
|
|
def __eq__(self, other):
|
|
return self.n == other.n
|