Author Topic: Update on Progress  (Read 254528 times)

0 Members and 1 Guest are viewing this topic.

Offline boggo2300

  • Registered
  • Rear Admiral
  • **********
  • Posts: 895
  • Thanked: 16 times
Re: Update on Progress
« Reply #270 on: August 06, 2019, 05:02:45 PM »
Trying to figure out all the possible contingencies that could happen in a game as complex as Aurora, and the possible consequences of them all is quite a daunting task, for very little gain in the end.

Yes, I have spent the last two evenings doing nothing but optimise the AI code that decides when a ship reloads missiles :)

It is surprising how many factors have to be considered to make a decision that at first glance would seem to be trivial. There can be multiple ships in an AI fleet, only some of which are missile-armed, and different ships have different values in terms of whether the fleet can accomplish its missions, which means reloading some ships is more urgent than others, plus the presence, proximity and capability of hostile units can change the decision and also the location of the reload point versus the ship's current location. The current amount of ordnance vs maximum possible is also a factor. I've also had to handle the situation where a ship is firing from a location in which it can simultaneously reload to make sure it doesn't just fire a single missile as soon as it arrives in the magazine (because reloading now takes time).

Consider that relatively minor decision vs all the other decisions that the AI has to make and you get an idea of the scale of the AI programming task :)

Have you considered breaking the actual AI logic out into text files that the specific code calls when a decision is needed? ie when magazines are empty call ai_missile_reload.txt  and then breaking the actual logic out into that file (like Space Empires did around version 3) though I suspect that would cause a performance hit it would make tweaking the ai easier
The boggosity of the universe tends towards maximum.
 

Offline Steve Walmsley (OP)

  • Moderator
  • Star Marshal
  • *****
  • S
  • Posts: 11658
  • Thanked: 20379 times
Re: Update on Progress
« Reply #271 on: August 07, 2019, 04:09:09 AM »
Trying to figure out all the possible contingencies that could happen in a game as complex as Aurora, and the possible consequences of them all is quite a daunting task, for very little gain in the end.

Yes, I have spent the last two evenings doing nothing but optimise the AI code that decides when a ship reloads missiles :)

It is surprising how many factors have to be considered to make a decision that at first glance would seem to be trivial. There can be multiple ships in an AI fleet, only some of which are missile-armed, and different ships have different values in terms of whether the fleet can accomplish its missions, which means reloading some ships is more urgent than others, plus the presence, proximity and capability of hostile units can change the decision and also the location of the reload point versus the ship's current location. The current amount of ordnance vs maximum possible is also a factor. I've also had to handle the situation where a ship is firing from a location in which it can simultaneously reload to make sure it doesn't just fire a single missile as soon as it arrives in the magazine (because reloading now takes time).

Consider that relatively minor decision vs all the other decisions that the AI has to make and you get an idea of the scale of the AI programming task :)

Have you considered breaking the actual AI logic out into text files that the specific code calls when a decision is needed? ie when magazines are empty call ai_missile_reload.txt  and then breaking the actual logic out into that file (like Space Empires did around version 3) though I suspect that would cause a performance hit it would make tweaking the ai easier

The AI is too integrated into everything else for it to be separated into a standalone file. For example, each ship AI checks its own status with a variety of parameters (fuel, ordnance, damage, ability to perform primary mission, etc). For ordnance for example, there are five statuses. Ordnance Not Needed, Fully Loaded, Reload Required, Urgent Reload Required and Empty. Each fleet AI then checks the status of its constituent ships and makes a determination at the fleet level for each status, which is different for the whole fleet vs any key element ships. So the ordnance status of a key element ship is more important than an escort and the number of ships with lower ordnance statuses has an impact too. The Race AI will take account of the fleet status when deciding how to deploy the ships within the Empire and the System AI will use the status when deciding how to deploy the fleets assigned to it by the Race AI.

The code that checks for fleets needing a reload occurs in three places, depending on the urgency of other tasks. So in some situations a fleet with a status of Reload Required might be sent to reload, although perhaps not if there are hostile ships in the system, depending on the threat posed by those ships (threat is assessed at a system level and for each grouping of hostile ships). The level of threat required to overcome an Urgent Reload Required status is different than for Reload Required, so the AI may sent urgent status fleets for reload, then assign other available forces to deal with the threats (or run away from them) and then check for reload status fleets that were not required to deal with threats, etc.

When a reload decision is made, the Population AIs check their own missiles available and the System and Race AIs try to match up ships needing particular missile types with those missiles available at population, taking into account demand so that sufficient missiles are available at a population for the ships en route to reload. Some ships may be sent further away if a population doesn't have sufficient missiles to meet local demand.

