Aurora 4x

VB6 Aurora => VB6 Mechanics => Topic started by: Steve Walmsley on January 08, 2010, 04:45:25 PM

Title: Civilian Contracts
Post by: Steve Walmsley on January 08, 2010, 04:45:25 PM
In v4.8, the civilian shipping lines will be able to move installations for you. You can setup a supply or demand contract for a specified amount of a specified installation type using a new section on the Civilian tab of the Economics window (see below). For example, you may setup a supply contract for 20 mines on Earth and a demand contract for 20 mines on Mars. For the civilians, this works in a very similar way to trade goods. They will look for matching supply and demand contracts, in this case on Earth and Mars, and create a trade run. As soon as they select the trade run and setup their orders, one installation is deducted from both the supply and demand contracts. This is to prevent duplication. The new contract section will show outstanding contracts and any contracts in progress that affect the population you are viewing. You don't have to worry about matching up contracts as the civilians will figure that out by themselves. If you have a surplus of something on a planet, then create a supply contract. If you need something, setup a demand contract. There may not be a match for it immediately but as soon as one appears the civs will spot it. Each freighter run will cost you 5 wealth for a same system contract and 10 wealth for an interstellar contract, which is paid when the freighter completes the contract. This wealth will be added to the wealth of the shipping line.

When a freighter is looking for a new trade run it will look at government contracts at its current location first, then potential trade runs at its current location, then government contracts originating in the same system, then trade runs originating in the same system, etc. As you already know, civilians work out trade runs for themselves and trade routes and trade hubs develop. In a well-developed game, If the civilian trade routes are not going near the locations of the supply contracts because there are easier trade runs available, you may have to move your installations to the nearest trade hub. It will be up to you to decide if partial civilian shipping is better than making the whole run with your own ships.

This should add a new dimension to NPRs as well. I will be able to create demand and supply contracts for various installations on individual worlds, depending on the situation on that world, without worrying about the NPR Empire situation as a whole. The NPR civilians will do that worrying for me.

[attachment=0:3nr8vhs8]Civs.JPG[/attachment:3nr8vhs8]
Steve
Title: Re: Civilian Contracts
Post by: schroeam on January 08, 2010, 05:47:35 PM
Steve,
So what happens if I have a surplus of 1 terraforming facility and Alien X, with whom I have a trade treaty, has a demand for 1 terraforming facility?  Will that facility suddenly get transferred to the alien world and would there be some sort of automatic credit transaction if that occurred?

Adam.
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 08, 2010, 05:54:20 PM
Quote from: "adradjool"
Steve,
So what happens if I have a surplus of 1 terraforming facility and Alien X, with whom I have a trade treaty, has a demand for 1 terraforming facility?  Will that facility suddenly get transferred to the alien world and would there be some sort of automatic credit transaction if that occurred?
Unlike trade goods, all government contracts are within one Empire only.

Steve
Title: Re: Civilian Contracts
Post by: sloanjh on January 08, 2010, 07:42:15 PM
This reminds me of a "feature" I ran into the last time I was running civies: the 4 jump limit.

Consider the following situation of 3 worlds

Homeworld A <--3 jumps --> Colony B <--3 jumps--> Colony C

I don't remember how it happened, but essentially I had colony ships that were stuck at either A or C, and didn't see any valid runs remaining so they just sat there.  I think it might have been that A and B were both sources of colonists, and the colony ships were at A, and didn't know they should go to C.

Is it possible to set the logic up so that civies will look farther than 4 jumps if they don't find anything within 4 jumps.  You could restrict it so it only looks for systems within the civie's owning empire beyond 4 jumps, so they don't end up traveling a long way into an alien empire (and so they can get back out if they do).

John
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 09, 2010, 09:30:49 AM
Quote from: "sloanjh"
This reminds me of a "feature" I ran into the last time I was running civies: the 4 jump limit.

Consider the following situation of 3 worlds

Homeworld A <--3 jumps --> Colony B <--3 jumps--> Colony C

