Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Dec 15, 2018 1:21 am

All times are UTC




Post new topic  Reply to topic  [ 22 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Mon Dec 21, 2015 9:07 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
Please find following my scenario builder GS, I have used for my UK scenario. Feel free to modify it for your own purposes. I'd recommend building the lists in your favourite spreadsheet program (attached is my very messy excel file I used to build my lists), also note your heightmap will have to be build using a Cartesian Northing, Easting coordinate system or you will have to make a far more complex convertor to OTTD grids.

My scenario used data and a heightmap in OSGB which are effectively X and Y coordinates which only need to be scaled and offset to become grid coordinates. Easiest way to do this is sample two costal points in both the scenario editor and your mapping software. I used free open source QGIS (http://qgis.org/en/site/) for my mapping software and OS open data (https://www.ordnancesurvey.co.uk/busine ... ducts.html the same data which was used to build the UK minecraft map)

The GS is currently able to:

  • Place towns with set location, size and city status, accounting for barriers, hills, and coast
  • industry with one of three methods: at Determined located (with nearest valid search), within determined area (rectangles), or random (prospecting)
  • rectangles of trees
  • signs

I used the following process:
1. Load heightmap in scenario editor
2. add temporary town away from anything which will be added so that the scenario will be "playable"
3. set the GS in the AI settings
4. save it and play the scenario
5. watch while the GS places towns, industry, signs and trees (note trees will take a while on big maps, ~10mins to place 10,000 rectangles for my UK map)
6. save the game, go to your saves folder, move the *.sav file to scenarios and rename it to *.scn
7. load it back into the editor, delete the temporary town, and make other manual adjustments
8. save it and done!

Please post any suggestions, improvements you've made, question, comments, or complaints about my poorly styled code.


Attachments:
File comment: Scenario Generator script
main.nut [589.4 KiB]
Downloaded 64 times
File comment: List Generators
OTTDConversion.xlsx [10.75 MiB]
Downloaded 99 times

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter
Top
   
PostPosted: Mon Jan 04, 2016 11:06 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
Hi

Nice work there... was looking to try and build the uk using your bits but cannot find where to put the script using ottd 1.5.3 on window s 10. I was going to try and use it with full ecs, uk renewal, pipes, fish and a few other newgrfs and the uk v3 heightmap and those old houses from around 1830 onwards...

Trying to rework existing scenarios always causes reload problems in my experience (very limited :/)


Top
   
PostPosted: Tue Jan 05, 2016 12:59 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
Hi,

I will post more details for how to get the script working along with finding the ids for industries this evening.
I have also a height map for the uk in osgb coordinates, you can use any heigh map but but converting the coordinates could become very maths heavy and you will need to know the system your height map used.

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter


Top
   
PostPosted: Tue Jan 05, 2016 7:35 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
Okay, So the script main.nut is needed with info.nut to explain what it is to OTTD. These two in a folder need to be placed in your ...\OpenTTD\game\ folder either where you installed the OTTD or there is another folder in your documents.

also attached is the heightmap I used for my scenario which will work with the script as it is. For other heightmaps you will have to generate new sets of x and y coordinates for the lists such as local industries = [{....
_
_
}];

to get the industry IDs for your GRFs, modify the code to iterate through the industry type list printing the names and IDs of each
something like this:
Code:
for(i=1;i<255;i++){
   GSLog.Info(GSIndustryType.GetName(i)
}
}

untested

if your heightmap is from grid coordinates it will be similar to how I did it, if it is in lat/long that you will have a very very nasty time dealing with conversions, easiest way would be to get some GIS software which can handle the conversion to grid, but I would just avoid it to start with. In an unknown system it will be hellish, so if you have downloaded someones heightmap ask for the coordinate system from the author.

any questions please ask :D


Attachments:
File comment: place in "...\game" folder
ScenarioGenerator.zip [236.44 KiB]
Downloaded 45 times
File comment: heightmap in "...\scenario\heightmap"
Blend.png [1.05 MiB]
Not downloaded yet

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter
Top
   
PostPosted: Thu Jan 07, 2016 12:49 am 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
Many thanks, hopefully I will give it a try at the weekend :)


Top
   
PostPosted: Thu Jan 07, 2016 11:40 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
Hmm, not quite lining up on the heightmap, I seem to have cities in the sea... thinking I need to use 4096 x4096 since you don't seem to be able to use it as is is...

Was using old main, substituting...

Looks like time to get the API :/


Top
   
PostPosted: Fri Jan 08, 2016 2:48 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
hi,

the GS is currently very dumb, it doesn't look at the size of the map or make any kind of checks before trying to run, if you want a smaller scenario it should work if you factor down the x and y grid coordinates in the lists.

if a town or industry is placed on the sea, it will look for nearby land (forget if it was 5 or 10 tiles)

for the API docs, there is a link to NOGO on the wiki... for the most part it is the same as the AI API, with GS substituted for AI.

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter


Top
   
PostPosted: Sat Jan 09, 2016 11:26 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
As for api:

GS: http://nogo.openttd.org/
AI: http://noai.openttd.org/

But yes, you can also go via the wiki which was mostly written in the past when there was only AI and not GS, but has after that had some patch work to include GS details. You can still probably see the AI origin in the wiki. I do recommend reading the AI/GS stuff on the wiki as it contains some useful facts on how AI/GS scripts interact with OpenTTD and some squirrel 2.0 pitfalls.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Last edited by Zuu on Sat Jan 09, 2016 11:30 am, edited 1 time in total.

Top
   
PostPosted: Sat Jan 09, 2016 11:28 am 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
No problem, I sorted it (weekend was best ;))

