world#

class gym_socks.envs.world.World[source]#

World.

The World class is essentially a MutableSequence (such as a list), of objects contained within the world. The objects contained within the world must be of type _WorldObject, meaning the implement the step, reset, render, close, and seed methods. 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 World is primarily used for keeping track of multiple objects, such as obstacles, which are contained within the world environment and simulated together. While it can track DynamicalSystem, 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, and seed.

E.g., the step method calls the step method 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

append(value)[source]#

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S[source]#
close()[source]#
count(value) integer -- return number of occurrences of value[source]#
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.

render(mode='human')[source]#
Parameters

mode (str) –

reset()[source]#

Reset the world to a random initial condition.

Returns

The result of each reset function in a list.

Return type

list

reverse()[source]#

S.reverse() – reverse IN PLACE

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.