Author Topic: C# Suggestions  (Read 272805 times)

0 Members and 3 Guests are viewing this topic.

Offline Barkhorn

  • Commodore
  • **********
  • B
  • Posts: 719
  • Thanked: 133 times
Re: C# Suggestions
« Reply #330 on: April 24, 2020, 07:12:25 PM »
Could we have a way to sell ships and perhaps ground equipment on the civilian market?  In real life, nations have often sold off surplus military hardware.  Many small commercial vessels even today were originally auxiliary military ships in WW2.  I think the reverse should also be possible.  Many navies have bought civilian ships to fill auxiliary roles.
 

Offline Father Tim

  • Vice Admiral
  • **********
  • Posts: 2162
  • Thanked: 531 times
Re: C# Suggestions
« Reply #331 on: April 24, 2020, 07:54:07 PM »
Could we have a way to sell ships and perhaps ground equipment on the civilian market?  In real life, nations have often sold off surplus military hardware.  Many small commercial vessels even today were originally auxiliary military ships in WW2.  I think the reverse should also be possible.  Many navies have bought civilian ships to fill auxiliary roles.

Delete the ship; SM add the wealth (and, if you feel it appropriate, minerals) you decide was the price.

For Aurora to dictate the price at which this happens, or whether or not there is a buyer, or to limit the frequency at which I can do this is to interfere with my fiction.  And I don't even know what that fiction is yet, but I'm pretty sure it's going to vary from game to game.

- - - - -

I would much rather see a way to sell (trade) to the AI.  I can already perform trade between two empires I control, but I can't buy up all my neighbour's Corbomite.  I can SM add all I want in exchange for my wealth, but the AI-run NPR doesn't lose any.
 
The following users thanked this post: DIT_grue, BAGrimm, Alsadius

Offline db48x

  • Commodore
  • **********
  • d
  • Posts: 641
  • Thanked: 200 times
Re: C# Suggestions
« Reply #332 on: April 24, 2020, 10:23:50 PM »
I'm not certain if this should go in Suggestions or Development Discussion since it is regarding the database, but there is potential for some improvement that Steve might want to consider.

Saving the 1.8.0 stock game on my machine takes around 30 seconds.  During this time the journal file is repeatedly created and destroyed with heavy disk activity.  This seems excessive for an 80MB file.

This post explains what is happening.
Quote from: Steve Walmsley link=topic=10096.msg116038#msg116038
I am using a single transaction for each table, so all rows are committed at once.

In an attempt to simulate this behaviour, I ran some tests using sqlite3's command line utility and the stock 1.8.0 database.

Test script:
Code: [Select]
# create test files, stripping query optimization data.
sqlite3 AuroraDB.db '.dump' | grep -v 'sqlite_stat' | grep -v 'ANALYZE' > dump.prime.txt

# insert DELETE FROM commands.
sed -E 's/CREATE TABLE (IF NOT EXISTS)?([^(]+)\(/DELETE FROM\2;\n\0/' < dump.prime.txt > dump.single.txt

# break into multiple transactions.
sed -E 's/(DELETE FROM|CREATE TABLE)/COMMIT;\nBEGIN IMMEDIATE;\n\0/' < dump.single.txt > dump.multi.txt

# prime temporary database
sqlite3 dump.db < dump.prime.txt

# simulate saving a game under various conditions
sqlite3 dump.db 'PRAGMA journal_mode=delete;'
time sqlite3 dump.db < dump.multi.txt
time sqlite3 dump.db < dump.single.txt

sqlite3 dump.db 'PRAGMA journal_mode=wal;'
time sqlite3 dump.db < dump.multi.txt
time sqlite3 dump.db < dump.single.txt

# clean up
rm dump.*

