Skip to content

Commit

Permalink
Remove smell related code
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Dec 6, 2024
1 parent 2fa460e commit 051e019
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
14 changes: 12 additions & 2 deletions experiments/cf_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,19 @@ def vis_policy(
scale: float = 1.0,
seq_plot: bool = False,
) -> None:
import importlib

import matplotlib as mpl

from emevo.analysis.evaluate import eval_policy
from emevo.analysis.policy import draw_cf_policy, draw_cf_policy_multi
from emevo.analysis.value import plot_values

if importlib.util.find_spec("PySide6") is not None: # type: ignore
mpl.use("QtAgg")
else:
mpl.use("TkAgg")

with cfconfig_path.open("r") as f:
cfconfig = toml.from_toml(CfConfig, f.read())

Expand All @@ -636,6 +645,7 @@ def vis_policy(
if seq_plot:
visualizer = None
images = []
policy_means, values = [], []
for output, env_state, ag_idx in outputs:
if visualizer is None:
visualizer = env.visualizer(
Expand All @@ -653,7 +663,8 @@ def vis_policy(
visualizer.render(env_state.physics)
images.append(visualizer.get_image())
visualizer.show()
policy_means = [np.array(output.mean) for output, _, _ in outputs]
policy_means.append(np.array(output.mean))
values.append(np.array(output.value).ravel())
rot = [state.physics.circle.p.angle[idx].item() for _, state, idx in outputs]
draw_cf_policy_multi(
names,
Expand All @@ -663,7 +674,6 @@ def vis_policy(
max_force=max_force,
show=False,
)
values = [np.array(output.value).ravel() for output, _, _ in outputs]
plot_values(np.stack(values), names, images, fig_unit=value_fig_unit)
else:
visualizer = None
Expand Down
9 changes: 0 additions & 9 deletions src/emevo/environments/circle_foraging.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,6 @@ def __init__(
max_place_attempts: int = 10,
n_max_food_regen: int = 20,
random_angle: bool = True, # False when debugging/testing
# Only for CircleForagingWithSmell, but placed here to keep config class simple
smell_decay_factor: float = 0.01,
smell_diff_max: float = 1.0,
smell_diff_coef: float = 100.0,
) -> None:
# Coordinate and range
if env_shape == "square":
Expand Down Expand Up @@ -732,11 +728,6 @@ def place_newborn_neighbor(
)
)

# Smell
self._smell_decay_factor = smell_decay_factor
self._smell_diff_max = smell_diff_max
self._smell_diff_coef = smell_diff_coef

# Sensor index
self._sensor_index = 0

Expand Down
2 changes: 0 additions & 2 deletions src/emevo/environments/circle_foraging_with_neurotoxin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""Various hand-coded rules for the effect of food"""

from dataclasses import replace
from typing import Any

Expand Down
3 changes: 0 additions & 3 deletions src/emevo/exp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ class CfConfig:
n_position_iter: int = 2
n_physics_iter: int = 5
max_place_attempts: int = 10
smell_decay_factor: float = 0.01
smell_diff_max: float = 1.0
smell_diff_coef: float = 100.0
observe_food_label: bool = False
mouth_range: str = "front"

Expand Down

0 comments on commit 051e019

Please sign in to comment.