README
# particle-brute
Brute-force N-body gravitational simulation — a pure-computation Native Gene for the Rotifer Protocol.
## Algorithm
All-pairs direct summation with O(n²) complexity per step. For each pair of particles (i, j), computes the exact gravitational force using Newton's law with a softening parameter to prevent singularities:
```
F = G × m_i × m_j × r̂ / (|r|² + ε²)^(3/2)
```
Integration uses the symplectic leapfrog (kick-drift-kick) scheme for energy conservation.
This is the **accuracy baseline** — every pairwise interaction is computed exactly, making it ideal for validating approximation-based algorithms like Barnes-Hut or spatial hashing.
## Usage
```bash
# Solar system preset (64 particles, 100 steps)
rotifer run particle-brute --input '{"preset": "solar"}'
# Cluster collision (128 particles, 500 steps)
rotifer run particle-brute --input '{"preset": "collision", "count": 128, "steps": 500}'
# Custom particles
rotifer run particle-brute --input '{"particles": [{"x":0,"y":0,"vx":0,"vy":0,"mass":100}, {"x":5,"y":0,"vx":0,"vy":4.47,"mass":1}]}'
```
## Presets
| Preset | Description |
|--------|-------------|
| `solar` | Central massive body + orbiting lighter bodies with circular velocities |
| `binary` | Two equal-mass stars in mutual orbit + debris ring |
| `cluster` | Random particles in a disk with small random velocities |
| `collision` | Two groups of particles approaching head-on |
## Output
- `particles` — final positions and velocities of all particles
- `steps_computed` — number of simulation steps executed
- `total_energy` — total system energy (kinetic + potential) for conservation validation
- `interactions_computed` — total force evaluations (n(n-1)/2 × 2 × steps for kick-drift-kick)
## Fitness Characteristics
| Metric | Expected |
|--------|----------|
| Success Rate | 1.0 (deterministic, no failure mode) |
| Accuracy | Exact (machine-precision pairwise forces) |
| Complexity | O(n² × steps) |
| Interactions | n(n-1) × steps |
| Best For | Small N (≤256), accuracy benchmarks |
| Weakness | Scales poorly for large N |
Brute-force N-body gravitational simulation — a pure-computation Native Gene for the Rotifer Protocol.
## Algorithm
All-pairs direct summation with O(n²) complexity per step. For each pair of particles (i, j), computes the exact gravitational force using Newton's law with a softening parameter to prevent singularities:
```
F = G × m_i × m_j × r̂ / (|r|² + ε²)^(3/2)
```
Integration uses the symplectic leapfrog (kick-drift-kick) scheme for energy conservation.
This is the **accuracy baseline** — every pairwise interaction is computed exactly, making it ideal for validating approximation-based algorithms like Barnes-Hut or spatial hashing.
## Usage
```bash
# Solar system preset (64 particles, 100 steps)
rotifer run particle-brute --input '{"preset": "solar"}'
# Cluster collision (128 particles, 500 steps)
rotifer run particle-brute --input '{"preset": "collision", "count": 128, "steps": 500}'
# Custom particles
rotifer run particle-brute --input '{"particles": [{"x":0,"y":0,"vx":0,"vy":0,"mass":100}, {"x":5,"y":0,"vx":0,"vy":4.47,"mass":1}]}'
```
## Presets
| Preset | Description |
|--------|-------------|
| `solar` | Central massive body + orbiting lighter bodies with circular velocities |
| `binary` | Two equal-mass stars in mutual orbit + debris ring |
| `cluster` | Random particles in a disk with small random velocities |
| `collision` | Two groups of particles approaching head-on |
## Output
- `particles` — final positions and velocities of all particles
- `steps_computed` — number of simulation steps executed
- `total_energy` — total system energy (kinetic + potential) for conservation validation
- `interactions_computed` — total force evaluations (n(n-1)/2 × 2 × steps for kick-drift-kick)
## Fitness Characteristics
| Metric | Expected |
|--------|----------|
| Success Rate | 1.0 (deterministic, no failure mode) |
| Accuracy | Exact (machine-precision pairwise forces) |
| Complexity | O(n² × steps) |
| Interactions | n(n-1) × steps |
| Best For | Small N (≤256), accuracy benchmarks |
| Weakness | Scales poorly for large N |
表型
输入
| 属性 | 类型 | 描述 |
|---|---|---|
| G | number = 1 | Gravitational constant |
| dt | number = 0.01 | Time step size |
| seed | number | Random seed for preset generation (deterministic output) |
| count | number = 64 | Number of particles for preset generation |
| steps | number = 100 | Number of simulation steps |
| preset | solar | binary | cluster | collision | Preset particle configuration |
| particles | array | Initial particle states. Ignored if preset is provided. |
| softening | number = 0.01 | Softening parameter to prevent singularity at close range |
输出
| 属性 | 类型 | 必填 | 描述 |
|---|---|---|---|
| particles | array | ✓ | Final particle states after simulation |
| total_energy | number | ✓ | Total system energy (kinetic + potential) at final state |
| steps_computed | number | ✓ | Actual number of simulation steps computed |
| interactions_computed | number | ✓ | Total pairwise force evaluations across all steps |
原始 JSON Schema
inputSchema
{
"type": "object",
"required": [],
"properties": {
"G": {
"type": "number",
"default": 1,
"description": "Gravitational constant"
},
"dt": {
"type": "number",
"default": 0.01,
"description": "Time step size"
},
"seed": {
"type": "number",
"description": "Random seed for preset generation (deterministic output)"
},
"count": {
"type": "number",
"default": 64,
"maximum": 2048,
"minimum": 2,
"description": "Number of particles for preset generation"
},
"steps": {
"type": "number",
"default": 100,
"maximum": 10000,
"minimum": 1,
"description": "Number of simulation steps"
},
"preset": {
"enum": [
"solar",
"binary",
"cluster",
"collision"
],
"type": "string",
"description": "Preset particle configuration"
},
"particles": {
"type": "array",
"items": {
"type": "object",
"required": [
"x",
"y",
"vx",
"vy",
"mass"
],
"properties": {
"x": {
"type": "number"
},
"y": {
"type": "number"
},
"vx": {
"type": "number"
},
"vy": {
"type": "number"
},
"mass": {
"type": "number"
}
}
},
"description": "Initial particle states. Ignored if preset is provided."
},
"softening": {
"type": "number",
"default": 0.01,
"description": "Softening parameter to prevent singularity at close range"
}
}
} outputSchema
{
"type": "object",
"required": [
"particles",
"steps_computed",
"total_energy",
"interactions_computed"
],
"properties": {
"particles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"x": {
"type": "number"
},
"y": {
"type": "number"
},
"vx": {
"type": "number"
},
"vy": {
"type": "number"
},
"mass": {
"type": "number"
}
}
},
"description": "Final particle states after simulation"
},
"total_energy": {
"type": "number",
"description": "Total system energy (kinetic + potential) at final state"
},
"steps_computed": {
"type": "number",
"description": "Actual number of simulation steps computed"
},
"interactions_computed": {
"type": "number",
"description": "Total pairwise force evaluations across all steps"
}
}
} Arena 历史
| 日期 | 适应度 | 安全分 | 调用数 |
|---|---|---|---|
| 3月17日 | 1.0000 | 1.00 | 1 |