I used the original main file with the second scenario package and replaced the towns with those from the new one. Then I rotated the heightmap 90 degrees, went through your procedure and voilà!

I'm just generating a full sized screenshot (whole map so you can see the results) and then I'm going to try and play, save and reload the map. If all goes well, I'll post the finished scenario here.

Then I'm going to try and cut out the motorways and rail so I can simulate undeveloped Britain for an 1870 map to see what we might have come up with without landowners' rights, nimbys, etc ;). Idea being steelworks don't appear before 1875 so how will ppl cope with the transition..


Top
   
PostPosted: Sat Jan 09, 2016 11:42 am 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
Zuu wrote:
As for api:

GS: http://nogo.openttd.org/
AI: http://noai.openttd.org/

But yes, you can also go via the wiki which was mostly written in the past when there was only AI and not GS, but has after that had some patch work to include GS details. You can still probably see the AI origin in the wiki. I do recommend reading the AI/GS stuff on the wiki as it contains some useful facts on how AI/GS scripts interact with OpenTTD and some squirrel 2.0 pitfalls.


Thanks Zuu :)

I am thinking of seeing if I can get the placement script working with some of the other gamescripts here like neighbours, balanced growth, etc so I know I'm going to have to do some serious reading to catch up with U guys :/

20yr years ago I introduced my little bro to this game and he broke it (passed was it 4bn back then?) in a few weeks or less I think and now its my cousin's kids (11 and downwards). They only know the uk and get easily confused by random town names and positioning especially when you're trying to help their gameplay :)


Top
   
PostPosted: Sat Jan 09, 2016 1:33 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
Teaching national geography is not a bad thing either, the map is helping my girlfriend actually get an idea of where places are located.

Your scenario sounds exciting, one adaption to the game script I would like to make but haven't managed yet, is to add construction/destruction dates to industries so the power plants and mills exist during the correct years. I've also not found any historic population data for scaling back the sizes of towns/cities.

for combining the scripts, should hopefully be a case of wrapping each of the scripts into a function/co-routine wrapper, which should give scoping that avoids nasty namespace issues.

Most important thing is that the generator script should run once and once only, currently it only flags to the save function when it is done completely, but it would be safer to keep track of progress encase the script is still running during a save.

Will be excited to see what you can manage with the early start dates. When I can find the time/effort to add more I am hoping to add canals to my scenario.

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter


Top
   
PostPosted: Sat Jan 09, 2016 4:23 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
I think dates are set in the newgrfs but if you want to apply a disaster like Margaret Thatcher to the coal industry for example, I suppose you can either use an array of known coal mines created from start or randomly select from a list of coal mines generated from the game at a year or few during the 80s to reduce by 80% in your script. I know that the newgrf topics are still quite active from my background reading so I reckon that anyone there should be able to quickly help with that. ;)

I know some might argue not just the coal industry was her effect but I don't think this thread is the place for that...

I had started discussing the combi script idea http://www.tt-forums.net/viewtopic.php?f=65&t=71555 and what you're suggesting might be a little ambitious from the noises I've been getting so far but you have more downloads here recently so I guess there are a few more guys on this now.

Will the guy under the bed please make himself known? ;)

Oops, full map 700MB and nothing will open it so I can shrink it :/


Top
   
PostPosted: Sun Jan 10, 2016 11:39 am 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
Putting a wrapper around the build industry method: http://nogo.openttd.org/docs/trunk/clas ... d215cb34a7
you could use an if statement and the gameTime class to set dates to build them.


sadly I don't see a method on the industry object to close them. This along with placing rivers, and terraforming and canals without company scope. I am planning to suggest the GS be extended to allow.

Impressive, I gave up waiting for a full map screenshot.

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter


Top
   
PostPosted: Sun Jan 10, 2016 12:49 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
Sorry about that issue.

I've done a save but it keeps crashing when DictatorialAI starts reloading and trying to find its property. Windows shuts it down so no crash logs.

I've included script, heightmap too for anyone aware of the issue while I search for clues...

Also found a potential source for historical population stats but not yet sure as to whether they actually have the info yet


