Skip to content

Commit 96ac968

Browse files
author
Daniel Precioso, PhD
committed
Add detailed instructions for implementing predator behavior in Vicsek model
1 parent ea513b3 commit 96ac968

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

modules/collective-motion/vicsek-predator.qmd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ The simplest case is a predator fixed at a given position. To implement this:
2323
- Pass `xy_pred` to your Vicsek update at each frame.
2424
- Draw the predator in the plotting section (after initializing the axes).
2525

26+
::: {.callout-tip collapse="true"}
27+
## Where to include the code
28+
29+
- **Set `xy_pred` before the animation loop**: In `run_simulation`, set `xy_pred = np.array([box_size/2, box_size/2])` (or wherever you want the static predator) before entering the animation.
30+
- **Pass `xy_pred` to the Vicsek update**: In the `update_animation` function, pass `xy_pred` as an argument to `vicsek_equations`.
31+
- **Draw the predator**: After initializing the axes in `run_simulation`, add the predator circle with `circle_predator = plt.Circle(xy_pred, radius_predator, color="red", fill=False)` and `ax_plane.add_artist(circle_predator)`.
32+
- **Update the predator's position in the plot (if needed)**: For a static predator, this is only needed once. For moving predators, update `circle_predator.set_center(xy_pred)` in each animation frame.
33+
:::
34+
2635
---
2736

2837
## Random Walk Predator

0 commit comments

Comments
 (0)