I don't remember how it happened, but essentially I had colony ships that were stuck at either A or C, and didn't see any valid runs remaining so they just sat there.  I think it might have been that A and B were both sources of colonists, and the colony ships were at A, and didn't know they should go to C.

Is it possible to set the logic up so that civies will look farther than 4 jumps if they don't find anything within 4 jumps.  You could restrict it so it only looks for systems within the civie's owning empire beyond 4 jumps, so they don't end up traveling a long way into an alien empire (and so they can get back out if they do).
I can code for more than 4 jumps. The issue is more one of performance. There are a large number of checks performed during each increment with respect to finding things in other systems. Increasing the limit to 5 or 6 would potentially lead to an exponential effect on performace. Although perhaps I could set that up as a gameplay option so you could restrict or expend the limit if you wished. I'll give it some thought.

Steve
Title: Re: Civilian Contracts
Post by: sloanjh on January 09, 2010, 10:46:27 AM
Quote from: "Steve Walmsley"
Quote from: "sloanjh"
This reminds me of a "feature" I ran into the last time I was running civies: the 4 jump limit.

Consider the following situation of 3 worlds

Homeworld A <--3 jumps --> Colony B <--3 jumps--> Colony C

I don't remember how it happened, but essentially I had colony ships that were stuck at either A or C, and didn't see any valid runs remaining so they just sat there.  I think it might have been that A and B were both sources of colonists, and the colony ships were at A, and didn't know they should go to C.

Is it possible to set the logic up so that civies will look farther than 4 jumps if they don't find anything within 4 jumps.  You could restrict it so it only looks for systems within the civie's owning empire beyond 4 jumps, so they don't end up traveling a long way into an alien empire (and so they can get back out if they do).
I can code for more than 4 jumps. The issue is more one of performance. There are a large number of checks performed during each increment with respect to finding things in other systems. Increasing the limit to 5 or 6 would potentially lead to an exponential effect on performace. Although perhaps I could set that up as a gameplay option so you could restrict or expend the limit if you wished. I'll give it some thought.

Steve

Yeah, I figured that was the case.  Two thoughts on other options:

1)  Allow the player to give Aurora "hints" specifying trade routines between specific planet pairs that are more than 4 jumps apart.  So, in the example, I could open a "trade route configuration" screen, pick system A as a starting system, give it a series of jump orders (same as for TG on the F12 screen) that wind up at system C, then hit a "store trade route".  A commercial ship in A would then add the systems at the other end of all trade routes either originating in or terminating at A to the list of systems to check for contracts.  Note that I said "system" rather than "planet" in case there's more than one population in either A or C - one trade route would get all NxM combinations if there were N in A and M in C.