Results:
The closest simulation I could produce completed in 25.742 seconds.  This test was two transactions per table, one to erase followed by another to fill.
Converting to a single transaction for the entire operation reduced this to 3.489 seconds, more than 7x faster than baseline.
Multiple transactions running WAL mode completed in 8.712 seconds, nearly 3x faster than baseline.
Using both optimizations completed in only 2.876 seconds, nearly 9x faster than baseline.

3-4 seconds per save is fast enough that an auto-save option becomes viable, including save-on-exit.

Further testing (by killing Aurora while it was saving) revealed another issue:
Currently, if a save is interrupted (game or computer crash, power failure, etc), then sqlite can't correctly recover the database on the next start.  Some tables will be updated to the new state while others remain in the old state.  Because deletes and inserts are separate transactions, whichever table is being written at the time will be left blank*.  Using a single transaction per save guarantees that either the new state is completely written out or the old state can be automatically restored when Aurora is next started.

*While testing this I managed to delete every ship in the default game, and another time deleted the event history.  I'm not certain what got nuked by the other attempts, only that the database got smaller.  When restarted, Aurora reported no errors in any case.  Sadly, I never managed to accidentally Sol.  :(

Suggestions:
Use a single transaction per save so that auto-saving becomes practical.
-I recommend running all of the DELETEs before running any of the INSERTs to minimize fragmentation.
Auto-save periodically during long execution runs.
Auto-save on exit.

Two minor suggestions:
Set the page size to 4096 for around 10% faster disk performance on modern hardware.  This setting is persistent and requires no code changes.
The database could stand to be VACUUMed once in a while.  This is equivalent to the old VB "compact database" command.

If anyone is putting together a launcher like VB Aurora had, these last two are low hanging fruit.

There's an even easier way to save the in-memory database to an on-disk database. Just run 'VACUUM INTO filename', where the filename is the file you want to save into. It deletes the target file, so if you should first rename the exisiting file so that it becomes the backup. https://sqlite.org/lang_vacuum.html

Additionally, you should have access to the online backup API, which can also be used to save an in-memory database to a file. It doesn't do any vaccuming, so it's even faster. https://sqlite.org/backup.html

Edit: I almost forgot to mention, but the backup API can be run incrementally, meaning that autosaves can be really fast by doing incremental backups.
« Last Edit: April 24, 2020, 10:30:58 PM by db48x »
 

Offline HeroicHan

  • Petty Officer
  • **
  • H
  • Posts: 26
  • Thanked: 2 times
Re: C# Suggestions
« Reply #333 on: April 24, 2020, 10:28:04 PM »
Could we have a way to sell ships and perhaps ground equipment on the civilian market?  In real life, nations have often sold off surplus military hardware.  Many small commercial vessels even today were originally auxiliary military ships in WW2.  I think the reverse should also be possible.  Many navies have bought civilian ships to fill auxiliary roles.

Delete the ship; SM add the wealth (and, if you feel it appropriate, minerals) you decide was the price.

For Aurora to dictate the price at which this happens, or whether or not there is a buyer, or to limit the frequency at which I can do this is to interfere with my fiction.  And I don't even know what that fiction is yet, but I'm pretty sure it's going to vary from game to game.

- - - - -

I would much rather see a way to sell (trade) to the AI.  I can already perform trade between two empires I control, but I can't buy up all my neighbour's Corbomite.  I can SM add all I want in exchange for my wealth, but the AI-run NPR doesn't lose any.

And how do you SM the price?
 

Offline Father Tim

  • Vice Admiral
  • **********
  • Posts: 2162
  • Thanked: 531 times
Re: C# Suggestions
« Reply #334 on: April 24, 2020, 11:24:14 PM »
And how do you SM the price?


Space Master on, Colony screen, commercial shipping tab or wealth tab or mining tab to see the buttons or stockpiles to which you want to add the "price".

- - - - -

If you mean 'how do I set the price for a particular ship' -- I let my fiction do it for me.  Sometimes I even roll dice.
 

