<jupyter_start><jupyter_text>Experiment: Collective Sampling and SearchAn underwater robot collective is deployed to search and rescue a star in distress.<jupyter_code>%load_ext autoreload
%autoreload 2
%matplotlib inline

import matplotlib

matplotlib.rcParams['figure.figsize'] = [12, 8]

import math
import numpy as np

from interaction import Interaction
from environment import Environment
from fish import Fish
from channel import Channel
from observer import Observer

from utils import generate_distortion, generate_fish, run_simulation<jupyter_output>The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload<jupyter_text>Hear the signal of the star and run back to the deployment station to report itRobots disperse until the first one hears the signal of the star. That robot broadcasts the info that it has detected the star. Thereupon, all robots switch to aggregation and return to the deployment station.<jupyter_code>"""Hear star, gather at origin
"""

from events import InfoExternal

run_time = 30 # in seconds
num_fish = 15
arena_size = 30
arena_center = arena_size / 2.0
initial_spread = 1
fish_pos = initial_spread * np.random.rand(num_fish, 2) + arena_center - initial_spread / 2.0
clock_freqs = 1
verbose = False

distortion = generate_distortion(type='none', n=arena_size)
environment = Environment(
    node_pos=fish_pos,
    distortion=distortion,
    prob_type='binary',
    noise_magnitude=0.1,
    conn_thres=6,
    verbose=verbose
)
interaction = Interaction(environment, verbose=verbose)
channel = Channel(environment)

fish = generate_fish(
    n=num_fish, 
    channel=channel, 
    interaction=interaction, 
    lim_neighbors=[2,3],
    neighbor_weights=1.0,
    fish_max_speeds=1,
    clock_freqs=clock_freqs,
    verbose=verbose
)
channel.set_nodes(fish)

observer = Observer(fish=fish, environment=environment, channel=channel)

missing_aircraft = InfoExternal('signal_aircraft')
for i in range(1, run_time): 
    observer.instruct(event=missing_aircraft, rel_clock=i, pos=np.array([arena_center-5, arena_center+5]))

run_simulation(fish=fish, observer=observer, run_time=run_time, dark=True, white_axis=False, no_legend=True)<jupyter_output>Please wait patiently 30 seconds. Thanks.
It's time to say bye bye!<jupyter_text>Hear the signal of the star and use vision to swim towards itRobots disperse until the first one hears the signal from the star. That robot broadcasts the info that it has detected the star. Thereupon, all robots switch to aggregation except robots that can hear the star swim towards it by using their perception. This pulls the center of the collective and therefore all robots to the star.<jupyter_code>"""Hear star, see star, gather at star
"""

from events import Homing

run_time = 80 # in seconds
num_fish = 20
arena_size = 30
arena_center = arena_size / 2.0
initial_spread = 1
fish_pos = initial_spread * np.random.rand(num_fish, 2) + arena_center - initial_spread / 2.0
clock_freqs = 1
verbose = False

distortion = generate_distortion(type='none', n=arena_size)
environment = Environment(
    node_pos=fish_pos,
    distortion=distortion,
    prob_type='binary',
    noise_magnitude=0.1,
    conn_thres=8,
    verbose=verbose
)
interaction = Interaction(environment, verbose=verbose)
channel = Channel(environment)

fish = generate_fish(
    n=num_fish, 
    channel=channel, 
    interaction=interaction,
    lim_neighbors=[2,3],
    neighbor_weights=1.0,
    fish_max_speeds=1,
    clock_freqs=clock_freqs,
    verbose=verbose
)
channel.set_nodes(fish)

observer = Observer(fish=fish, environment=environment, channel=channel)

missing_aircraft = Homing()
for i in range(1, run_time): 
    observer.instruct(event=missing_aircraft, rel_clock=i, pos=np.array([arena_center-6, arena_center+6]))

run_simulation(fish=fish, observer=observer, run_time=run_time, dark=True)<jupyter_output>Please wait patiently 80 seconds. Thanks.
It's time to say bye bye!
{'fraction_non_alphanumeric': 0.08019225904376423, 'fraction_numerical': 0.014166455856311662, 'mean_word_length': 5.503289473684211, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '407971', 'license': 'MIT', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1208, 'n_words': 370, 'path': 'Collective Sampling and Search.ipynb', 'repo_name': 'fberlinger/UndercoverBot', 'size': '3953'}