With those type of interactions, you can't really create a standalone script file because the reload isn't a standalone decision.
 

Offline chrislocke2000

  • Captain
  • **********
  • c
  • Posts: 544
  • Thanked: 39 times
Re: Update on Progress
« Reply #272 on: August 07, 2019, 07:28:59 AM »
Its hugely exciting to see the level of thought and consideration going into the AI which looks like it will provide a real step up in challenge compared to the current AI. Have you had more of a chance to see it in action in your current test campaign?
 

Offline Steve Walmsley (OP)

  • Moderator
  • Star Marshal
  • *****
  • S
  • Posts: 11658
  • Thanked: 20379 times
Re: Update on Progress
« Reply #273 on: August 07, 2019, 07:47:18 AM »
Its hugely exciting to see the level of thought and consideration going into the AI which looks like it will provide a real step up in challenge compared to the current AI. Have you had more of a chance to see it in action in your current test campaign?

Yes, the AI is launching on my player race at the moment (which is why the sudden focus on reloading :) )

The AI killed a survey ship by sending out a small squadron to intercept. A large player fleet has now arrived. Rather than blindly attacking, the AI is holding its missile ships at a planet covered by defences and firing from there as the player ships approach. They can also reload at that location.
 
The following users thanked this post: Garfunkel, SpikeTheHobbitMage, Mastik, Alucard, Kiri

Offline Jovus

  • Lt. Commander
  • ********
  • J
  • Posts: 220
  • Thanked: 81 times
Re: Update on Progress
« Reply #274 on: August 07, 2019, 10:25:19 AM »
For those of us interested in how AI coding works, would you be willing to share a decision tree or the like for the AI once you get reloading working to your satisfaction?

I don't mean code, but more an informal design document, I guess. Just because it's really cool.
 

Offline Steve Walmsley (OP)

  • Moderator
  • Star Marshal
  • *****
  • S
  • Posts: 11658
  • Thanked: 20379 times
Re: Update on Progress
« Reply #275 on: August 07, 2019, 12:09:03 PM »
For those of us interested in how AI coding works, would you be willing to share a decision tree or the like for the AI once you get reloading working to your satisfaction?

I don't mean code, but more an informal design document, I guess. Just because it's really cool.

I don't have any design documentation :)

I code based on the overall design in my head (not just for AI - for the whole project). I know in broad terms what needs to be done and how it will all fit together, so I just sort of transfer my thoughts into the code syntax and then fix problems as I find them. The code and the comments become the design documentation. This may seem a chaotic approach but my experience has been that you can never think of everything beforehand and you will spend a great deal of time trying, so I just start coding and work it out as I go.

There isn't an overall decision tree as such. Each ship, fleet, population, system and race has its own AI. Each one makes decisions based on the information passed to it by higher and lower AI and within the parameters set by those AI. It is event-driven, rather than linear. For example, if a system AI detects hostile forces, it will inform the race AI. Depending on how the threat is assessed, the Race AI may tell the System AI to evacuate the non-combatants. The Race AI will also pass on which adjacent systems are regarded as safe. The System AI decides which fleets need to leave but also tells them the location of the known threats and the safest fall back positions within the system if they can't leave. The Fleet AI will try to calculate a path out of the system that avoids moving too close to the threats, or at least moving away if they are already close. If it can't find one, it will try to reach one of the 'safe' locations. So there are decisions being made at different levels based on the available information and each of those individual decisions has something like a decision tree, but the overall effect is more of a decision network. It would be difficult to put it down on paper in a concise way.
 
The following users thanked this post: waresky, davidr, Doren, SpikeTheHobbitMage, Jovus, Kiri

Offline Steve Walmsley (OP)

  • Moderator
  • Star Marshal
  • *****
  • S
  • Posts: 11658
  • Thanked: 20379 times
Re: Update on Progress
« Reply #276 on: August 20, 2019, 12:44:08 PM »
Latest amusing bug. The AI tried to intercept its own anti-ship missiles with AMMs :)

This happened because the AI ships and the player ships could both detect the AI anti-ship missiles at the same time (the two sides are only 500k km apart) and the AI fired at the player race's hostile missile contact. Oops!

This is why some bugs are hard to spot. They need a specific situation before they manifest. The good thing about C# Aurora is that there is a Save button, so when something like this happens I can fix the code and go back to the previous save.

 
The following users thanked this post: Demonides, AlStar, Jorgen_CAB, Zincat, hyramgraff, punchkid, Agoelia

