City Generator Scripting

How do you cycle through all the children of the intersection ? With a for loop ? Probably … LOL
No I didn’t look at those yet. I have to check those out soon.
It gets kind of complicated because since I added the intersections it’s overlapping a lot more than before.
I’ve been watching this thing build roads automatically for hours. LOL

Here is the updated version. When I added a free camera I realized the segments were not properly aligned.

Attachments

autoAlignF1.blend (191 KB)

Are the roads slanted above one another?That would be necessary.

See if you can figure out the intersections script but I see way more overlaps now. It also depends on how many curved segments and intersections you feed into it. More intersections gives more overlaps. I have to try different designs on the segments.

Your script is hard for me to understand.I did a little regular python programming but i am still a noob.I use logic bricks instead.Maybe i will get back to that but not now.All i can do is make suggestions and provide resources.
I would probably as easy as i could do it.Even if i knew python really good.

I know it’s hard to figure out scripts made by other people. I have the same problem.

Is GTA V able to generate caricature intersections like this one ?

Attachments


And here the file with 4 types of intersection segments (T-Y-X-O). Unfortunately the script is not using more than one node/child and intersections have more than one link node. So yeah, it’s a good programming challenge for the more advanced ones. I’ll have to try the scripting part too. At some point.

LostScience , you want bridges and tunnels and highways going above one another ?

I’ll have to add a few I guess but highways also need on/off ramps so it gets pretty complicated.

Attachments

autoAlignF3.blend (124 KB)autoAlignF5.blend (121 KB)

Your doing great job keep at it.

Here is the version that expands from all children it’s just not very random at the moment.

Attachments

autoAlignF8.blend (126 KB)

Okay, here we go:


This is how it should be:

  • proper names
  • uniform size tiles (20by20)
  • proper tile system ( no collisions )
  • randomized map ( tiles have probability as of weights )

What to do:

  • Better code
    [LIST]

  • a class perhaps

  • comments

  • variable names etc

  • Better map generator

  • add bias ( default weights ) to tiles
    [LIST]

  • for example even if random, +Crossroad intersection should be used sparingly

  • population density map

  • avoid deserts/mountains

  • build cities where habitable

  • looks better

[/LIST]

  • More tiles

  • I removed the no 90 degree Y intersection
    [LIST]

  • Because otherwise It would have been necessary to make proper connection tiles between [+ and y , L and Y , I and Y, etc ] and keep a dictionary of it

  • For first example that is too complex, but later in the end desirable.

  • Look how other games do it:


  • http://www.erzo.org/shannon/images-rpg/seismic.jpg

  • http://www.cr31.co.uk/stagecast/art/grabs/edge/road.png

(there are downloads in his video desc )

  • All of them are uniform size and can connect to each other, the randomness comes from the map generator, not from the tiles.
  • Tiles make it easy to place buildings and do pathfinding.
    [/LIST]
    [/LIST]

Offtopic:
if am/was too annoying, it might be because I had 36 hour math exam study marathon.
My brain is butter.

Attachments

roadTileSystem.blend (96.8 KB)

Hey , I managed to make it expand from all children I just had to use pop() to prevent runaway effect. It took me all day. LOL

I will have to read your script for a long time to figure out what’s what.

Mine is doing it completely different. Check autoAlignF8.

What I wanted to do was collect all children in the scene and add road segments there randomly but that created a feedback runaway effect because each spawned segment brings in it’s own children.

Different???
That is also what my script does :smiley:
On top of that it checks for overlaps and does improvements.

That one in the video looks nice but I have no idea how to texture the squares to match like that.

Wow. You guys are too advanced. LOL

How do you check for overlaps ? I’ll have to look into it more but it’s kind of advanced for noobs.

Ok so now that your road builder works, what’s next ? How do we add buildings in between or terrain ? Or should we do the one from the Unity 3D video ? The idea is to make it into a full city somehow. Like a mini clone of GTA 4 or something. The only difference is, this one would be completely open to modify. GTA 4 is not very easy to modify. It’s not generating roads for you at all.

Main point , listen:
Make your tiles all square
Make the connections standard

Don’t make the road segments randomly , otherwise the whole logic becomes too hard to make any use of it later.
You can use use logic brick (collisions(road)-and-endobject) and build your road system,
but what do you do after that? It’s a hard do manage mess…

I would suggest doing it by hand first by cutting out squares out of paper first.
Tiles would also be most easy for other people ( kids as you said) to understand.
http://www.erzo.org/shannon/images-rpg/seismic.jpg

To make the squares match, just put the empties where the roads on the tiles are,
it’s the same system you put together.

Wow more posts :slight_smile:

I save the position of each tile in a dictionary.
If some one ( road tile ) is at that location then logically that is occupied.

So, if i want to place a tile at XY worldposition (0,0) , I check if someone is at (0,0) by " if (0,0) in locationDict".

  • Ok so now that your road builder works, what’s next ?
    [LIST]

  • Develope it further ? what else.

  • Turn this into a game demo for you a resource/fun problem solving for me :smiley:

  • How do we add buildings in between or terrain ?

  • You put the roads on the terrain

  • Or, if you are really crazy, make the terain also a tile system.
    [LIST]



  • http://www.civfanatics.com/sotd/sotd99.jpg

  • You can start by having special building tiles that you add on the side of the road
    You can have special empties on you tiles can spawn buildings or other assets on them

  • You can stack tiles
    [/LIST]

  • Or should we do the one from the Unity 3D video ?

  • I want you to use or create the assets that are satisfy the problem and you.

  • We can use the texture from the video , as it was free?(didn’t watch it ) if you want…

  • The thing is there is not much difference, a tile(in sense) is a shape and a rule, it is not a texture always.

  • GTA not generating roads for you at all.

  • Well, their design was not a editable world but a copy of the real world

  • That is why they had to do it by hand beforehand.

  • A random world would need rules to be able to harbor a city and roads.
    [LIST]

  • Almost all building type stragegy games like simcity/transport tycoon/anno have a grid on top of which there are tiles.

  • In real world we flatten ground, define borders of things already built and don’t let matter occupy same space.

[/LIST]
[/LIST]

The thing is, from the way your script is generating is not leaving much room for buildings or sidewalks but it’s doing it nice.
Do we have to place buildings before the road gets generated or after ?

I think I get it now. All those road segments are always centered on the tile so it always fits properly as long as the rotation is ok.
And all tiles need to be the same size.

It is coming along pretty good.

Its not the script, its the tiles. It depends how we ( you ) want to design the tiles.
Yeah we would after placing a road tile reserve some empty tiles for buildings.
Also you can add buldings on a road tiles: a map tile can have its own sub tiles ( buildings ).

Yup, basically that.
The funny part is how do you define grid if your objects (obj.worldPosition) is not centered in the tile.(per your design)
Hopefully you get how that is handled in logic…