Published
Edited
May 22, 2022
7 stars
Insert cell
Insert cell
AA = import('https://cdn.skypack.dev/@gjmcn/atomic-agents@0.1.6?min');
Insert cell
Insert cell
Insert cell
AV = import('https://cdn.skypack.dev/@gjmcn/atomic-agents-vis@0.4.0?min')
Insert cell
Insert cell
{
// simulation
const sim = new AA.Simulation({
width: 700,
height: 400,
gridStep: 10
});
invalidation.then(() => sim.end()); // !! always include this in Observable !!
// circles
sim.populate({
n: 1000,
radius: 3,
setup: ac => ac.vel = AA.Vector.randomAngle(1)
});
// circles bounce off each other
sim.interaction.set('circle-bounce', {
group1: sim.actors,
behavior: 'bounce',
speed: 1 // fixed speed circles
});
// circles bounce off the simulation boundary
sim.interaction.set('boundary-bounce', {
group1: sim,
group2: sim.actors,
behavior: 'bounce'
});
// run and visualise
return AV.visObs(sim);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more