Offline skoormit

  • Rear Admiral
  • **********
  • Posts: 804
  • Thanked: 324 times
Re: C# Suggestions
« Reply #335 on: April 25, 2020, 07:17:12 AM »
And how do you SM the price?


Space Master on, Colony screen, commercial shipping tab or wealth tab or mining tab to see the buttons or stockpiles to which you want to add the "price".

- - - - -

If you mean 'how do I set the price for a particular ship' -- I let my fiction do it for me.  Sometimes I even roll dice.

I'm not following.
I see SM buttons on the Civilian Economy tab to add/edit numbers of installations.
But I don't see anything similar on the Mining tab or the Wealth tab.
 

Offline swarm_sadist

  • Lt. Commander
  • ********
  • s
  • Posts: 263
  • Thanked: 21 times
Re: C# Suggestions
« Reply #336 on: April 25, 2020, 07:49:13 AM »
Put the advanced time buttons in the event screen, or have a toggle to keep the events screen in front of the tactical map.
 

Offline SpaceMarine

  • Bug Moderators
  • Rear Admiral
  • ***
  • Posts: 904
  • Thanked: 877 times
Re: C# Suggestions
« Reply #337 on: April 25, 2020, 07:51:16 AM »
this will be much less needed because events on the tactical map is coming in 1.9
 

Offline Alsadius

  • Lieutenant
  • *******
  • Posts: 178
  • Thanked: 89 times
Re: C# Suggestions
« Reply #338 on: April 25, 2020, 10:34:36 AM »
Moving ground forces in a transport ship is annoying. A couple QoL requests - either:

1) Add a "Move including Subordinates" button that allows me to move a whole force structure, not just one division HQ at a time.

and/or

2) Let us multi-select in the orders window. I can click multiple ground units, but I can't actually order them all to be picked up at once.

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 #339 on: April 25, 2020, 11:03:17 AM »
Moving ground forces in a transport ship is annoying. A couple QoL requests - either:

1) Add a "Move including Subordinates" button that allows me to move a whole force structure, not just one division HQ at a time.

It seem that this is possible, I am using Load All Sub-Units check box and my troop transport will load whole formation.
 

Offline Father Tim

  • Vice Admiral
  • **********
  • Posts: 2162
  • Thanked: 531 times
Re: C# Suggestions
« Reply #340 on: April 25, 2020, 11:22:36 AM »
I'm not following.
I see SM buttons on the Civilian Economy tab to add/edit numbers of installations.
But I don't see anything similar on the Mining tab or the Wealth tab.


In SpaceMaster, untick "double click sets reserve amount" box.  Double-clicking now allows direct editing of colony stockpile.
 
The following users thanked this post: skoormit

Offline RagnarVaren

  • Chief Petty Officer
  • ***
  • R
  • Posts: 31
  • Thanked: 11 times
Re: C# Suggestions
« Reply #341 on: April 25, 2020, 01:45:19 PM »
Some suggestions for the civilians shipping orders mechanic.

1. Allow the player to specify supply and demand of minerals. This should preferably be in multiple of 1 thousand minerals to make it easier to set up.
2. Allow supply orders for installations that don't exist yet. When checking for supply to assign to a civilian check if that installation exists and then reserve it instead of failing to pickup when it doesn't exist. Current functionality makes it necessary to constantly update the supply when new installations are built for example when building terraforming installations at Earth would be nice to simply set supply and let the civilians check if it exists yet.
3. Allow civilian shipping of maintenance supplies and fuel (with the required new civilian designs). This will make it easier to manage outposts.
 

Offline Father Tim

  • Vice Admiral
  • **********
  • Posts: 2162
  • Thanked: 531 times
Re: C# Suggestions
« Reply #342 on: April 25, 2020, 02:06:08 PM »
Some suggestions for the civilians shipping orders mechanic.

