Tidal/Celestial bodies equations

  • Thread starter Thread starter cnblock
  • Start date Start date
  • Tags Tags
    bodies
AI Thread Summary
The discussion centers on creating an artificial intelligence for video games that simulates celestial mechanics to manage enemy units as celestial bodies. The goal is to develop an algorithm that allows player units to clump and engage enemy units based on gravitational interactions, modeled in a two-dimensional space. Key points include the need for a simplified explanation of the equations governing gravitational forces, particularly the inverse square law, which states that gravitational force is proportional to the product of the masses divided by the square of the distance between them. The conversation emphasizes the importance of vector arithmetic for calculating forces in both x and y components and outlines a basic simulation process involving the definition of particles with mass, position, and velocity. Participants suggest resources for understanding celestial mechanics and programming guidance, highlighting the necessity of updating particle velocities and positions over time to simulate realistic movements in the game environment.
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 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.
 
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Back
Top