Patch: Industry budgets

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Patch: Industry budgets

Post by antichaos »

I floated this idea in the economy and balancing thread a few weeks ago, and then decided I might as well have a go myself.

This patch gives each secondary industry (those that accept cargo) an annual budget for purchasing that cargo. Each industry has an operating balance which is credited each month up to the annual maximum and from which is deducted the cost of the raw material brought to that industry. If the balance is negative when a delivery arrives, the cargo will be thrown away and no money paid.

You can increase the budget for an industry by transporting the goods it produces as the profit from the transport is also passed back to the originating industry. Each industry tracks its average income (monthly, over a year) and adjusts its budget accordingly. For industries which accept but don't produce (like power stations) their income is directly related to the population of the town they are attached to. Note that income doesn't go directly to the balance - it adjusts the budget which pays into the balance monthly. Let me know if you think it would work better differently.

The point of all this is to shift the goal from 'how can I make the most money?' to 'how can I create a network that makes economic sense?'. For example, it requires you to set up a delivery route for produced cargo if you want to bring in raw materials from a second source, or from far away. It means that some industries may not be profitable to service. I realise that some, if not most people may not be interested in this, but if you fancy a slightly different challenge in openttd, then give the patch a try.

New version! 0.5.5 released 04/05/07
0.5.4 released 20/04/07
0.5.3 released 18/04/07
0.5.2 released 15/04/07
0.5.1 released 13/04/07
0.5 released 09/04/07
0.4.1 released 07/04/07
0.3.2 released 30/03/07
0.3 released 28/03/07
0.2 released 23/03/07

Changes in 0.5.5
- Resolved conflicts due to trunk changes in load/unload and savegame code.

Changes in 0.5.4
- Fixed a bug that prevented industries receiving the correct amount of income.

Changes in 0.5.3
- Rewrote the delivery sharing (4 times) so it performs better and also shares income between producing industries.
- Added: Workers are now given back to the station once they have been used.
- Changed: You will not get any income for passengers delivered to industries. You only get income when you deliver the passengers to a station that has enough houses around it to accept passengers, regardless of whether or not there is an industry nearby. This is to make sure that people transport passengers town<->industry and not industry<->industry. Financially this is no change, as workforce routes still only pay one way, but now you only get paid for the workers that are actually used. However, the receiving industry still pays the delivery cost for every passenger to bring it.
- Fixed a bug in the sharing code that mean an industry would get extra cargo if the total to be delivered was not an exact multiple of the number of industries to share between. (eg 35 passengers between 2 industries was giving 35/17, now gives 18/17)
- Reduced the base budget for primary industries.

Changes in 0.5.2
- Actually included the fix that was meant to be in 0.5.1. Sorry
- Resolved merge problem from recent savegame bump

Changes in 0.5.1
- Fixed a bug that caused income to be calculated incorrectly for trains.

Changes in 0.5
- New patch option under economy to toggle sharing of incoming goods / passengers among the industries within the station's catchment area. If one or more of the stations rejects its share, the program will try to give it to the other stations, until there is no more cargo, or all industries are rejecting. The old behavior is still available if you prefer it. I'd be interested in feedback as to whether there is any performance difference, especially with many large stations.
- New patch option under interface to toggle the display of the accept / reject messages that appear over industries.
- Improved checking of passenger acceptance at stations near industries and towns. This removes the need to manipulate the tile acceptance, so no more 'change of acceptance' popups. Now, if an industry rejects passengers, they will be thrown away, unless there are enough houses around, in which case you will be given the income, but not the workforce.