2)  (independent of #1)  You could add a second phase to the analysis of trade routes between systems.  In the first phase, Aurora finds all trade routes of length 4 or less between populated systems (this is essentially whats coded up now).  These, plus any player-defined trade routes (if you implemented #1) are used to build a graph (in the graph theory sense).  The nodes of the graph are populated systems, and the links are trade routes between them, plus the links could have a weight that was the number of jumps.  The idea here is that the trade routes can be thought of as "super jumps", with a variable cost.  You can the use the code you've already got to look for super-trade-routines that are up to 4 super jumps long.  In the example, there'd be trade routines AB (cost 3) and BC (cost 3).  A ship at A wouldn't find any contracts using a simple trade route.  So it would then look at the super-jump network, and notice a 2 super-jump route between A and C.

While typing this I realized that #2 is an optimization that can be stored in the data base.  There shouldn't be that many populated systems in an Aurora game (no more than a few hundred), so N^2 won't get you, and the trade routes will only change rarely (when a new jump gate is added, a new system is colonized (or decolonized), a new trade route defined by the player, etc), so the calculation of the trade route network would only need to be done infrequently.  The trade routes could also be used in the F12 orders screen - in addition to listing populations to jump to at the top of the screen, you could list populated systems to jump to (possibly on a checkbox option similar to waypoints).

John
Title: Re: Civilian Contracts
Post by: Father Tim on January 09, 2010, 11:34:53 AM
To keep the preformance costs down, you can simply set it up so that civilians will only look beyond four jumps if they can't find anything within four jumps.  That should solve the problem of 'stranded' ships that no longer have a trade route back to civilization.
Title: Re: Civilian Contracts
Post by: sloanjh on January 09, 2010, 12:26:34 PM
Quote from: "Father Tim"
To keep the preformance costs down, you can simply set it up so that civilians will only look beyond four jumps if they can't find anything within four jumps.  That should solve the problem of 'stranded' ships that no longer have a trade route back to civilization.

Yep, that was my original suggestion.  OTOH, my old empire got into a situation where there was more cargo capacity than interstellar trade would support.  I think Steve's afraid that one could get into a situation where a significant number of "extended searches" were happening every turn, and since the number of combinations probably grows exponentially in the number of jumps, that can get really slow really fast.

John
Title: Re: Civilian Contracts
Post by: boggo2300 on January 09, 2010, 05:10:51 PM
There will be much rejoicing throughout the United Kingdom of Terra (until they realise theyre about to be deleted for 4.8  :wink: ) I really like Johns idea of definig trade routes instead of just increasing the 4 jump limit, though not sure how easy that would be to impliment

Matt
Title: Re: Civilian Contracts
Post by: alanwebber on January 10, 2010, 07:13:35 AM
Steve

I have a problem with shipping lines. I have a colony next to Sol which is now over 30 million colonists. I set the colony to be a supplier of colonists and have another small colony within 2 jumps of Sol. All jumps have gates in place. However all the shipping lines stopped shipping colonists and are only moving freight to the one next door. I was also wondering about setting up transit lines which used to be available until you put the automatic system in place.
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 11, 2010, 07:17:56 AM
Quote from: "Father Tim"
To keep the preformance costs down, you can simply set it up so that civilians will only look beyond four jumps if they can't find anything within four jumps.  That should solve the problem of 'stranded' ships that no longer have a trade route back to civilization.
That is what happens at the moment. A fleet looks at every system within 1 jump. If nothing found then moves on to trying every system within 2 jumps, excluding the ones it just checked, etc.. My concern is more about the fact that some fleets are making four jump checks every increment for months on end until something changes. If that becomes five and six jump checks it will have an impact on performance.

Steve
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 11, 2010, 07:19:30 AM
Quote from: "alanwebber"
Steve

I have a problem with shipping lines. I have a colony next to Sol which is now over 30 million colonists. I set the colony to be a supplier of colonists and have another small colony within 2 jumps of Sol. All jumps have gates in place. However all the shipping lines stopped shipping colonists and are only moving freight to the one next door. I was also wondering about setting up transit lines which used to be available until you put the automatic system in place.
Has there been any combat in the affected system or en route? Civilians will avoid systems with recent combat for quite a while.

Steve
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 11, 2010, 07:36:35 AM
Quote from: "sloanjh"
1)  Allow the player to give Aurora "hints" specifying trade routines between specific planet pairs that are more than 4 jumps apart.  So, in the example, I could open a "trade route configuration" screen, pick system A as a starting system, give it a series of jump orders (same as for TG on the F12 screen) that wind up at system C, then hit a "store trade route".  A commercial ship in A would then add the systems at the other end of all trade routes either originating in or terminating at A to the list of systems to check for contracts.  Note that I said "system" rather than "planet" in case there's more than one population in either A or C - one trade route would get all NxM combinations if there were N in A and M in C.