Last edited by madprof on Sun Jan 10, 2016 1:15 pm, edited 1 time in total.

Top
   
PostPosted: Sun Jan 10, 2016 12:53 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
On the matter of closing industries:

I have a started, but not completed patch that allow GS to speak with industry NewGRFs. I made a fork of Busy Bee where raw industry production is increased by completing goals using the patch and a special NewGRF which listen to the GS and change production on the command of the GS. It should also be possible for the GS using this patch to close industries although I'm not sure if I ever tried it.

Patch thread in NewGRF dev forum
Bee Productive - the Busy Bee fork

Eg. you may be interested to look at it. But it is not in trunk as of now and there is no ETA.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sun Jan 10, 2016 1:17 pm 
Offline
Engineer
Engineer

Joined: Sat Jan 02, 2016 10:00 pm
Posts: 13
Thanks Zuu :)

Interesting addition. One question though.. was the patch incorporated into 1.5.3? At the moment I can see why things are so locked down, i.e., to protect game integrity and security, in relation to blowing everything apart to add new functionality it seems and rightly too I suppose...

1.5.3 question cos patch was July? it might affect take up until 1.6 is released at least.


Top
   
PostPosted: Tue Jan 12, 2016 8:59 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Zuu wrote:
But it is not in trunk as of now and there is no ETA.


Not in trunk means it is not sure if/when it get released. It needs more work for that. But knowing what use cases there might be is motivating.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Tue Jan 12, 2016 11:18 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
Being unfamiliar with grf coding I'm not entirely sure what they can do other than what I've seen with pikkas industry or firs or even if you mean industry or more grfs more generally.

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter


Top
   
PostPosted: Fri Aug 03, 2018 2:38 am 
Offline
Engineer
Engineer

Joined: Sat Sep 27, 2014 5:16 am
Posts: 58
Location: Calgary, Canada
I'm a bit late to the party for scripts but I stumbled across this when looking for a way to batch process city placement for a scenario I am tinkering with. I understand the logic of this I think but I am struggling a bit.

Firstly, I can't seem to select the script from the AI/GS settings menu in the scenario editor even though the two files are placed in their own folder in the OpenTTD/Game folder. . I am working through the steps in this thread with your heightmap and files.

Secondly, how would I go about creating a list of X/Y coordinates and getting them to work with this script? For example, I have a heightmap in mind, and can develop a list of X/Y coordinates from it. EDIT - Opening one of the .nut files in notepad I can sort of see where to paste the lists in the same format.

Thanks in advance for any help you can provide me. Currently using JGR Patch Pack 26.

Cheers

Le_Harv


Top
   
PostPosted: Sat Sep 15, 2018 7:49 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Nov 24, 2014 9:13 pm
Posts: 76
Location: At a desk
le_harv wrote:
I'm a bit late to the party for scripts but I stumbled across this when looking for a way to batch process city placement for a scenario I am tinkering with. I understand the logic of this I think but I am struggling a bit.

Firstly, I can't seem to select the script from the AI/GS settings menu in the scenario editor even though the two files are placed in their own folder in the OpenTTD/Game folder. . I am working through the steps in this thread with your heightmap and files.

Secondly, how would I go about creating a list of X/Y coordinates and getting them to work with this script? For example, I have a heightmap in mind, and can develop a list of X/Y coordinates from it. EDIT - Opening one of the .nut files in notepad I can sort of see where to paste the lists in the same format.

Thanks in advance for any help you can provide me. Currently using JGR Patch Pack 26.

Cheers

Le_Harv



Hey, I'm affraid I can't really remember much about this script, but I believe I ran it through the debug console. Because parts of the script were ran through a company (roads) and rail and canals were planned it was converted to an AI which only run in a game. Having let the script run in the new game, you can rename the extension to open the "game save" as a scenario again.

The UK heightmap I used was a geospatial TIFF which was in OSGB coordinates, I had to sample coordinates at the two ends of the UK to get scaling factor to convert between OSGB and pixels. All my points for towns/rivers/roads were loaded from a number of Ordance Survey layers also in OSGB. QGIS is very good at handling all the coordinates and heightmap information as well as all the different strange coordinates systems maps use. I would do everything in QGIS before converting your layers to any projection which uses Eastings and Northings in meters, then manually do the conversion between meters and pixels.

Of course if your heightmap is not a geospatial image (the good news is you don't have to worry about GIS, but the bad news is you can't just auto generate your towns from map data), I would start off with pixels coordinates, any decent image editor should be able to get your pixel coordinates, and just move your cursor to the point and copy the numbers into that section of the nut file. This would also need ripping out all of the code which converts OSGB to pixels

I don't know anything about patch packs but if the pack can load vanillia scenarios I'd run it all in vanillia before loading it with JGR.

_________________
Image
Real life transport planner
My projects:Link to my UK Scenario|Scenario Builder GS
Do check out my 3D unity transport game: transporter


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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.