Jump to content




[WIP] [Infinity 1.7.0] Procedural building

command

25 replies to this topic

#21 Yarillo

  • Members
  • 81 posts
  • LocationFrance

Posted 19 July 2015 - 04:50 PM

Sorry Bomb Bloke ! I completly re-did the city generation code to something more modular and generally better.
Your idea just didn't work out as it was and I had to scrap it. It didn't feel "random" enough, it made some holes, you had to check afterwards if there were any useless parallel roads...

So, this morning started from scratch with the generation and I managed to do this:

Posted Image

Completly new approach.

Here's how it's done: You make you city chunk by chunk.
You start by making your first line by simply placing chunks of buildings of random length, and spacing them with a road each time.
3 buildings, then a road, then 2 buildings, then a road, then 1, road, 3, road, 2, road, etc...
After that, you define a set of rules. Here are mine:

- If below me there are two consecutive roads, this chunk will be a building
- If below me there are three consecutive building chunks, start a new road (this prevents making the buildings too large)
- If the chunk below is a road, choose between those two actions:
1) Make a turn (1/3 of the time)
2) Continue the road (2/3 of the time)
- If the chunk below is a building, this chunk will be a building

Then I stopped a little and continued. I added a new step: "make all the intersections and turns look nice"

Posted Image

Posted Image

It was pretty tough. I figured out that not every intersection had to have crosswalks but only those with 3+ openings. The others were technically just "road turns".
So, now that some of my intersections became "turns", some of them have to get little dashes of paint.
Well, that's a problem: how do you know where to start the dashes and where to end them ? You don't want to break the pattern of the road connecting to the turn. It's one dash every 4 blocks and not "one dash every 4 blocks and sometimes when there's a turn it's whatever you want"

I'll spare the explanation because it's not really fun, but it was a challenge to figure that out

Spoiler

Edited by Yarillo, 19 July 2015 - 05:02 PM.


#22 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 19 July 2015 - 04:55 PM

Nice! But currently it seems like the road is only turning right and not left.

#23 Yarillo

  • Members
  • 81 posts
  • LocationFrance

Posted 19 July 2015 - 05:06 PM

Yes. That's the flaw :D
I knew about it but I didn't think anyone could point it out.
It must be a little bit more obvious than I thought.

It's can be easily fixed, I just didn't bother out of laziness. I've been on it for too long and just wanted to update the devlog and go eat :D
The problem is right there:

Quote

- If the chunk below is a road, choose between those two actions:
1) Make an east turn either a left or a right turn (1/3 of the time)
2) Continue the road (2/3 of the time)

That's why it's awesome ! You can fix everything very easily :D

Edited by Yarillo, 19 July 2015 - 05:08 PM.


#24 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 July 2015 - 01:39 AM

View PostYarillo, on 19 July 2015 - 04:50 PM, said:

Your idea just didn't work out as it was and I had to scrap it. It didn't feel "random" enough, it made some holes, you had to check afterwards if there were any useless parallel roads...

My idea, and what you actually coded, were two different things. I may not've been clear in expressing it.

Your current system should work quite well once you get all the roads to connect together. :)

#25 MCplayer

  • New Members
  • 1 posts

Posted 17 August 2016 - 02:22 PM

It does not work it says citybuilder:9: attempt to index ? (a nil value)

pastebin get dj7hsjKU citybuilder works but it does not want to work

#26 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 August 2016 - 02:25 AM

... and what command did you use to start it?





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users