Improved smooth_economy patch

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

CheeseWeaver
Engineer
Engineer
Posts: 14
Joined: 26 Jul 2005 13:16

Post by CheeseWeaver »

SirkoZ wrote: BTW - I'll update/correct the 1.4 in the readme. :).
yay, i've contributed to improve OpenTTD, or at least a patch to improve OpenTTD :D

but i managed to write 1.5 when i meant to write 1.4 about when you meant to write 1.5 when you wrote 1.4. its not easy to get those version numbers right :/
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

:D

Well - I mistakingly left 1.4 in the readme - I have updated it so hastily the first time, I left half of the changes out. :lol:
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Updated to the source r2866 (SourceForge too)....still v1.5 - works nicely. :)
Attachments
smooth_economy_sz_v1-5_r2866.patch
(2.3 KiB) Downloaded 360 times
sz_ind_patch_comments_v1-5.txt
(2.12 KiB) Downloaded 366 times
smooth_economy_sz_v1-5_r2354-0401.patch
Diff for OpenTTD 0.4.0.1 (r2354)
(2.29 KiB) Downloaded 349 times
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Another update/tweak - now more natural/logarithmic behaviour (bigger increase, if smaller production and bigger decrease, if bigger production), also more random. :)
Attachments
smooth_economy_sz_v1-7_r2354-0401.patch
the same patch for the 0.4.0.1 (r2354) version of OpenTTD
(2.26 KiB) Downloaded 427 times
smooth_economy_sz_v1-7_r3091.patch
r3091 and up patch
(2.4 KiB) Downloaded 397 times
sz_ind_patch_comments_v1-7.txt
Comments to v1.7 of Industry patch
(2.92 KiB) Downloaded 473 times
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

New version! :)
2.0 now with a "switch" to control the behaviour of industries - either more smooth (up to "10") and no or few changes per month or more ("1" = v1.7 patch behaviour) responsive with more changes per month.
For OTTD 0.4.0.1 the patch 1.7 with no switch is available...


P.S.: The text beside the switch in the "Patches" panel is english for all languages - to make it more compatible for the integrated nightly build. You can easily translate it in your native language...
Attachments
smooth_economy_sz_v2-0_r3328.patch
diff
(25.84 KiB) Downloaded 392 times
sz_ind_patch_comments_v2-0.txt
extended comments
(4.81 KiB) Downloaded 372 times
screenie :)
screenie :)
smooth_economy_sz_v2-0_r3256.gif (4.3 KiB) Viewed 8388 times
Last edited by SirkoZ on 21 Dec 2005 16:58, edited 1 time in total.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Code: Select all

if (i->type == IT_OIL_RIG && j == 1) {
	new = clamp(new, 0, 14);
}
else {
	new = clamp(new, 0, 255); 
}
Are you aware "else" means

Code: Select all

if (i->type != IT_OIL_RIG || j != 1)
?
So "new" will be clamped for all industries besieds OIL RIG...
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Well - I have double checked and with a random temperate livestock game too - it works nicely, without any problems.

And behind that "else", you just had to have meant:

Code: Select all

type != OIL_RIG && j != 1


Which never holds water/is true, so other industries are working/increasing happily. Where's your logic? Why would an "else" turn an "&&" into an "||"? :o :?

To really confirm it - a screenie:
Attachments
Farms
Farms
Bogota Transport, 10th Jul 2051.png (62.89 KiB) Viewed 8316 times
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

I hope now, MeusH, you will actually take time and test the patch, because just scanning through code, you can make a mistake.

Thank you for your interest anyway. ;)
User avatar
Graphite
Engineer
Engineer
Posts: 84
Joined: 17 Nov 2005 20:56
Location: Netherlands
Contact:

Post by Graphite »

SirkoZ wrote:Where's your logic? Why would an "else" turn an "&&" into an "||"? :o :?
Actually his logic is covered by De Morgan's rule: NOT (P AND Q) = (NOT P) OR (NOT Q).
A computer scientist is someone who, when told to "Go to Hell," sees the "go to," rather than the destination, as harmful.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

In any case - it works as it should - code mincers. :P
User avatar
Graphite
Engineer
Engineer
Posts: 84
Joined: 17 Nov 2005 20:56
Location: Netherlands
Contact:

Post by Graphite »

Code mincing is not necessarily a bad thing, you know. When a student writes a thesis, he is supposed to defend it as well. Along the same lines, a coder who write a piece of code for OpenTTD should be able to defend it too :wink:

