-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.py
More file actions
45 lines (39 loc) · 1.45 KB
/
Copy pathenvironment.py
File metadata and controls
45 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Environment:
def __init__(self, bounds):
"""
Initialize the environment.
Parameters:
bounds: A tuple (min_x, min_y, max_x, max_y) defining the design area.
"""
self.bounds = bounds
self.modules = []
def add_module(self, module):
self.modules.append(module)
def update(self):
"""
Update global environment conditions if needed.
Currently a placeholder.
"""
pass
def shrink_bounds(self, shrink_amount=1):
"""
Shrink the environment bounds by shrink_amount on all sides.
"""
min_x, min_y, max_x, max_y = self.bounds
if (max_x - min_x > 2 * shrink_amount) and (max_y - min_y > 2 * shrink_amount):
min_x += shrink_amount
min_y += shrink_amount
max_x -= shrink_amount
max_y -= shrink_amount
self.bounds = (min_x, min_y, max_x, max_y)
print(f"Environment bounds shrunk to: {self.bounds}")
def plot_state(self, ax):
"""
Plot the current state of the environment and its modules.
Draws the environment boundary and each module as a rectangle.
"""
# This function is only needed for local matplotlib development
pass
def plot_overlap_bars(self, ax_overlap, ax_outside=None, show_outside=False):
# This function is only needed for local matplotlib development
pass