View examples here <—
View source code here <—
Clone the repository:
git clone https://github.com/mayushii21/the-grid.git
Navigate to the folder:
cd the-grid
Create a python virtual environment:
python -m venv gridenv
Activate the virtual environment:
source gridenv/bin/activate
Install the package from the current folder:
pip install .
Create a new jupyter notebook or navigate to the example file at /src/city_network/results.ipynb
. Activate the virtual environment with the installed package.
Import the class with from city_network.citygrid import CityGrid
.
Create an instance of the CityGrid class with instance_var = CityGrid(n, m, obstruction_cov=0.3, seed=None)
Parameters:
n: Number of columns in the grid.
m: Number of rows in the grid.
obstruction_cov: Coverage of obstructions (default is 0.3).
seed: Seed for random number generation of obstructions (default is None).
place_tower(x, y, tower_range, display=False)
Places a tower at a specified location with a given range. Set display
to True
to display the tower's coverage.
Parameters:
x: X-coordinate of the tower.
y: Y-coordinate of the tower.
tower_range: Range of the tower's coverage.
display: Whether to display the tower's coverage (default is False).
optimize_tower_placement(tower_range)
Runs algorithm to optimize tower placement to cover all empty blocks.
Parameters:
tower_range: Range of tower coverage.
most_reliable_path(start_tower, end_tower, tower_range, recalculate=False)
Finds the most reliable path between two towers.
Parameters:
start_tower: Starting tower (tuple containing x, y coordinates).
end_tower: Ending tower (tuple containing x, y coordinates).
tower_range: Range of tower coverage.
recalculate: Whether to recalculate the path (default is False).
visualize_grid(paths=False)
Visualizes the grid, including non-obstructed blocks, obstructed blocks, towers, and coverage, with the option to display optimal data paths.
Parameters:
paths: Either "all" to display all optimal paths previously added withmost_reliable_path
, or a specific path to display (default is False).
visualize_obstructions()
Visualizes the grid with only obstructed blocks.
visualize_towers()
Visualizes the grid with only towers.