world#
- class gym_socks.envs.world.World[source]#
World.
The
Worldclass is essentially aMutableSequence(such as a list), of objects contained within the world. The objects contained within the world must be of type_WorldObject, meaning the implement thestep,reset,render,close, andseedmethods. If an object that does not implement these methods is added, an assertion error will be thrown.It can be used in much the same was as a list, for example:
>>> world = World() >>> world.append(item) >>> world[1] = item >>> world += [item]
The
Worldis primarily used for keeping track of multiple objects, such as obstacles, which are contained within the world environment and simulated together. While it can trackDynamicalSystem, it is moreso intended to track uncontrolled or fully autonomous systems or objects, and to synchronize the simulation time.In addition, it implements the following methods, which are applied to all objects in the world environment:
step,reset,render,close, andseed.E.g., the
stepmethod calls thestepmethod for each item in the world. The order in which the items are iterated over is the same as the order of the list. If the functions return a value, the results are given in a list.- Return type
None
- extend(values)[source]#
S.extend(iterable) – extend sequence by appending elements from the iterable
- index(value[, start[, stop]]) integer -- return first index of value.[source]#
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(_index, _object)[source]#
S.insert(index, value) – insert value before index
- Parameters
_index (int) –
_object (gym_socks.envs.world._WorldObject) –
- pop([index]) item -- remove and return item at index (default last).[source]#
Raise IndexError if list is empty or index is out of range.
- remove(value)[source]#
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reset()[source]#
Reset the world to a random initial condition.
- Returns
The result of each reset function in a list.
- Return type
list
- seed(seed=None)[source]#
Sets the seed of the random number generator.
This is primarily useful for objects which incorporate some sort of stochasticity to ensure repeatability.
- Parameters
seed (Optional[int]) – Integer value representing the random seed.
- Returns
The seed of the RNG for each object in a list.
- Return type
list
- step(time=None)[source]#
Advances the simulation forward one time step.
- Parameters
time (Optional[int]) – The simulation time.
- Returns
The result of each step function in a list.
- Return type
list
- property time_horizon#
Time horizon for the simulation.