Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Anubis-class Cruiser (12/20/24)

Pages: 1 ... 26 27 [28] 29 30 ... 32

Author Topic: Optimizing the Conquest: a Mathematical Model of Space Combat  (Read 35156 times)

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #405 on: January 15, 2023, 07:52:57 PM »

Ship weapon slots are given as midpoint and arc, so no need to worry about that. So long as you know the unit vector in the direction of the enemy ship (or alternatively range to enemy ship and vector to enemy ship to calculate it) this is usable.
Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #406 on: January 15, 2023, 08:33:05 PM »

Ship weapon slots are given as midpoint and arc, so no need to worry about that. So long as you know the unit vector in the direction of the enemy ship (or alternatively range to enemy ship and vector to enemy ship to calculate it) this is usable.
Presumably the weapons arcs are known with respect to the ship, which can rotate, while the positions of things are known in the global frame of reference. So you still need to get the vectors into a common coordinate system (accounting for the firing ships rotational state) before you can take the dot product.
Logged

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #407 on: January 15, 2023, 09:40:42 PM »

I don't really understand this point. Rotation doesn't alter angles between vectors, so if you have a vector from our ship to the enemy ship, and a vector from our ship to the gun's midpoint, then the angle between these will be the same regardless of whether you rotate them to align to a particular coordinate system or not. That is, unless there are multiple ships, you don't really need an absolute coordinate system as there is only one vector that is relevant which is from our ship to the target ship. Why would you describe the target ship in any other frame of reference than ours?

I suppose it would make sense if we were at some point to create a fully realistic simulation of the Starsector battlefield, since unlike real space it has boundaries and describing those would be easier in the absolute frame. If we ever get to a point where we want to make space non-infinite then we can do that and just rotate the vector to the enemy ship to adjust for our ship's rotation before applying this code.
« Last Edit: January 15, 2023, 09:55:12 PM by CapnHector »
Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #408 on: January 15, 2023, 10:07:29 PM »

In the actual game, the positions of the ships are all known with respect to some global coordinate system which does not rotate or move with our ship (x,y coordinates on a grid fixed to the map). The weapon arcs are (presumably) known with respect to a coordinate system attached to your ship (angle with respect to the front of the ship or something). If you rotate your ship, the weapon arc moves with it (in the global coordinate system), but the direction to the target does not change. Or if you want to view it from your ship-fixed coordinate system, the vector to the (static) enemy moves when you rotate your ship but the weapon arc is fixed in that coordinate system.

If you are dealing with a completely static case, you could do stuff in a coordinate system attached to your own ship and just figure out what direction you want the target to be in relative to your ship at the start, but if your ship ever moves or rotates, that appears like your target moving in the ship-fixed coordinate system, and you would have to account for that, so it makes things much more difficult/complicated that just doing everything in a global coordinate system where the motions of the ships are independant.

It's also really not complicated math, so it seems like an easy thing to do that allows for more complex simulations in the future.
Logged

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #409 on: January 15, 2023, 10:18:43 PM »

It really shouldn't matter though unless space is bounded. If our ship moves forward x pixels and to the right y pixels, and the enemy ship moves forward r pixels and to the right s pixels, then in the system of coordinates centered on our ship we just say the enemy ship moves forward (r-x) pixels and to the right (s-y) pixels, right? And if our ship rotates we can easily express the rotation in polar coordinates. But it does get awkward if we have a boundary fixed in universal coordinates we must not cross.
Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #410 on: January 15, 2023, 10:44:28 PM »

It's way more intuitive to me to work in global (inertial) coordinates. That way rotating my ship causes my weapons to point in a different direction, and the target does not move, whereas working in ship-fixed coordinates means when I rotate my ship, the target (and every other object) moves and my weapons stay stationary. It just seems silly to do things so that every time my ship rotates or moves, I have to update the position/orientation of every other object instead of just the state of my own ship and weapons. Particularly if you ever want to consider more than one ship.

But I guess being an engineer, I am just used to working in inertial (global) coordinates since that is where the relevant laws of physics are defined.
Logged

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #411 on: January 15, 2023, 10:59:14 PM »

