Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Sep 22, 2018 11:48 pm

All times are UTC




Post new topic  Reply to topic  [ 58 posts ]  Go to page 1 2 3 Next
Author Message
PostPosted: Wed Aug 15, 2007 9:26 am 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
Well its been a while since I've done anything with the OpenTTD Code. I still have my subsidy distance patch to work on, but I thought I would create this quick patch first. For those that don't know I like to play with Very Low towns because it makes the towns more spread out. The trouble is that this is not always the case, I often get random maps that have open areas with no towns, and other spots with 3, 4, or sometimes 5 towns all close together. In order to get the towns spread out more evenly on the Low and Very Low town settings I have created this patch.

Revision 2 of this patch makes things configurable, and allows the original behavior of the game if desired. Also I have added the ability to set a minimum distance between industries. Previously, industries had to be a minimum distance from related industries, setting this value sets a distance requirement between all industries.

Revision 3 of this patch disables the distance check on industries that need to be built in a town like Water Towers and Banks.


Attachments:
File comment: A patch to configure the minimum distance between towns and between industries.
Minimum_Town_Distance_r3.patch [4.96 KiB]
Downloaded 581 times


Last edited by wleader on Fri Aug 17, 2007 1:07 pm, edited 2 times in total.
Top
   
PostPosted: Wed Aug 15, 2007 12:22 pm 
Offline
Engineer
Engineer

Joined: Tue Aug 07, 2007 9:10 pm
Posts: 24
Great, I would love to see this in ChrisIN or even trunk. I've found on very large maps even with towns on Very Low theres still way too many around, will this also reduce the number of towns on very large maps as a side effect of the distance limit?

_________________
Image
Currently running: Bigos Patch Pack (forum link) with custom GRF pack.
win32 binary: bigos_pack_1.2.rar | patch file: 12.patch | GRF's: finessegrfv3.rar


Top
   
PostPosted: Wed Aug 15, 2007 2:36 pm 
Offline
Route Supervisor
Route Supervisor

Joined: Thu Oct 07, 2004 10:05 am
Posts: 415
I also like this :) although cluttered city areas are realistic, it is not so nice for gaming :) I'll give this patch a try!


Top
   
PostPosted: Wed Aug 15, 2007 2:57 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Tue Nov 09, 2004 10:33 pm
Posts: 357
Good job, I've been looking for something like this for a while.

_________________
NB: the below challenges are still open for submission, so feel free to perform necromancy on them!
Try the PouncingAnt National Monopoly Challenge
Or even better, the PouncingAnt National Monopoly Challenge 2
Or better still, the PouncingAnt National Monopoly Challenge 3
Or, the PouncingAnt National Monopoly Challenge 4

Or try my scenario instead!

-(A lazy) OpenTTD Japanese Translator-
-(A lazy) PNGcodec user-
"You get what you pay for, so pay attention!"

Patches:
Company Station Stats


Top
   
PostPosted: Wed Aug 15, 2007 3:57 pm 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
finesse wrote:
will this also reduce the number of towns on very large maps as a side effect of the distance limit?


If the limit was too high, then it might cause problems finding locations for new maps during generation. If that happened then the number of towns might be reduced. The numbers I selected should not be great enough for this to happen. The only effect this patch is supposed to have is to make the towns spread out on the map more evenly.


Top
   
PostPosted: Wed Aug 15, 2007 11:19 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 23, 2005 12:09 am
Posts: 3138
Can you put a slider to choose even higher numbers (>200)?
I am interested to see the effects of this patch on huge maps (4096).

_________________
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.


Top
   
PostPosted: Thu Aug 16, 2007 8:24 am 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
athanasios wrote:
Can you put a slider to choose even higher numbers (>200)?
I am interested to see the effects of this patch on huge maps (4096).


My choice was to either make the distance a configurable value on the patch configuration window, or use constants like I did. If it were configurable then it would apply to all town density settings, which I suppose is OK. Imagine setting it to 50, but with towns on High. On the other hand its not always a good thing to just add more stuff to the patches window. Its already pretty cluttered.

I guess the real problem is that if this patch is to be considered for including in the trunk, there must be away to disable it. So if it were configurable, then setting it to 20 (the default value) would effectively retain the original play. That being said I guess a configurable option is the way to go.

I'll see if I can find some time to make this change later today.


Top
   
PostPosted: Thu Aug 16, 2007 11:26 am 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
athanasios wrote:
Can you put a slider to choose even higher numbers (>200)?
I am interested to see the effects of this patch on huge maps (4096).


