Tidal/Celestial bodies equations

  • Thread starter Thread starter cnblock
  • Start date Start date
  • Tags Tags
    bodies
Click For Summary

Discussion Overview

The discussion revolves around the application of celestial mechanics equations in the context of developing an artificial intelligence for video games. Participants explore how to model enemy units as celestial bodies and how to calculate their interactions using gravitational equations, specifically in a two-dimensional battlefield scenario.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant suggests creating an AI that simulates celestial bodies as enemy units, seeking a simplified explanation of the relevant equations.
  • Another participant introduces the inverse square law for gravitational forces, referencing the equation G * M1 * M2 / r^2 and providing links to additional resources on gravitational fields and N-body simulations.
  • A participant attempts to clarify the gravitational equation, noting the need for a scalar multiplier to adjust forces in the simulation.
  • Another participant corrects the previous statement about the radius, emphasizing that it should be the distance between two masses rather than a fixed radius.
  • One participant outlines a step-by-step approach for simulating particle motion, including defining particles with mass, position, and velocity, and updating their states based on gravitational forces.

Areas of Agreement / Disagreement

Participants express differing levels of understanding and familiarity with the concepts, leading to corrections and clarifications. There is no consensus on a single approach or equation, and the discussion remains exploratory with multiple viewpoints presented.

Contextual Notes

Participants mention the need for vector arithmetic and the importance of accurately defining the parameters of the simulation, indicating potential complexities in the implementation that are not fully resolved.

cnblock
Messages
9
Reaction score
1
I was thinking that it would be cool to be able to create an artificial intelligence for video games which has an understanding of celestial bodies in relation to clumps of enemy units. The enemy units become the celestial bodies, and your units clump to engage them. I would be running the celestial bodies equation for all my counter units, so I would essentially be forking the algorithm multiple times for certain units. Would it be at all possible to get a synopsis of the equations in a packet that a layman can understand? I would essentially need the equation that calculates the tides in relation to the moon, but it would be two dimensional, and would therefore be telling my units what affinity they should have for certain areas of the map. I am a software developer, so if one could explain with very simple and or vocabulary names of the elements of the equation that would be great. Software equations get evaluated backwards, but if you need to do it the other way, that's fine. I would need to know how to scale down to a battlefield approximation.

var num = 1
num = num + 2
num = num * 3
 
Computer science news on Phys.org
The bodies will have velocity in your 2D world, that will change due to gravitational forces of all other bodies or players through the inverse square law. G * M1 * M2 / r^2.
Start here; https://en.wikipedia.org/wiki/Gravitational_field#Classical_mechanics
https://en.wikipedia.org/wiki/N-body_simulation

Or find any book on Orbital or Celestial Mechanics.

If you want our real Solar system predictive computations...
Beginners programming guide here; Astronomical algorithms, by Meeus J. Willmann-Bell, 1991.
See also; SLALIB, find code here by following https://en.wikipedia.org/wiki/Starlink_Project
 
  • Like
Likes   Reactions: jim mcnamara and anorlunda
I can see that the equation you have given me is Gravity times Mass1 times Mass2 all divided by the radius of my circle squared. Please check that last sentence. I will probably add a scalar multiplier in order to overwhelm forces that approach by a certain factor. Should be simple multiplication. Thanks.
 
cnblock said:
all divided by the radius of my circle squared.
No, divided by the distance between those two masses squared.
 
You seem to be new to this.
You will need to do vector arithmetic on x and y components.

Define a particle as an object. It has mass m, position px and py, and velocity vx and vy vectors.

For each time step you must;
1. Sum all the force components fx and fy of gravitational forces on each particle, due to all other particles using the force = G.m1.m2 / r2 equation.
2. Use that force and the particle mass to update the particle velocity component vector.
3. Work out the new position of each particle based on last position and velocity.
4. Redraw the screen.

Setup a couple of particles with mass, position and velocity. See if you can simulate one particle orbiting another on the screen.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 22 ·
Replies
22
Views
10K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
12K