Wait, aren't all physical laws independent of frame of reference?

The only university level physics I have is a course on relativity and reading about convolutions from a mathematical physics book so I genuinely have no idea about this stuff.
Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #412 on: January 16, 2023, 08:42:30 AM »

Wait, aren't all physical laws independent of frame of reference?

The only university level physics I have is a course on relativity and reading about convolutions from a mathematical physics book so I genuinely have no idea about this stuff.
Newtons laws are definitely not. I never had to learn relativity, but according to the wikipedia page (https://en.wikipedia.org/wiki/Special_relativity) it's also only true in inertial (non-accelerating) frames. Doing simple classical mechanics (F=ma) in a moving (accelerating) frame results in fictitious forces (for example coriolis forces on earth).

It's easy to see how this is true, even in our little example here. If our ship is rotating and the target is stationary and has mass (m=/=0), then in our ship-fixed frame, the target can be accelerating (a=/=0) despite there being no forces acting on the target (F=0), so clearly F =/= ma in that frame.
« Last Edit: January 16, 2023, 08:48:42 AM by intrinsic_parity »
Logged

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #413 on: January 16, 2023, 09:01:27 AM »

Yes, but isn't that just Newtonian mechanics being an incomplete theory? In relativity we have this stuff: https://en.m.wikipedia.org/wiki/Preferred_frame

I have absolutely no idea about other things than gravity or motion though (not that I have an idea of those either). We need a physicist in this. Well. Possibly not since we will probably not be including realistic physics in our model. Still, you'd think the "design philosophy" of laws of physics would be that switching the observer doesn't break them somehow. The alternative seems kind of weird.
« Last Edit: January 16, 2023, 09:14:05 AM by CapnHector »
Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #414 on: January 16, 2023, 02:08:13 PM »

Isn't general relativity just about gravity and replaces newtons law of gravity? Not all of newtons laws. Like there is definitely a relativistic version of F=ma but I'm pretty sure it still requires a non-accelerating frame... I just asked my dad who taught physics and he agreed with that.

But this is all completely beside the point lmao. All I was saying is that everything in engineering is done in inertial frames because classical mechanics requires it, and no one is wasting their time with relativity unless they need it. Very few things reach a non-trivial fraction of c where relativity would be relevant.
Logged

Liral

  • Admiral
  • *****
  • Posts: 726
  • Realistic Combat Mod Author
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #415 on: January 16, 2023, 02:27:44 PM »

The laws of physics are the same in inertial and non-inertial reference frames by the equivalence principle of general relativity; unfortunately for our hopes of an intuitive and satisfying understanding of nature, this principle merely replaces the mind-bending implication that acceleration distorts the laws of physics with the mind-bending implication that acceleration distorts spacetime.

Centuries of theoretical, experimental, and lately computational research have yielded about a dense textbook's volume of fundamental equations accurately and precisely predicting experimental results, about a warehouse's worth of very convincing and even useful theories about what some of these equations mean, and absolutely no imminent prospect of any theory of all the equations recorded already, nevermind the ones we might later discover.  So for all practical purposes, use the fewest, simplest equations that accurately predict what you want to know, assuming whatever makes applying those equations the most convenient without spoiling your result too much, and don't dwell too long on the philosophical implications lest you should lose your mind.

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #416 on: January 16, 2023, 08:32:12 PM »

Thanks! One of the mysteries of physics for me is why does it seem that theoretical work is focused on objects on the 10^-36 m scale or incredibly far away, when it seems like problems such as the Navier-Stokes equations or superconductivity would be more pressing. Of course this could just be an outsider's illusion and more work be ongoing on the latter for all I know.

Liral, do you have all you need to proceed with the code?

Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

Liral

  • Admiral
  • *****
  • Posts: 726
  • Realistic Combat Mod Author
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #417 on: January 16, 2023, 09:33:40 PM »

The problems of fundamental inanimate physics and cosmology are the most intriguing, exciting, and grand ones in all of science because to solve them is to solve all others by proxy of the more-abstract sciences of chemistry, biology, psychology, and so on, and to know the past, present, and future of the universe.  Yet hence likewise melancholy: to see the world as a great machine working by rules unknown is to see it, with every discovery, more as a mere contraption proceeding to its ultimate fate.  So, while mysteries still remain in the world, while curiosity can still be felt and satisfied, what bright and noble mind would yearn to spend its eyeblink existence developing a higher-temperature superconductor or quieter airplane propeller when it could instead hunt for the theory of everything--or the story of how everything came to be?

...

I believe I have what I need to proceed with the code, though I do agree that moving the target rather than the weapons confuses me.  Thanks for your help, CapnHector. :)