Offline xenoscepter

  • Vice Admiral
  • **********
  • Posts: 1156
  • Thanked: 318 times
Re: Update on Progress
« Reply #277 on: August 20, 2019, 01:28:05 PM »
SAVE BUTTON!?!? Praise z0rg!
 
The following users thanked this post: Demonides

Offline mtm84

  • Sub-Lieutenant
  • ******
  • m
  • Posts: 131
  • Thanked: 36 times
Re: Update on Progress
« Reply #278 on: August 20, 2019, 02:26:01 PM »
If i remember right as part of database optimization, in C# Aurora he is only saving to the DB after it processes a turn, instead of interacting with the DB any time there is a user interaction.  This makes it easy to have a save button so you can save it in between turns as well.
 

Offline Froggiest1982

  • Gold Supporter
  • Vice Admiral
  • *****
  • F
  • Posts: 1332
  • Thanked: 591 times
  • Gold Supporter Gold Supporter : Support the forums with a Gold subscription
    2021 Supporter 2021 Supporter : Donate for 2021
    2022 Supporter 2022 Supporter : Donate for 2022
    2023 Supporter 2023 Supporter : Donate for 2023
Re: Update on Progress
« Reply #279 on: August 20, 2019, 04:24:17 PM »
The good thing about C# Aurora is that there is a Save button, so when something like this happens I can fix the code and go back to the previous save.

Steve you cannot drop bombs like that in a post! Unless I didn't see it in the new feature list this should have been mentioned sometime before today!

Another QOL improvement that is worth more than some new feature.

Offline QuakeIV

  • Registered
  • Commodore
  • **********
  • Posts: 759
  • Thanked: 168 times
Re: Update on Progress
« Reply #280 on: August 20, 2019, 09:18:24 PM »
Didn't he mention the save button ages ago?  I don't fully remember now.  I'm pretty sure he doesn't hit the DB at all unless you are saving for some reason, which is why turns go faster.
 

Offline Doren

  • Sub-Lieutenant
  • ******
  • D
  • Posts: 137
  • Thanked: 34 times
Re: Update on Progress
« Reply #281 on: August 20, 2019, 11:31:50 PM »
Didn't he mention the save button ages ago?  I don't fully remember now.  I'm pretty sure he doesn't hit the DB at all unless you are saving for some reason, which is why turns go faster.
I think this was the case. No saves until you hit the button
 

Offline Steve Walmsley (OP)

  • Moderator
  • Star Marshal
  • *****
  • S
  • Posts: 11658
  • Thanked: 20379 times
Re: Update on Progress
« Reply #282 on: August 21, 2019, 02:55:29 AM »
I didn't realise I hadn't officially mentioned it :)

C# Aurora doesn't continually update to disk, which is why it is so much faster (still about 1 second per turn in my current campaign which is on year eleven). When you save, it takes about thirty seconds. The database pre-save is copied to a new file called AuroraDBSaveBackup.db and then the AuroraDB file is updated with the current game. The downside is that if you close without saving you lose progress. I tend to save quite often.

It is super useful for testing through as I can run the same situation many times without having to save and restore db files.
 
The following users thanked this post: Demonides, Viridia

Offline Shuul

  • Sub-Lieutenant
  • ******
  • S
  • Posts: 108
  • Thanked: 28 times
Re: Update on Progress
« Reply #283 on: August 21, 2019, 03:09:16 AM »
The downside is that if you close without saving you lose progress. I tend to save quite often.


Can we get a confirmation window before closing the game to remind us to save? I believe many players are very used to how VB6 version works and will forget to save.
 
The following users thanked this post: Viridia, Agoelia

Offline Tree

  • Sub-Lieutenant
  • ******
  • Posts: 143
  • Thanked: 27 times
Re: Update on Progress
« Reply #284 on: August 21, 2019, 03:15:34 AM »
I didn't realise I hadn't officially mentioned it :)

C# Aurora doesn't continually update to disk, which is why it is so much faster (still about 1 second per turn in my current campaign which is on year eleven). When you save, it takes about thirty seconds. The database pre-save is copied to a new file called AuroraDBSaveBackup.db and then the AuroraDB file is updated with the current game. The downside is that if you close without saving you lose progress. I tend to save quite often.

It is super useful for testing through as I can run the same situation many times without having to save and restore db files.

Will you also add an autosave feature? Maybe something customizable, so you can set it to save every hour while fighting a battle, every month if you're moving a lot of ships, or only every year if you're just clicking through?