pydistsim.network.environment.Environment

class Environment[source]

Bases: ABC

Environment abstract base class.

This class represents an abstract base class for environments in the PyDistSim framework.

Methods

__init__

are_visible

Check if two coordinates are visible to each other in the environment.

find_random_pos

Returns a random position in the environment.

is_space

Check if the given coordinates represent a valid space in the environment.

abstract are_visible(xy1, xy2)[source]

Check if two coordinates are visible to each other in the environment.

This method should be implemented by subclasses to determine whether the two given coordinates are visible to each other in the environment.

Parameters:
  • xy1 – The first set of coordinates.

  • xy2 – The second set of coordinates.

Returns:

True if the coordinates are visible to each other, False otherwise.

Return type:

bool

abstract find_random_pos(n=100)[source]

Returns a random position in the environment.

Parameters:

n (int) – The maximum number of iterations to find a free space.

Returns:

The random position found.

Return type:

tuple

abstract is_space(xy)[source]

Check if the given coordinates represent a valid space in the environment.

This method should be implemented by subclasses to determine whether the given coordinates represent a valid space in the environment.

Parameters:

xy – The coordinates to check.

Returns:

True if the coordinates represent a valid space, False otherwise.

Return type:

bool