Skip to content

Commit

Permalink
better orbits
Browse files Browse the repository at this point in the history
  • Loading branch information
yhattav committed Jan 17, 2025
1 parent 60e3b41 commit 1569c26
Showing 1 changed file with 61 additions and 7 deletions.
68 changes: 61 additions & 7 deletions src/utils/prompts/scenarioPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,70 @@ Environment Context:
2
)}
Physics Model Information:
1. Gravitational Force Calculation:
- Uses simplified Newton's law: F = G * (m1 * m2) / r²
- G (gravitational constant) = 0.1 in simulation units
- Minimum distance clamp = 10 units to prevent infinite forces
- Force falloff starts at 20 units for stability
2. Mass-Force Relationships:
- Gravity points (stars/planets) mass range: 5,000 to 2,500,000
* Brown Dwarf: ~5,000
* Red Dwarf: ~20,000
* Main Sequence Star: ~50,000-200,000
* Red Giant: ~200,000-1,000,000
* Super Giant: >1,000,000
- Particles mass range: 0.01 to 0.1
* Light particles: 0.01-0.03 (faster, more affected by gravity)
* Medium particles: 0.03-0.07 (balanced)
* Heavy particles: 0.07-0.1 (more inertia, less affected by gravity)
3. Stable Orbit Guidelines:
- For circular orbit around mass M at radius r:
* Required velocity = sqrt(G * M / r) where G = 0.1
* Example: For a 1,300,000 mass star
- At r=100: v ≈ 360 units/tick
- At r=200: v ≈ 180 units/tick (common stable orbit velocity)
- At r=300: v ≈ 120 units/tick
- For elliptical orbits, velocity should be:
* Higher than circular orbit velocity for elongated orbits
* Lower for more circular orbits
- Multiple bodies need higher masses to maintain stable orbits
- IMPORTANT: These velocities are exact - using lower values will result in unstable orbits!
4. Practical Example - Multi-Body Orbital System:
Consider a system with a central star (mass: 1,300,000) and two orbiting bodies:
a) Planet (mass: 1.0)
- Distance from star: 300 units
- Required orbital velocity: 180 units/tick
- Direction perpendicular to radius for circular orbit
- Creates stable circular orbit due to mass ratio ~1:1,300,000
b) Moon (mass: 0.01)
- Distance from planet: 101 units
- Additional velocity: 220 units/tick (relative to planet)
- Smaller mass allows it to be affected by both planet and star
Key Insights:
- Mass ratios: Star:Planet:Moon = 1,300,000:1:0.01
- Required velocities are typically in the range of 100-400 units/tick
- Common stable orbit velocity is around 180 units/tick at r=200
- Velocity calculation: v = sqrt(0.1 * M / r)
- DO NOT adjust for time steps - use the raw calculated values
- Larger central mass requires higher velocities
- Safe separation distances prevent immediate collisions
Scenario Requirements:
1. All positions must be within the simulator bounds (0 to ${width} for x, 0 to ${height} for y)
2. Each gravity point must have:
- position (x, y)
- mass (typical range: 100,000 to 2,000,000)
- mass (use ranges from Physics Model section)
- label (descriptive name)
3. Each particle must have:
- position (x, y)
- velocity (x, y) (typical range: -50 to 50)
- mass (typical range: 0.01 to 0.1)
- velocity (x, y) (calculate based on orbit guidelines)
- mass (0.01 to 0.1)
- elasticity (0 to 1, typically 0.8)
- id (unique string)
4. Settings can include:
Expand All @@ -65,10 +119,10 @@ Generate a valid JSON scenario that matches this description. The JSON must foll
${JSON.stringify(EXAMPLE_SCENARIO, null, 2)}
Consider:
- Relative positions (e.g., "center" means x=${centerX}, y=${centerY})
- Physical accuracy (e.g., orbits need appropriate velocity vectors)
- Visual balance within the simulator dimensions
- Realistic mass and velocity ranges for stable simulation
- Use appropriate mass ratios between gravity points and particles
- Calculate orbital velocities using the provided formulas
- Ensure multi-body systems have sufficient mass for stability
- Position objects with enough separation to prevent immediate collisions
Return only the valid JSON with no additional text.`;
};

0 comments on commit 1569c26

Please sign in to comment.