Author Topic: C# Suggestions  (Read 272805 times)

0 Members and 1 Guest are viewing this topic.

Offline Black

  • Gold Supporter
  • Rear Admiral
  • *****
  • B
  • Posts: 868
  • Thanked: 218 times
  • Gold Supporter Gold Supporter : Support the forums with a Gold subscription
    2022 Supporter 2022 Supporter : Donate for 2022
    2023 Supporter 2023 Supporter : Donate for 2023
    2024 Supporter 2024 Supporter : Donate for 2024
Re: C# Suggestions
« Reply #2025 on: August 07, 2021, 07:09:29 AM »
Can we get SM command to change field of the Ancient Constructs? I have 7 Constructs in my current game and 4 are Power and Propulsion and 2 are Sensors. And it is kind of disappointing.
 

Offline Gabrote42

  • Warrant Officer, Class 2
  • ****
  • G
  • Posts: 69
  • Thanked: 16 times
  • Waiting until I have the Time to play.
Re: C# Suggestions
« Reply #2026 on: August 07, 2021, 05:31:51 PM »
Currently, a number of quantities which scale with starting population at game start have hard limits beyond which they do not scale. The most obvious of these is research points and research labs which are both capped at 200,000 and 50 respectively (corresponding to 1.25b population). Similarly the number of starting officers is capped at, IIRC, 200 (where the default is 150 officers at 500m pop) which tends to be not enough at high populations with a lot of free BPs.

I would suggest that these and any other hard caps are removed and the scaling with population is directly proportional for all populations, possibly with a minimum for very low-pop starts.

While it is trivial for the player to change these quantities at game start, the bigger issue in my mind is the NPR balance. Additionally I think removing particularly the 50 Labs hard cap would help generated NPRs in the later game period remain competitive, as right now it is possible for the player to easily exceed the generated NPR starting tech levels once they have 75 or 100 labs and a few levels of RP boosting tech since new NPRs are still limited to 50 labs on spawning.
[snip]
This needs to be hard doubleplussed in my opinion. I am sure there are a lot of people who can't take the micro of manning multiple player races and this would be great for them. While I don't want to dismiss the other suggestions I think this needs to be mentioned.
Everyone asks me why I like The Hitchhiker's Guide to the Galaxy.  In actuality, my username predates my knowledge of the books.
 

Offline Droll

  • Vice Admiral
  • **********
  • D
  • Posts: 1704
  • Thanked: 599 times
Re: C# Suggestions
« Reply #2027 on: August 07, 2021, 08:06:21 PM »
It may be said already, but starting to feel the need for a Standing Orders Template

Also, the more I think about it and the more I realize that being the same for essentially every race and ship, such templates could be exported, imported and shared through the entire database.

I think I could spare something like 100/200 clicks and repetitions.

This would be great for multi-class survey ships as you could swap out their geosurvey templates for gravsurvey templates and vice versa. A useful extension of this would be to have a default template, not unlike what ground formations have, that way you could spam out 10 geosurvey ships and they'd immediately get to work once built.
 
The following users thanked this post: LiquidGold2

Offline db48x

  • Commodore
  • **********
  • d
  • Posts: 641
  • Thanked: 200 times
Re: C# Suggestions
« Reply #2028 on: August 07, 2021, 09:49:02 PM »
It’s always bothered me a little that ships in Aurora cannot predict the course of a planet and adjust their own heading to minimize the trip time, so I made a little toy program to see how hard it would be. Here’s a video of the result:

http://db48x.net/Aurora/four different ways of plotting a course in Aurora-2021-08-07_18.33.48.webm

(If anyone knows of a way to embed this in the post without uploading it to Youtube or Vimeo, let me know.)

The simplest thing to implement is what Aurora does; each ship simply heads directly towards the planet at every tick. These ships are shown in red, and as you can see they fall behind the planet and must catch up just as ships do in Aurora.

The next thing to do is make a simple measurement of the time it will take to reach the planet, then head for the place where the planet will be in that amount of time. These ships are shown in orange–red. Unfortunately this simple strategy overcompensates and causes the ships to get ahead of the planet before turning towards it.