You say it works as it should, but, knowing what you know about the if-statement now, can you explain why it works as it should? That's the question that interests me now.
A computer scientist is someone who, when told to "Go to Hell," sees the "go to," rather than the destination, as harmful.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Well - you got a good point there, however - I'd rather play with the patch or see some gameplay opinions, than do much more code explaining. :)

Anyhow - I'd say the game first checks for the i->type==OIL_RIG and only then j==1 (the easiest way - you can't go wrong with the LeChatelier principle :D). So it works nicely.

And as I'm more of an avid fan than a coder, I thank you for your interest, Graphite. ;)
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

SirkoZ, as Graphite said, it was DeMorgans rule: !(p && q) == !p || !q, which Graphite wrote in much user-friendly language.

Anyway, I'd like to know what does j == 1 do - is it to give out more passengers to oil rigs than steel mills?
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

No no - I just fixed maximum number of passengers per oil rig per month at 112/126 (=8x or 9x 14), therefore I used j==1 - because j in this case is cargo type per industry - 0=primary cargo, 1=secondary cargo,...so at oil rig j=1 are passengers and j=0 is oil. At the farm j=0 is grain, j=1 is livestock.
So - only cargo 1 (second) at oil rig is clamped at max. 14 (x8/x9 = 112/126), all other cargos (j=0, 1, or more) with all other industries are capped at 255, which is the maximum production_rate (x8/x9 = 2040/2195 units per month) because every industry gives out cargo/production_rate 8 or 9 times per month. I hope this all is clear enough. :)


P.S.: Oh and BTW - if steel mills were set to "produce" passengers, j==1 would in that case be passengers = secondary cargo (steel = 0 (primary)).
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Update to r4321 source and some minor GUI-switches changes

Post by SirkoZ »

New update! :)

Here it is for latest source/trunk, r4321.
Attachments
smooth_economy_sz_v2-0b_r4321.patch
diff
(27.5 KiB) Downloaded 376 times
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

....updated and with new features - banks in temperate and tropic terrain now have production - temperate (valuables) bank maximum 432 bags valuables per month and tropic (diamond) bank maximum 54 bags of diamonds.

gkirilov has suggested this and firstly I though I could make the feature switchable, but I'd have to rewrite the whole IndustryType/_industry_close_mode array and I just didn't have any good ideas, being more of a fan, than a programmer. =)

So - max for temperate bank 432 because those are valuables and as such prone to inflation and tropic is clamped at 54 as bank doesn't have a mine-shaft somewhere in the back-room. :D
Although - imagine a bank-mine with the BIG elevator from Coal Mine. :lol:

Of course increases are gradual, accompanied by decreases.

One other thing to notice, especially for MeusH or Graphite is the "clamp" section of industry_cmd.c - I believe there's not fear of being in possible conflict with deMorgan's rule anymore. Please, check. :)

Thanks

SirkoZ

P.S.: Detailed readme_sz_smooth_ec_2-1 comes soon... :)
P.S. #2: Translation-correctness update: I have removed all the english from non-english language files as per peter1138's request. No behaviour and none visible changes in-game though.
Attachments
smooth_economy_sz_v2-1_r4321_eng.patch
diff
(5.7 KiB) Downloaded 322 times
Last edited by SirkoZ on 10 Apr 2006 14:16, edited 1 time in total.
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Post by Michi_cc »

You should post that on http://bugs.openttd.org/ so it has at least a chance to get into trunk. My advice would be to remove all non-english strings before, makes the patch much smaller and nicer and therefore inclusion more likely.

-- Michael Lutz
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Michi_cc wrote:You should post that on http://bugs.openttd.org/ so it has at least a chance to get into trunk. My advice would be to remove all non-english strings before, makes the patch much smaller and nicer and therefore inclusion more likely.

-- Michael Lutz
It's posted on SourceForce - under Bugs and under Patches - what now - does noone look there anymore - SourceForge was supposed to be the default OpenTTD bug/patch etc. tracker? :?:

Also - if you'd looked at it - you would have seen there are no non-english strings therein (in none of my patches for that matter), in fact even the strings for "configure patches" switch are english for all languages, because IMO the switch should exist with all available languages and the translations' authors can translate that.

All the developers should announce the transfer of trackers etc. to openttd.org if it has any steam, to put in transportingly. Please explain. :!:
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Post by peter1138 »

Do NOT put English into the non-English files. They should only contain translated text.
He's like, some kind of OpenTTD developer.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

peter1138 wrote:Do NOT put English into the non-English files. They should only contain translated text.
:arrow: I don't care - my objective is for the patch to work - I'm not gonna hunt around the translators for all the 21 other languages.

:idea: If and when my patches are about to be added to the trunk, then and only then we'll talk about what I add into language files.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 25 guests