2)  (independent of #1)  You could add a second phase to the analysis of trade routes between systems.  In the first phase, Aurora finds all trade routes of length 4 or less between populated systems (this is essentially whats coded up now).  These, plus any player-defined trade routes (if you implemented #1) are used to build a graph (in the graph theory sense).  The nodes of the graph are populated systems, and the links are trade routes between them, plus the links could have a weight that was the number of jumps.  The idea here is that the trade routes can be thought of as "super jumps", with a variable cost.  You can the use the code you've already got to look for super-trade-routines that are up to 4 super jumps long.  In the example, there'd be trade routines AB (cost 3) and BC (cost 3).  A ship at A wouldn't find any contracts using a simple trade route.  So it would then look at the super-jump network, and notice a 2 super-jump route between A and C.

While typing this I realized that #2 is an optimization that can be stored in the data base.  There shouldn't be that many populated systems in an Aurora game (no more than a few hundred), so N^2 won't get you, and the trade routes will only change rarely (when a new jump gate is added, a new system is colonized (or decolonized), a new trade route defined by the player, etc), so the calculation of the trade route network would only need to be done infrequently.  The trade routes could also be used in the F12 orders screen - in addition to listing populations to jump to at the top of the screen, you could list populated systems to jump to (possibly on a checkbox option similar to waypoints).
Interesting idea about creating a stored trade network. Would be a lot of work but might be worth it. One significant problem though is that a lot of the multi-system jump checks (especially for NPRs) are not just for civilian traffic. At the moment checks are made for geological and gravitational survey opportunities, friendly pops generally, pops with 25m+, suitable colonies for unloading (that do not already have inbound fleets), pops with fuel, specific ordnance, maint supplies or maint facilties, fleets with tankers or supply ships, unexplored jump points, JPs with no gate, mining populations, ship contacts, population contacts, fleets with specific ship types (such as escorts looking for capital ships), points of interest for NPRs, import requirements for trade goods, goods available for export, ruins, specific installations required (in v4.8), specific installations supplied (v4.8), etc.. Any overall changes I make will affect all of the above. Although one option would be to prevent longer searches for certain search types, the temptation would be to use the code (especially for NPRs) if it was available. I couldn't build all of these into a node system as they change too often and I am reluctant to create different code for different types of searches. At the moment the specifics of what you are looking for are separated from the generic code that handles the searching, which means it is very easy to add new searches. You have given me some things to think about though.

Steve
Title: Re: Civilian Contracts
Post by: alanwebber on January 11, 2010, 07:59:36 AM
Quote from: "Steve Walmsley"
Quote from: "alanwebber"
Steve

I have a problem with shipping lines. I have a colony next to Sol which is now over 30 million colonists. I set the colony to be a supplier of colonists and have another small colony within 2 jumps of Sol. All jumps have gates in place. However all the shipping lines stopped shipping colonists and are only moving freight to the one next door. I was also wondering about setting up transit lines which used to be available until you put the automatic system in place.
Has there been any combat in the affected system or en route? Civilians will avoid systems with recent combat for quite a while.

Steve

No combat on route. Once I reset the 30 million + world as a destination for colonists, the shipping lines started moving colonists into there again but nowhere else.

Alan
Title: Re: Civilian Contracts
Post by: sloanjh on January 11, 2010, 10:00:45 AM
Quote from: "Steve Walmsley"
Interesting idea about creating a stored trade network. Would be a lot of work but might be worth it. One significant problem though is that a lot of the multi-system jump checks (especially for NPRs) are not just for civilian traffic. At the moment checks are made for geological and gravitational survey opportunities, friendly pops generally, pops with 25m+, suitable colonies for unloading (that do not already have inbound fleets), pops with fuel, specific ordnance, maint supplies or maint facilties, fleets with tankers or supply ships, unexplored jump points, JPs with no gate, mining populations, ship contacts, population contacts, fleets with specific ship types (such as escorts looking for capital ships), points of interest for NPRs, import requirements for trade goods, goods available for export, ruins, specific installations required (in v4.8), etc.. Any overall changes I make will affect all of the above. Although one option would be to prevent longer searches for certain search types, the temptation would be to use the code (especially for NPRs) if it was available. I couldn't build all of these into a node system as they change too often and I am reluctant to create different code for different types of searches. At the moment the specifics of what you are looking for are separated from the generic code that handles the searching, which means it is very easy to add new searches. You have given me some things to think about though.

Steve

Quick implementation idea for the issue you pose:  I assume you would save trade route links in the DB, e.g. with "start system" and "end system" fields.  You could add additional (boolean) attribute fields for each of the various types of criteria you're using, so the "find a path given a set of links" code could be generic, but the criterion passed to "find the links associated with this criterion" would vary.

John
Title: Re: Civilian Contracts
Post by: waresky on January 11, 2010, 01:55:02 PM
Poor Steve...:D

Am fear can't enjoy himself in a simple play-session.Everytime r caught at upgrade work:D..
Title: Re: Civilian Contracts
Post by: mrwigggles on January 16, 2010, 07:50:19 PM
When you set up a supply does the supply have to be constructed by player or would the civvies be handling everything?

I actually still haven't played, in the middle of getting an emulator working to play it since the game is not suppose to have a dire cpu requirement.
Title: Re: Civilian Contracts
Post by: Erik L on January 16, 2010, 08:06:23 PM
Quote from: "mrwigggles"
When you set up a supply does the supply have to be constructed by player or would the civvies be handling everything?

I actually still haven't played, in the middle of getting an emulator working to play it since the game is not suppose to have a dire cpu requirement.

To my knowledge, the Civs will construct everything they ship. Of course, this may not be what you WANT there. ;)
Title: Re: Civilian Contracts
Post by: Hegemon2 on January 17, 2010, 01:15:09 PM
Tried the Contracts:

I set up Supply (Earth) and Demand (Mars) for 3 Terraforming Installations. My only civilian shipping line has 3 small freighters (5k cargo) which would each transport 0.04 TIs a trip. So it should take them 75 trips.

Guess what, they only did one trip with three ships and the contract disappeared.

Love the feature, but the implementation needs work.
Title: Re: Civilian Contracts
Post by: mrwigggles on January 17, 2010, 01:58:22 PM
Do the civvies only look for supply matching demands within four jumps?
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 18, 2010, 01:27:58 PM
Quote from: "Hegemon2"
Tried the Contracts:

I set up Supply (Earth) and Demand (Mars) for 3 Terraforming Installations. My only civilian shipping line has 3 small freighters (5k cargo) which would each transport 0.04 TIs a trip. So it should take them 75 trips.

Guess what, they only did one trip with three ships and the contract disappeared.

Love the feature, but the implementation needs work.
Fixed for the next version.

Steve
Title: Re: Civilian Contracts
Post by: Steve Walmsley on January 18, 2010, 01:28:55 PM
Quote from: "mrwigggles"
Do the civvies only look for supply matching demands within four jumps?
Yes, but you can set up a chain of contracts to move items more than four jumps

Steve
Title: Re: Civilian Contracts
Post by: mrwigggles on January 20, 2010, 07:58:41 PM
I think I am having an issue with civvie shipping.

In the event log, it says

FT Alaska Humphrises 002 has failed to Load Installation at Earth. Please reschedule the orders this fleet.


I have a supply order on Earth for 150 infrastructure and a demand order on mars for 150 infrastructure. Their both down to 138, so something has been happening. Is this due to the fact that the supply is higher then what the civvie fleet can carry in one go?

Their both using my 25k freighter.



---
EDIT: They've been sitting their for about a month now. 8/ I wish they would deliver the mass driver to venus and rhea.
Title: Re: Civilian Contracts
Post by: sloanjh on January 20, 2010, 08:13:48 PM
Quote from: "mrwigggles"
I think I am having an issue with civvie shipping.

In the event log, it says

FT Alaska Humphrises 002 has failed to Load Installation at Earth. Please reschedule the orders this fleet.


I have a supply order on Earth for 150 infrastructure and a demand order on mars for 150 infrastructure. Their both down to 138, so something has been happening. Is this due to the fact that the supply is higher then what the civvie fleet can carry in one go?

Their both using my 25k freighter.

Ah, all the questions this brings up.... :-) ).
2)  Do the same as 1, except with 150 infrastructure.  This might or might not satisfy the "Load 150" (again, I suspect it won't).
3)  Instead of waiting for builds in 1 and 2, you can simply go to the SM mods screen (Open F2 in SM mode and hit the SM mods button at the bottom) and give Earth the appropriate infrastructure.
4)  Try selecting the civie freighter in question, and hitting the "cancel orders" button.  This will kill the Load 150 order, but will leave the freighter sitting there with 138 infrastructure that it has no orders for.  If you're lucky, it will notice that Mars needs infrastructure (not a contract -through the normal trade mechanism) and sell the infrastructure at Mars.  If you're unlucky, then the 138 infrastructure will just sit there in the hold, causing problems, with no way to get rid of it without Steve's help.