CapnHector

  • Admiral
  • *****
  • Posts: 1056
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #418 on: January 16, 2023, 10:15:10 PM »

Haha. This must be a bug in human cognition (and one that is present in myself as well since if you look at my degree planning in math you would think I am allergic to anything practical). For some reason we consider Grothendieck to be the greatest mathematician of the past century when even the average scientist is more likely to say "excuse me" than know what you are talking about if you ever should have reason to bring him up, I think, while Ronald Fisher is probably unknowingly cited by every. single. scientist in all fields except math at some point. Although I'm an amateur so I really wouldn't know, but that's my impression. I would disagree about the ultimate problem in science though. The physical world is accidental, while the Langlands program for example could reveal some of the essence of necessary and ultimate truth, one that is not accidental but necessarily true, unalterable and fundamental. I suppose it depends on whether your definition of science includes mathematics, though.

As for rotating the target, well, I mean, if you move your head it is exactly the same as if everything except your head were to move around, right? The formulation is really really really simple: imagine you are looking ahead (let's move 0 degrees to in front). Positive degrees are to the left and negative to the right. You see a target at 20 degrees that you want to hit with your right fist, but that can only reach to 10 degrees. So you must rotate yourself which is equivalent to rotating the target so that the target is at 10 degrees. The difference is one of language only so if instead of "rotate the target to" you write "rotate our ship so the target is at" then it is the exact same thing but said differently.

Let me know when I can be helpful again. I think one thing is that we do not need the flux management system to test weapons. For them, it is even likely that the appropriate statistic is "time to kill" paired with "flux to kill" rather than the single statistic "time to kill as a function of max flux and dissipation". I was also thinking about another thing. Maybe instead of an AI you could still use arithmetic. Like, suppose we have a set of weapons and priorities. Then, you could do
- fire weapon with priority 1 as many times as possible. Compute how much flux is left over (at each timepoint)
- fire weapon with priority 2 as many times as you can using this leftover flux. Compute how much flux is left over.
- etc. until you have gone through all weapons.

There is a certain downside to this which is that if we ever want to add more dynamic flux (say, return fire) then this won't work as the computation would be recursive.
« Last Edit: January 16, 2023, 10:38:15 PM by CapnHector »
Logged
5 ships vs 5 Ordos: Executor · Invictus · Paragon · Astral · Legion · Onslaught · Odyssey | Video LibraryHiruma Kai's Challenge

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Optimizing the Conquest: a Mathematical Model of Space Combat
« Reply #419 on: January 17, 2023, 12:44:05 AM »

I am not saying doing things in the ship-fixed frame is inherently wrong, and I understand how to do it that way, I just don't see why you wouldn't do it in a stationary frame. If you ever want to do stuff like model shots as projectiles with travel time, or consider dynamic motion of ships during combat, using a rotation frame results in stuff like non-accelerating (moving in a straight line) projectiles following a curved path in your coordinate system if your ship is rotating. And it certainly seems like it would be more complicated computationally and unintuitive to have to update the states of every other object in the simulation whenever your own ship moves, rather than just updating the state of your ship.

The way I would do it is just make the ship class have x,y coordinates and an angle/orientation (defined wrt a stationary frame). Then the vector between ships is just the difference in their position coordinates, and the direction of a weapon arc center is just the the angle between it and 'forward' on the ship plus the rotation angle of the ship (and you can get a unit vector from that easily). That's all very simple, and extends naturally to having ships moving around, or having projectiles modeled etc.
Logged
Pages: 1 ... 26 27 [28] 29 30 ... 32