Since neither of these strategies is amazing, perhaps we need something more sophisticated. A key observation is that we are trying to find an initial heading that minimizes the distance between the ship and the planet; ideally the ship should be zero pixels away from the planet in order to land.

We can easily search this space by considering the distance between the ship and planet at a grid of points in space, and finding the one that gets us the closest. These are the orange ships; you can see that they rarely find a heading that gets them close enough to land, so most of them miss. This is easy to write but rather imprecise in practice. Note that these ships only calculate their course once, on the frame that they are spawned.

For reference, here is a screenshot showing all the points that it considered; the coarseness of this grid is why the ships usually miss. Making the grid finer can make the ships miss less frequently, but at a higher runtime cost. Still, my toy prototype maintains 60fps…



To do better than this we can use a little calculus. Instead of considering points on a fixed–size grid that will always be either too coarse or too expensive, we should adjust the point based on the slope of the function we are minimizing. This search strategy is called “gradient descent”, and the white ships use it. You can see from the debug output that the search always stops once it gets within half a pixel of the planet, and that it usually only takes a couple of dozen steps to find this point. Occasionally it takes many more, but even so it doesn’t blow the frame budget. Like the grid search ships, these only need to calculate their course once.

I suggest that Aurora should have better navigation. My prototype shows that it is entirely feasible; I didn’t even have to implement gradient descent myself; I just used an open–source library for that.

However, I do want to point out that my prototype does have some flaws, which I have arranged not to show off in this video.

If the jump point is very near the orbit, then the gradient descent search goes a little off the rails. It still finds a good solution, but it can take seconds instead of milliseconds. That’s terrible in a 60fps game, but it would be completely unnoticeable in Aurora. Also, it’s probably just a bug in my code rather than an inherent problem with gradient descent.

One thing that is a problem with gradient descent is that sometimes it finds a solution in the past. These solutions only work if the ship and the planet both run backwards, which would be silly. The gradient descent algorithm just looks for minima of the function you give it, and this one has more than one of them. In fact, it has infinitely many since the angle wraps around. Mostly those aren’t a problem, though it is funny to see it pick an optimal heading of 16.622303 or −46.64971 radians. I’ve partly solved this problem with an exponential penalty for negative time values and with a better guess for the starting conditions for the search, but it isn’t perfect. I think that if I picked those initial conditions using a simple grid search (like the third type of ship uses), then it would go away entirely.

The third problem is that my collision detection just looks for ships that are within 1px of a planet. That usually works, but if the planet and ship are headed towards each other then they can move past each other between frames and the ship never lands. That’s easy to fix, I just didn’t do it. We’ll just pretend that the captain was napping and the crew didn’t want to wake him.

Another limitation is that I have not yet written the code to do these computations for moons, moons of moons, etc. This would be quite trivial to do for the first three algorithms, and should only be moderately annoying for the gradient descent search. For that one I have to actually compute the derivative of the distance function; luckily I don’t have to do that by hand.

I put my code on GitLab in case any one is interested in taking a look or running it themselves.
 
The following users thanked this post: serger, Vizzy, nuclearslurpee

Offline nuclearslurpee

  • Admiral of the Fleet
  • ***********
  • Posts: 2984
  • Thanked: 2243 times
  • Radioactive frozen beverage.
Re: C# Suggestions
« Reply #2029 on: August 08, 2021, 12:06:05 AM »
Some interesting work here. I do have a quick question: does your algorithm account for the fact that planetary/body motion in Aurora takes place only on the construction increments? It seems like that should make an algorithm much easier, since you can basically loop over a limited set of body positions instead of solving a problem in continual dimensional space.

This would require pathfinding to be aware of the time until the next increment, which I don't know if it currently is, but otherwise would be simpler and not require more complex algorithms. I think particularly this may be important as I doubt Steve wants to use other libraries to write his code for him, since Aurora is a coding hobby project as much as a game for him.
 

Offline QuakeIV

  • Registered
  • Commodore
  • **********
  • Posts: 759
  • Thanked: 168 times