Changes in 0.4.1
- Fixed a rather major bug with the cargo acceptance and rejection message display. Never trust a x.0 release :(

Changes in 0.4.0
- Changing workforce of budget multiplier settings mid-game now behaves properly.
- Fixed average monthly income not being saved properly. This will break earlier savegames.
- Workforce now affects budget. Budgets extended to primary industries.
- Added floating text to inform you if cargo has been rejected.
- Initialize budget data correctly for old save games and scenarios.
- Updated readme

Changes in 0.3.2
- Raised the min value window to 5% from 2%
- Fixed a problem with the calculation and display of protected balance
- Show Average value per 100 units for each player, rather than cost and income separately.
- Fixed max production and workforce bugs related to lumbermill production by tree chopping.
- Added a readme with more detailed info about the patch features.

Changes in 0.3
- Stats of each players contribution to each industry, in glorious black-and-red-o-vision.
- The player who has the largest (average income per unit - average cost per unit) is the cheapest. That value minus 2% is the Min Value per 100 units shown at the top of the Finance window.
- The protected balance is equal to 4 times the cheapest player's average monthly cost + income. (Totals, not per unit). Other players can't deliver to the industry if the balance is less than the protected balance, unless their per unit value is greater than the Minimum, ie within 2% of the cheapest.
- A player can only claim best value, and get a protected balance if they are actually delivering cargo to the industry, not just carrying goods away.
- If a player has no interaction with an industry for more than 3 months, their per unit value is reduced by 5% per month.
- If a player has no interaction with an industry for more than 12 months, they are removed from the tracking.

New patch option in economy: Industry Workforce . Note that this defaults to OFF.
- This makes any industry that produces cargo able to accept passengers. , though this isn't shown in the industry view yet
- Delivered passengers go into the workforce and are used to produce cargo. No workers, no cargo.
- Production is displayed as Actual / Max possible.
- If at the end of a month the workforce is more than twice the max production, some of the workers will disappear.
- Don't try and use this with the AI, it can't understand it at all.
- Passengers don't affect budgets. The two patches work independently.

Changes in 0.2
- Initial budges are now set using the actual cost for delivering (budget multiplier -default 100) units per month of each cargo the industry accepts, 30 tiles, in a time that is scaled from 50 days to 2 days according to the start date. The time scaling actually makes relatively little difference
- Budgets are now increased with inflation.
- Finances button on the industry view opens a new window with more detailed finance info.

Issues remaining:
- I haven't yet added budgets to towns. Trickier than expected - not going to happen soon.

As I said I'm not pushing for this to go into trunk, so if you don't like what this does, you don't have to touch it. Other than that, comments and suggestions welcome.
Attachments
industry_budgets_0.5.5_9775.diff
Industry budgets and workforce v0.5.5 patch. Built against r9775
(102.08 KiB) Downloaded 544 times
r9789 + industry_budgets 0.5.5.zip
Industry budgets and workforce v0.5.5 Win32 binary. Updated to r9789 to fix the unload bug.
(764.46 KiB) Downloaded 557 times
Last edited by antichaos on 05 May 2007 11:07, edited 19 times in total.
User avatar
flake
Engineer
Engineer
Posts: 66
Joined: 28 Apr 2004 10:07
Location: Salzburg
Contact:

Post by flake »

You can increase the budget for an industry by transporting the goods it produces as the profit from the transport is also passed back to the originating industry.
Does that mean you do not make (or as much) money from transporting the goods ?
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

Now I get more confused. :?
Pikkas industries accept limited cargo, this one throws cargo away.

The big question is:

Will industries play in the game or remain as they currently are?

I suggest they do. You get money from transportation OR you own an industry and generate products and sell them and get profit from sales - (transport fee + raw mat. purchase + running costs).

This implies that game starts with ability to build smaller industries (due to loan limit) that can expand later in time.

Do you agree?
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

antichaos, I like your idea, but I think this may be vunerable to multiplayer abuse: Imagine the other player transporting lots of cargo to an industry just to make you get zero money. This should be fixed
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

flake wrote:
You can increase the budget for an industry by transporting the goods it produces as the profit from the transport is also passed back to the originating industry.
Does that mean you do not make (or as much) money from transporting the goods ?
No, you get the full amount yourself too. If the route is subsidised then you and the originating industry get the subsidised profit, but the receiving industry pays the unsubsidised cost, making these routes even more worthwhile.
MeusH wrote:antichaos, I like your idea, but I think this may be vunerable to multiplayer abuse: Imagine the other player transporting lots of cargo to an industry just to make you get zero money. This should be fixed
Part of my purpose in this patch is to increase competition around industries. If someone undercuts you by bringing raw materials in more cheaply, then that's fair game in my opinion. However what I think should be penalised is a big company setting up a high cost route which takes all the budget from a cheaper route. This means giving industries the realistic behaviour of rejecting the higher cost-per-unit cargo if money is tight. Similarly I'd like to tie income to the station ratings so that more cargo is given to higher profit routes.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Well of course that would increase competition, which I like very much (but some do not).
antichaos wrote:However what I think should be penalised is a big company setting up a high cost route which takes all the budget from a cheaper route.
That's exactly what I meant. You said it with better words :)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Interesting patch - adds quite a bit more complexity to the game.
Pity we don't have an Integrated build anymore (for now at least), so all kinds of interesting patches could be joined in one challenging build...
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

Patch updated. See first post.
giddorah
Engineer
Engineer
Posts: 22
Joined: 08 Jan 2007 22:01

Post by giddorah »

I really do hope you can keep this up! Just because there's not so many replies, this is a very good patch :)

It sure makes the game more interesting, especially during multiplayergames where you finally have competition.
User avatar
AlexW
Traffic Manager
Traffic Manager
Posts: 213
Joined: 20 Feb 2007 07:59
Location: Newbury, UK

Post by AlexW »

A fantastic (and fantastically complex) concept - keep up the good work. If I had any time on my hands, this would encourage me to learn how to apply patches to OTTD.

Well done.
Hooked on Transport Tycoon since 1994
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

Thank you for the encouragement. It means a lot. See the first post for an updated patch that now also contains the industry workforce option.

Please note I've made significant changes to the saveload procedures in this, so any savegames you may have made with previous versions of this patch are not going to work. Normal saves should be fine though.

Would anyone by interested in a Win32 binary? It will only have English versions of all the new strings.

Edit: I was a bit hasty in uploading the new patch last night. I've just updated it slightly to fix some problems with protected balances.
User avatar
Mambaru
Engineer
Engineer
Posts: 42
Joined: 29 Apr 2006 18:34
Location: Middlesex U.K

Post by Mambaru »

I'd be VERY interested in a win32 binary! Count me in. :)
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

First post updated with Win32 binary and updated patch. Below are some screen shots of the patch in action.
Attachments
Industry budgets1.png
Industry budgets1.png (15 KiB) Viewed 20281 times
Industry workforce1.png
Industry workforce1.png (70.47 KiB) Viewed 20263 times
User avatar
Mambaru
Engineer
Engineer
Posts: 42
Joined: 29 Apr 2006 18:34
Location: Middlesex U.K

Post by Mambaru »

I must say that so far it's fantasic. But.....
Maybe it's just me but I've run into only one error. And that is if you load up a senario then all of the industries have budgets! Also the financial page of the industry is corupted. I'll supply screen shots in a while.
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

Mambaru wrote:I must say that so far it's fantasic. But.....
Maybe it's just me but I've run into only one error. And that is if you load up a senario then all of the industries have budgets! Also the financial page of the industry is corupted. I'll supply screen shots in a while.
The corruption also seems to happen with old save games. It's probably because the finance data is not getting initialized properly. Should be fairly easy to fix. I also want to add the ability to edit an industry's budget in the scenario editor

Something I noticed in my test games is that the range for stations delivering cargo or passengers to industries is huge, up to 40 tiles. This means that for industries close to a town you don't need to set up a dedicated station right next to it to deliver passengers - just put a station in the middle of town as normal.

However, at the moment each station only delivers to its closest industry. I could add some code to make the station share incoming passengers between all the stations in range, but this might not be what you want in all situations. Another option would be to provide a way to link a station with an industry.

The one thing I haven't tested at all is multiplayer - so I have no idea if these changes will cause horrible desyncs.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Post by burty »

i really love this although surely the workforce would have to be payed for out of the budget.
Also it is really easy to make a profitable route(s) with a few close together industries as well as the fact that the extra passenger routes for the workforces brings in a lot more as well!
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

burty wrote:i really love this although surely the workforce would have to be payed for out of the budget.
Also it is really easy to make a profitable route(s) with a few close together industries as well as the fact that the extra passenger routes for the workforces brings in a lot more as well!
I'm working on a new version in which workforce affects the budget, but it's proving tricky to make sure things behave for all the possible patch settings (budgets only, workforce only and both), especially if you change settings mid game. I want to finish that and add a few other bits and bobs and aim for a 0.4 over the weekend.
xyz
Engineer
Engineer
Posts: 46
Joined: 19 Feb 2005 07:37

Post by xyz »

This is the missing link in the ttd evolution.
Finaly roads vehicles have a meaning in this game. good job.

bug:

why only one industry will take the workforce broth to a station connectet to 2 ore more industries? is this a bug, or is just not implemented yet?

thx.
Interesting Projects:
Celestia an open source space simulator.
EventGhost an open source PC remote control.
TA Spring
OpenTTD
User avatar
Villem
Tycoon
Tycoon
Posts: 3310
Joined: 28 Aug 2003 09:38

Post by Villem »

Afaik, its the way that cargo acceptance in TTD is. The closest industry gets all cargo. I.e if you have 2 power plants in vicinity of a station, the closest gets all coal.
User avatar
antichaos
Engineer
Engineer
Posts: 42
Joined: 13 Feb 2007 21:51
Location: UK

Post by antichaos »

Akalamanaia wrote:Afaik, its the way that cargo acceptance in TTD is. The closest industry gets all cargo. I.e if you have 2 power plants in vicinity of a station, the closest gets all coal.
This is correct. A the moment the function for picking an industry to deliver to is pretty dumb (loop though all industries and find the closest). However, there is the following comment in the code for the function:

Code: Select all

/* Check if there's an industry close to the station that accepts the cargo
	 * XXX - Think of something better to
	 *       1) Only deliver to industries which are withing the catchment radius
	 *       2) Distribute between industries if more then one is present */
The obvious solution would be to store the list of nearby industries in a list attached to the station. However it's not clear to me where and how often this list should be updated, especially when you consider that industries can be started or closed at any time. There is a function which scans the catchment area to get the station acceptance, so it should be possible to get the industry list at the same time, rather than setting up the same loop twice.

Once we have the list, there is the question of how the cargo should be distributed. Should it be split equally, or on the basis of distance, or budget, or user selection?

On another topic, I'm working on a feature so that when cargo is rejected by an industry, you will get some red text telling you so instead of the income text. In doing so I've realized that for trains the function to deliver cargo to an industry (where the budget stuff is checked) is called separately for each carriage. This means that if an industry is low on budget, it can accept the first few carriages of cargo and reject the rest. I think I like that behaviour, but in any event we are stuck with it. Once the crazy bug with the cargo display in the rejection message is fixed, you'll be able to see exactly how much is rejected.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 7 guests