Revision 2 of the patch (at the top of the thread) allows you to configure the distance. It also allows you to set a minimum distance between industries.


Top
   
PostPosted: Thu Aug 16, 2007 4:49 pm 
Offline
Route Supervisor
Route Supervisor

Joined: Thu Oct 07, 2004 10:05 am
Posts: 415
Is the minimum distance between industries only valid for generating maps (which would the way I prefer it) or also when constructing industries during a game even with close industries enabled?


Top
   
PostPosted: Thu Aug 16, 2007 5:28 pm 
Offline
Engineer
Engineer
User avatar

Joined: Fri Feb 17, 2006 10:51 pm
Posts: 1
Location: Australia
Depending on how far you go with this, it could be nice to allow users to change the maximum number of towns within the limit as well. This way you still get those clusters, but only between 2 or 3 cities, rather than 7 or 8.

Either way, a great idea. Nice work :)


Top
   
PostPosted: Fri Aug 17, 2007 8:37 am 
Offline
Director
Director

Joined: Tue Feb 22, 2005 9:51 am
Posts: 586
Quote:
On the other hand its not always a good thing to just add more stuff to the patches window. Its already pretty cluttered.

Just because the patches window is pretty crowded isn't a reason to eliminate configuration options. The config file contains a huge number of settings that aren't available to change in game. Yes, its not quite as user friendly as the in game window, but hard coded (or simply excluded) settings aren't that user friendly either :)


Top
   
PostPosted: Fri Aug 17, 2007 9:11 am 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
chrissicom wrote:
Is the minimum distance between industries only valid for generating maps (which would the way I prefer it) or also when constructing industries during a game even with close industries enabled?


The code that checks distance from other industries is in PlaceInitialIndustry which as best I can tell is only called from GenerateIndustries. GenerateIndustries is called when a new map is generated or the Many Random Industries button is clicked in the Scenario Editor. A player can still fund a new industry anywhere they like, and random industries created by MaybeNewIndustry can spawn anywhere.

Krysole wrote:
it could be nice to allow users to change the maximum number of towns within the limit as well. This way you still get those clusters, but only between 2 or 3 cities, rather than 7 or 8.


I did some thinking about this, and my first thought was that I could count the number of nearby towns, and then check the count of nearby towns. But then I realized that this has the potential to create a string of towns. Imagine town A is placed first, then town B is placed East of Town A. Finally Town C is placed West of Town A. Placing town C is ok, because its near to A but not B. Instead of being a cluster of two as the user might have originally wanted, its now a cluster of three. So to do this right, there would need to be a bit of code more clever than I am up for to determine what towns are in what clusters, and how many towns are in the cluster. Sorry, I just to plan on adding anything like this to the patch.

sc79 wrote:
Just because the patches window is pretty crowded isn't a reason to eliminate configuration options.


Certainly. My thinking is that I might as well add the configuration option to make it easier to people testing the patch. If it does get included into ChrisIN or the Trunk, then I am sure someone will make an 'executive decision' about where the configuration stuff should go. I'm not really worried about it.


Top
   
PostPosted: Fri Aug 17, 2007 1:06 pm 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
I have found that with this patch applied, Water Towers never get created in the tropical climate (or are very likely to not be created) I think this is because the locations in towns are too near other industries, and it can't find suitable locations for them. This results in there being fewer Water Towers and Banks than originally intended. To correct this, I have disabled the distance check when the industry type is a water tower or bank.

Revision 3 of the patch is at the top of this thread.


Top
   
PostPosted: Fri Aug 17, 2007 1:26 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Tue Apr 05, 2005 1:48 am
Posts: 1507
Location: Deep down the deepest blue
You would be better off using something like :

Code:
         for (i = 0; i < 2000; i++) {
+            tile = RandomTile();
+
+            if (_patches.industry_minimum_distance > 0 &&
+                  !HASBIT(indspec->behaviour, INDUSTRYBEH_ONLY_INTOWN) &&
+                  IsCloseToIndustry(tile, _patches.industry_minimum_distance))
+               continue;
+
+            if (CreateNewIndustry(tile, type) != NULL) break;
         }
      } while (--num);


Uncompiled code, just proof of concept.
Personnally, i don't like the idea of what you've just added. I do not know the reason of the INDUSTRYBEH_ONLY_INTOWN industries behaving like you just mentionned, but i think it is something else to check then this. Doing what you did is a hack, and not the cure to the real problem.