Re: C# Suggestions
« Reply #2030 on: August 08, 2021, 02:45:24 AM »
There shouldnt be any actual need for a solver to calculate this.  Im pretty sure in particular given that the orbits are perfectly circular there is a calculable way to find the intercept without iterating.
 
The following users thanked this post: serger

Offline Steve Walmsley

  • Aurora Designer
  • Star Marshal
  • S
  • Posts: 11671
  • Thanked: 20444 times
Re: C# Suggestions
« Reply #2031 on: August 08, 2021, 09:12:06 AM »
There shouldnt be any actual need for a solver to calculate this.  Im pretty sure in particular given that the orbits are perfectly circular there is a calculable way to find the intercept without iterating.

Funny you should make that post today :)

In Newtonian Aurora, I had a problem of a missile intercepting a ship from a billion kilometres away. Unfortunately, both were accelerating and both were burning fuel, which meant constant changes in mass and therefore rate of acceleration. After tackling the complex math, I hit on a much simpler solution. The missile guessed a direction, then plotted what happened. Based on that information, it made a better guess and then repeated until it picked the right course. No complex math and hit every time :)

I could write some code to calculate the intercept, even with the new eccentric orbits, but it would add processing time. I'm not sure how much without coding it, but movement is the already the largest time-sink. It would also require the necessary enthusiasm from me to solve a problem that isn't really a major issue.

In summary, the reason that ships don't intercept planets is not due to an inability to solve the problem, but rather a question of priority and enthusiasm.
 

Offline Droll

  • Vice Admiral
  • **********
  • D
  • Posts: 1704
  • Thanked: 599 times
Re: C# Suggestions
« Reply #2032 on: August 08, 2021, 09:18:58 AM »
There shouldnt be any actual need for a solver to calculate this.  Im pretty sure in particular given that the orbits are perfectly circular there is a calculable way to find the intercept without iterating.
The missile guessed a direction, then plotted what happened. Based on that information, it made a better guess and then repeated until it picked the right course. No complex math and hit every time :)

So your saying that the missile knows where it is, and also where it isn't.
 
The following users thanked this post: LiquidGold2

Offline serger

  • Commodore
  • **********
  • Posts: 634
  • Thanked: 120 times
  • Silver Supporter Silver Supporter : Support the forums with a Silver subscription
    2021 Supporter 2021 Supporter : Donate for 2021
    2022 Supporter 2022 Supporter : Donate for 2022
Re: C# Suggestions
« Reply #2033 on: August 08, 2021, 11:43:19 AM »
With new Eccentric Orbits - is it possible to show in Galactic Map an upper half of planet's circle in a colour of current CC and a lower half in a colour of max CC?
 

Offline unkfester

  • Silver Supporter
  • Warrant Officer, Class 1
  • *****
  • Posts: 78
  • Thanked: 1 times
  • Discord Username: unkfester
  • Silver Supporter Silver Supporter : Support the forums with a Silver subscription
    2021 Supporter 2021 Supporter : Donate for 2021
    2023 Supporter 2023 Supporter : Donate for 2023
    2024 Supporter 2024 Supporter : Donate for 2024
Re: C# Suggestions
« Reply #2034 on: August 08, 2021, 12:06:39 PM »
quantum missiles
 

Offline db48x

  • Commodore
  • **********
  • d
  • Posts: 641
  • Thanked: 200 times
Re: C# Suggestions
« Reply #2035 on: August 08, 2021, 12:50:15 PM »
Some interesting work here. I do have a quick question: does your algorithm account for the fact that planetary/body motion in Aurora takes place only on the construction increments? It seems like that should make an algorithm much easier, since you can basically loop over a limited set of body positions instead of solving a problem in continual dimensional space.

This would require pathfinding to be aware of the time until the next increment, which I don't know if it currently is, but otherwise would be simpler and not require more complex algorithms. I think particularly this may be important as I doubt Steve wants to use other libraries to write his code for him, since Aurora is a coding hobby project as much as a game for him.

