Skip to content

Commit

Permalink
refactor: AgentAlgorithm.initializaiton
Browse files Browse the repository at this point in the history
  • Loading branch information
tetov committed Nov 1, 2024
1 parent 513b033 commit 53f163b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 92 deletions.
14 changes: 0 additions & 14 deletions src/bdm_voxel_builder/agent_algorithms/algo_20_build_by_sense.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ def __post_init__(self):
name=self.name,
)

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
# update walk region
self.update_offset_regions(
ground_array=state.grids["ground"].to_numpy(),
scan_array=state.grids["scan"].to_numpy(),
)

def update_environment(self, state: Environment):
self.decay_environment(state)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,6 @@ def __post_init__(self):
name=self.name,
)

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
# update walk region
self.update_offset_regions(
state.grids["ground"].to_numpy(), state.grids["scan"].to_numpy()
)

def update_environment(self, state: Environment):
self.decay_environment(state)
self.diffuse_follow_grid(state, state.grids["built"].to_numpy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,6 @@ def __post_init__(self):
name=self.name,
)

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
# update walk region
self.update_offset_regions(
state.grids["ground"].to_numpy(), state.grids["scan"].to_numpy()
)

def update_environment(self, state: Environment):
self.decay_environment(state)
if follow_newly_built > 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ def __post_init__(self):
)
self.print_dot_counter = 0

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
ground = state.grids["ground"]
scan = state.grids["scan"]

# update walk region
self.update_offset_regions(ground.to_numpy(), scan.to_numpy())

def update_environment(self, state: Environment):
self.decay_environment(state)
if follow_newly_built > 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,14 @@ def __post_init__(self):
)

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
"""Setup that needs to be after environment is created"""
self.super().initialization(state)
goal_density = state.grids["goal_density"]

goal_density.set_values_using_index_map(
self.make_goal_density_box_mockup_D(), goal_density__modifier_D
)

# update walk region
self.update_offset_regions(
state.grids["ground"].to_numpy(), state.grids["scan"].to_numpy()
)

def update_environment(self, state: Environment):
self.decay_environment(state)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,8 @@ def __post_init__(self):
)

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
"""Setup that needs to be after environment is created"""
self.super().initialization(state)
goal_density = state.grids["goal_density"]

goal_density.set_values_using_index_map(
Expand All @@ -117,11 +112,6 @@ def initialization(self, state: Environment):
self.make_goal_density_box_mockup_C(), goal_density__modifier_C
)

# update walk region
self.update_offset_regions(
state.grids["ground"].to_numpy(), state.grids["scan"].to_numpy()
)

def update_environment(self, state: Environment):
self.decay_environment(state)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ def __post_init__(self):
name=self.name,
)

def initialization(self, state: Environment):
"""
creates the simulation environment setup
with preset values in the definition
returns: grids
"""
ground = state.grids["ground"]
scan = state.grids["scan"]
self.update_offset_regions(ground.to_numpy(), scan.to_numpy())

def update_environment(self, state: Environment):
self.decay_environment(state)

Expand Down
6 changes: 4 additions & 2 deletions src/bdm_voxel_builder/agent_algorithms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def __init__(
def setup_agents(self, state: Environment):
raise NotImplementedError

@abc.abstractmethod
def initialization(self, state: Environment, **kwargs):
raise NotImplementedError
"""Setup that needs to be after environment is created"""
ground = state.grids["ground"].to_numpy()
scan = state.grids["scan"].to_numpy()
self.update_offset_regions(ground, scan)

@abc.abstractmethod
def update_environment(self, state: Environment):
Expand Down

0 comments on commit 53f163b

Please sign in to comment.