1. Allow the player to specify supply and demand of minerals. This should preferably be in multiple of 1 thousand minerals to make it easier to set up.
2. Allow supply orders for installations that don't exist yet. When checking for supply to assign to a civilian check if that installation exists and then reserve it instead of failing to pickup when it doesn't exist. Current functionality makes it necessary to constantly update the supply when new installations are built for example when building terraforming installations at Earth would be nice to simply set supply and let the civilians check if it exists yet.
3. Allow civilian shipping of maintenance supplies and fuel (with the required new civilian designs). This will make it easier to manage outposts.


Again, these largely amount to "remove any remaining need for government-owned shipping" and I, for one, would like to see shipping lines move in other direction -- that of becoming less useful.
 

Offline Jorgen_CAB

  • Admiral of the Fleet
  • ***********
  • J
  • Posts: 2837
  • Thanked: 673 times
Re: C# Suggestions
« Reply #343 on: April 25, 2020, 02:26:10 PM »
Some suggestions for the civilians shipping orders mechanic.

1. Allow the player to specify supply and demand of minerals. This should preferably be in multiple of 1 thousand minerals to make it easier to set up.
2. Allow supply orders for installations that don't exist yet. When checking for supply to assign to a civilian check if that installation exists and then reserve it instead of failing to pickup when it doesn't exist. Current functionality makes it necessary to constantly update the supply when new installations are built for example when building terraforming installations at Earth would be nice to simply set supply and let the civilians check if it exists yet.
3. Allow civilian shipping of maintenance supplies and fuel (with the required new civilian designs). This will make it easier to manage outposts.


Again, these largely amount to "remove any remaining need for government-owned shipping" and I, for one, would like to see shipping lines move in other direction -- that of becoming less useful.

I don't see why we could eventually get both.

First of the civilian economy should actually consume Trans-Newtonian elements... either by mining them or buying them from the government. Lack of minerals could then have reduced production capacities and the like. Now.. this could be solved through the civilian trade system in some form.

Now... civilian shipping lines should require both fuel and minerals to operate, like government ships. There should be no free rides anywhere... fuel in particular needs to be created even for the civilian fleets.

You as the head of the government could then dictate in what field the civilians are allowed to operate... so you could ban civilians from mining at all, build fuel harvesters or just ban certain systems. Although there can be consequences by doing that... if you restrict them too much their income might go down so they can't maintain their fleets properly.

Now... operating government owned commercial ships will still be highly useful even if there is a civilian fleet doing some of the work. You as a player also can restrict the civilian fleet where it can operate which will impact their economy and the amount of ship they can maintain and build.

I also think that both Commercial and Civilian ship should cost an amount of Wealth each year in a maintenance fee... it could be something like 1/20 the build cost of the ship in a yearly cost. This would represent crew salaries and general maintenance of the ships.
 

Offline Barkhorn

  • Commodore
  • **********
  • B
  • Posts: 719
  • Thanked: 133 times
Re: C# Suggestions
« Reply #344 on: April 25, 2020, 04:12:38 PM »
Some suggestions for the civilians shipping orders mechanic.

1. Allow the player to specify supply and demand of minerals. This should preferably be in multiple of 1 thousand minerals to make it easier to set up.
2. Allow supply orders for installations that don't exist yet. When checking for supply to assign to a civilian check if that installation exists and then reserve it instead of failing to pickup when it doesn't exist. Current functionality makes it necessary to constantly update the supply when new installations are built for example when building terraforming installations at Earth would be nice to simply set supply and let the civilians check if it exists yet.
3. Allow civilian shipping of maintenance supplies and fuel (with the required new civilian designs). This will make it easier to manage outposts.


Again, these largely amount to "remove any remaining need for government-owned shipping" and I, for one, would like to see shipping lines move in other direction -- that of becoming less useful.
That's not very realistic though.  Governments mostly do not own cargo ships.  They contract out most of their needs.
 
The following users thanked this post: SpikeTheHobbitMage