Thank you :)

I completely ignored that problem. In my program, the positions of objects are entirely computed based on the number of seconds since the program started up. I didn’t even add a way to pause the simulation!

Incidentally, since planetary motion is so cheap, I also suggest that it ought to be decoupled from the construction cycle.
 

Offline db48x

  • Commodore
  • **********
  • d
  • Posts: 641
  • Thanked: 200 times
Re: C# Suggestions
« Reply #2036 on: August 08, 2021, 12:52:29 PM »
There shouldnt be any actual need for a solver to calculate this.  Im pretty sure in particular given that the orbits are perfectly circular there is a calculable way to find the intercept without iterating.

I thought so too, at first. I spent some time over the last couple of months trying to find a closed–form solution with no luck. Of course that doesn’t mean that it doesn’t exist; I did discover how much calculus I had forgotten over the last 20 years. I would be quite willing to be proven wrong on that point!
 

Offline db48x

  • Commodore
  • **********
  • d
  • Posts: 641
  • Thanked: 200 times
Re: C# Suggestions
« Reply #2037 on: August 08, 2021, 03:04:25 PM »
There shouldnt be any actual need for a solver to calculate this.  Im pretty sure in particular given that the orbits are perfectly circular there is a calculable way to find the intercept without iterating.

Funny you should make that post today :)

In Newtonian Aurora, I had a problem of a missile intercepting a ship from a billion kilometres away. Unfortunately, both were accelerating and both were burning fuel, which meant constant changes in mass and therefore rate of acceleration. After tackling the complex math, I hit on a much simpler solution. The missile guessed a direction, then plotted what happened. Based on that information, it made a better guess and then repeated until it picked the right course. No complex math and hit every time :)

An interesting point. Should missiles even be able to take into account the fuel state of their target?

I could write some code to calculate the intercept, even with the new eccentric orbits, but it would add processing time. I'm not sure how much without coding it, but movement is the already the largest time-sink. It would also require the necessary enthusiasm from me to solve a problem that isn't really a major issue.

In summary, the reason that ships don't intercept planets is not due to an inability to solve the problem, but rather a question of priority and enthusiasm.

One good thing about doing the work to find the exact correct course is that it only needs to be done once, when you start working on a new order. It also gives you an exact time of arrival, so you could schedule a sub–pulse for exactly that time.
 
The following users thanked this post: LiquidGold2

Offline ISN

  • Sub-Lieutenant
  • ******
  • I
  • Posts: 108
  • Thanked: 38 times
Re: C# Suggestions
« Reply #2038 on: August 08, 2021, 03:08:50 PM »
With the new changes to system generation, it would be particularly useful to have a "Redo system bodies" button in SM mode that reruns the entire system body generation process (unless there's already some way of doing this that I'm missing. I know you can just delete the system and explore the JP again, but you'll likely end up with a different star, which isn't always desirable, and using the "Create System" button to pick the star means you have to set up the JP connections to your other systems manually). Previously if I wanted to customize a system I would just add and remove bodies as desired. But with the new eccentricity rules, twin planets, and gas giant effects I feel it would be difficult to make by hand a system that fits in with the procedurally generated systems. For instance, if I want a system with a terrestrial planet thrown into an eccentric orbit by a gas giant, it would be much easier to simply rerun the process until I get what I want rather than try to design it manually. This button would be useful even if you don't care about the new system generation features, though: it would make generating the systems you want much easier in general.
 
The following users thanked this post: serger

Offline serger

  • Commodore
  • **********
  • Posts: 634
  • Thanked: 120 times
  • Silver Supporter Silver Supporter : Support the forums with a Silver subscription
    2021 Supporter 2021 Supporter : Donate for 2021
    2022 Supporter 2022 Supporter : Donate for 2022
Re: C# Suggestions
« Reply #2039 on: August 09, 2021, 07:50:22 AM »
I have made some Ground Weapon tinkering sugestion in a separate thread (http://aurora2.pentarch.org/index.php?topic=12687.0), so posting this here as a note just in case that Steve will have someday a time and inspiration for.