Don't forget to delete the infrastructure contracts so other ships don't get sucked into the same trap :-)

John
Title: Re: Civilian Contracts
Post by: mrwigggles on January 20, 2010, 09:36:07 PM
Quote from: "sloanjh"
Quote from: "mrwigggles"
I think I am having an issue with civvie shipping.

In the event log, it says

FT Alaska Humphrises 002 has failed to Load Installation at Earth. Please reschedule the orders this fleet.


I have a supply order on Earth for 150 infrastructure and a demand order on mars for 150 infrastructure. Their both down to 138, so something has been happening. Is this due to the fact that the supply is higher then what the civvie fleet can carry in one go?

Their both using my 25k freighter.

Ah, all the questions this brings up.... :-) ).
2)  Do the same as 1, except with 150 infrastructure.  This might or might not satisfy the "Load 150" (again, I suspect it won't).
3)  Instead of waiting for builds in 1 and 2, you can simply go to the SM mods screen (Open F2 in SM mode and hit the SM mods button at the bottom) and give Earth the appropriate infrastructure.
4)  Try selecting the civie freighter in question, and hitting the "cancel orders" button.  This will kill the Load 150 order, but will leave the freighter sitting there with 138 infrastructure that it has no orders for.  If you're lucky, it will notice that Mars needs infrastructure (not a contract -through the normal trade mechanism) and sell the infrastructure at Mars.  If you're unlucky, then the 138 infrastructure will just sit there in the hold, causing problems, with no way to get rid of it without Steve's help.

Don't forget to delete the infrastructure contracts so other ships don't get sucked into the same trap :-)

John

I asked earlier if I needed to construct the widgets myself or if the civvies build and ship it, and the answer I believe I got was, that the civvies take care of everything.

Yes, the built infrastructure on earth is at a zero, Mars is capable of supporting 11m colonist  with a population of 3 million and rising.

I made the supply and demand from the civvie screen.

So I have to construct the widgets for the civvie to move? Boo.

So whats this safety margin for infrastructure for planets?
Title: Re: Civilian Contracts
Post by: sloanjh on January 20, 2010, 10:30:06 PM
Quote from: "mrwigggles"
I asked earlier if I needed to construct the widgets myself or if the civvies build and ship it, and the answer I believe I got was, that the civvies take care of everything.
They do - that's why I said "DO NOTHING" above. 8) is the ability to advertise contracts to get the civies to move this player-owned stuff.

The tricky part is that infrastructure is special - it can either be a trade good or player-owned.  If you make it in a factory, then it's player-owned from the start and civie lines won't pick it up as a trade good.  The infrastructure in the "available for export" field, however, is a trade good that's created magically by the civie sector, and will be picked up as such.  Once it's dropped on a planet, then it becomes player-owned, and civies won't treat it as a trade good any more.  By putting out a contract to pick up 150 infrastructure at Earth, you were actually saying "pick up 150 player-owned infrastructure at Earth".  But since you hadn't built any, you didn't have it to pick up.

From what you've said, I'd just SM in 150 infrastructure on Earth - that will probably make the cargo ship happy and it'll go on its way.

Quote
So whats this safety margin for infrastructure for planets?
If Mars has a population of 2,000,000, and has a colonization cost of such that it requires 1000 infrastructure to support that 2,000,000 pop (this is almost certainly not the right number - I made it up), then the civilian economy (the wealth/trade) tab will still show a shortfall in infrastructure until there's enough to support slightly more (e.g. 10%) than the current population.  So assuming fixed population, Mars would still show up as a sink of infrastructure on the trade tab until e.g. the infrastructure was at 1100.  I just made up the word safety margin - it's not something you need to worry about in terms of game mechanics.

John

PS - Since the contract stuff is so new, there are likely to be bugs.  You've hit one of them: "The civie sector should be able to handle the situation where there aren't enough goods present to fill up a 'supply' contract".  I'd say you should post this on the bugs thread.