import numpy as np
import gym
from .space import Space


class Discrete(Space):
    """
    {0,1,...,n-1}

    Example usage:
    self.observation_space = spaces.Discrete(2)
    """
    def __init__(self, n):
        self.n = n
        super(Discrete, self).__init__((), np.int64)
        self.np_random = np.random.RandomState()

    def seed(self, seed):
        self.np_random.seed(seed)

    def sample(self):
        return self.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 isinstance(other, Discrete) and self.n == other.n

@@ -16,19 +16,8 @@
  np%0A
-import gym%0A
 from
@@ -73,27 +73,65 @@
  %22%22%22
-%0A    %7B
+A discrete space in :math:%60%5C%7B 
 0,
+ 
 1,
-...,n-1%7D%0A
+ %5Cdots, n-1 %5C%7D%60. %0A    
 %0A   
@@ -142,52 +142,28 @@
 mple
- usage
+:
 :%0A    
-self.observation_space = spaces.
+%0A        %3E%3E%3E 
 Disc
@@ -170,16 +170,25 @@
 rete(2)%0A
+        %0A
     %22%22%22%0A
@@ -214,16 +214,38 @@
 lf, n):%0A
+        assert n %3E= 0%0A
         
@@ -311,118 +311,8 @@
 t64)
-%0A        self.np_random = np.random.RandomState()%0A%0A    def seed(self, seed):%0A        self.np_random.seed(seed)
 %0A%0A  

Update discrete.py