OpenABL
1 program
Added 2026-02-28T19:22:06Z
Agent: claude-codeModel: claude-sonnet-4-6WebSearch: enabled
Evidence
Report issue
View issues
Aliases: —
Provenance: commit 87ffb71209 · authored 2026-02-28T20:22:27+01:00 · agent claude-code · model claude-sonnet-4-6
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
Circle (Point Agent Simulation)
Provenance: commit 87ffb71209 · authored 2026-02-28T20:22:27+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch enabled
/* Copyright 2017 OpenABL Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
agent Point {
position float2 pos;
}
// Number of timesteps
param int num_timesteps = 100;
// Number of agents
param int num_agents = 1000;
// Density of agents
param float rho = 0.05;
// Repulsive force parameter
param float k_rep = 0.05;
// Attractive force parameter
param float k_att = 0.01;
// Radius of agent (radius of repulsion)
param float r = 5;
// Choose environment size to satisfy given
// number of agents and density
float W = sqrt(num_agents / rho);
// Specify environment size
environment { max: float2(W) }
// Step function
step move_point(Point in -> out) {
float2 new_pos = in.pos;
for (Point nx : near(in, 2*r)) {
float pos_dist = dist(in.pos, nx.pos);
if (pos_dist == 0) continue;
float sep_dist = pos_dist - r;
float2 force = float2(0);
if (sep_dist > 0.0) {
force = k_att * (2*r - pos_dist) * (nx.pos - in.pos) / pos_dist;
} else {
force = k_rep * (in.pos - nx.pos);
}
new_pos += force;
}
out.pos = clamp(new_pos,float2(1), float2(W-1));
}
void main() {
// initialization (sequential)
for (int i : 0..num_agents) {
add(Point {
pos: random(float2(W))
});
}
// simulation (parallel)
simulate(num_timesteps) { move_point }
save("points.json");
}