And i think that the idea of this patch is wrong. Somebody (another dev) mentionned that the whole idea of the IsCloseToTown(tile, 20) is due to the fact that a town is 19x19 big and 19/2 + 19/2 ~= 20 and that you have to deliver goods within 9 tiles of the city center to be paid, which leads to conclude that the town is 19x19 (9 + 9 + the center tile) max upon creation. Therefore, it would be wrong to change these values, no matter how attractive it would look to have towns evenly dispersed on the map. Don't forget that it is done by random...

You did a much better job with your other patches, if i may say so. Although I do understand that this is the very first versions of this one ;)

_________________
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones


Top
   
PostPosted: Fri Aug 17, 2007 4:06 pm 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
belugas wrote:
You would be better off using something like : (code removed)
Uncompiled code, just proof of concept.
Personnally, i don't like the idea of what you've just added. I do not know the reason of the INDUSTRYBEH_ONLY_INTOWN industries behaving like you just mentionned, but i think it is something else to check then this. Doing what you did is a hack, and not the cure to the real problem.


To be honest this just shows my unfamiliarity with the code, and c++. INDUSTRYBEH_ONLY_INTOWN isn't even something I was aware of. I also don't think in terms of bitmasks. That being said I'm not against being shown new things, as OpenTTD is the only c++ code that I even look at on a semi-regular basis. I like getting feedback like this because I means someone is looking at my code, which is way more gratifying then posting something and getting no responses.

belugas wrote:
And i think that the idea of this patch is wrong. Somebody (another dev) mentionned that the whole idea of the IsCloseToTown(tile, 20) is due to the fact that a town is 19x19 big and 19/2 + 19/2 ~= 20 and that you have to deliver goods within 9 tiles of the city center to be paid, which leads to conclude that the town is 19x19 (9 + 9 + the center tile) max upon creation. Therefore, it would be wrong to change these values, no matter how attractive it would look to have towns evenly dispersed on the map. Don't forget that it is done by random...


I've been sitting here thinking about what you are saying for probably a half an hour, and I do not understand why it is wrong to increase the distance between town. Is there something I'm not seeing that it breaks. I could see things might get ugly if the value were reduced below 20. Clearly it is OK for towns to grow up against each other as they will do that in the natural progression of the game. Additionally they can also grow outside of initial boundaries of the local authority. Its not unfair in multi-player since everyone still plays on the same map.

Could you explain to my just why you think its wrong?

belugas wrote:
You did a much better job with your other patches, if i may say so. Although I do understand that this is the very first versions of this one ;)


Thanks, I feel like a lot of the time I am stumbling around in the dark, So I must have been lucky in the past. Like I mentioned above c++ is not the language I use everyday.


Top
   
PostPosted: Tue Mar 04, 2008 12:11 am 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
It looks like my hiatus is coming to an end now that the busy season at work is ending. So to get back into things I spent some time this afternoon making this patch work on a server. Anyone that wants to should be able to connect to it using 6.0 beta 4. Its an advertised server so just look for a server named 'Minimum Distance'. Enjoy.


Top
   
PostPosted: Fri Jul 04, 2008 5:19 pm 
Offline
Engineer
Engineer

Joined: Fri May 18, 2007 9:04 am
Posts: 123
And another update.

Update Aug 3: Wow, no one noticed that the code to enforce town distance wasn't working at all?


Attachments:
File comment: Updated to 13979, and fixed town distance bug.
Minumum Distance Patch r13979.patch [6.19 KiB]
Downloaded 239 times
Top
   
PostPosted: Mon Sep 22, 2008 12:13 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Mon Mar 08, 2004 8:20 pm
Posts: 137
Location: Czech republic
I finally found this. Since I am not into coding/compiling/playing with code at all, I got no idea how to apply this to my current OpenTTD installation. Could you provide an .exe like I saw elsewhere a few times, please?


Top
   
PostPosted: Mon Sep 22, 2008 2:25 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Oct 01, 2004 3:28 pm
Posts: 313
If you're using windows, have a look at the Build-OTTD-sticky, it's really easy to use!


Top
   
PostPosted: Mon Sep 22, 2008 7:59 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Mon Mar 08, 2004 8:20 pm
Posts: 137
Location: Czech republic
Ok I believe I managed to get it to work using Tortoise. Last question though: I got the latest nightly source downloaded, I think it's 14384. When I did the "patch all" it started to give me messages about catching something and r13979. am I to understand these patches are all made for one specific version, or can I use them with newer builds as well?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 58 posts ]  Go to page 1 2 3 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.