Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Procedural City Street Generation Using L-Systems  (Read 857 times)
0 Members and 1 Guest are viewing this topic.
Offline Slyth2727
« Posted 2014-07-13 17:45:06 »

After a long hiatus from game programming I've returned with some decent ideas (in my mind).

First of all, I'm trying to procedurally generate a city for my game. It will be a game feature, so the player can play in different worlds.
I think that the best approach would be to generate a 2D texture of the road map, and then populate it with buildings in the 3D game world (also procedurally generated), so I did some research and decided that L-Systems would be the way to go simply because that's really the only thing I saw people using. After a few more days of research, I still don't fully understand how I would put it into code.

From what I understand, you have a predefined string which is basically the generation rule for the system. You can go forward and draw a line, rotate, switch draw states, and use the | symbol to do something else I don't really understand either. If anyone has any simple/beginner friendly street generation articles they know of, I'd appreciate it if they could share it as well as any advice!

Also, some time ago I saw a post from Riven (I believe?) of a city street generation exactly like what I'm going for. So if you're reading this Riven, mind popping in and either sharing some code or advice?

Thanks!

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2014-07-13 17:58:34 »

L systems are a way to recursively turn a sequence of instructions, into another sequence of instructions.

This is a totally different thing than how to interprete these instructions.

Say you get these instructions: "FFLFRFLFRFF", where F is: go forward, L is: turn left, R is: turn right.

Exercise 1: follow the instructions in the sequence - draw the path
Exercise 2: turn every "FL" sequence into "FFRLFRL"
Exercise 3: goto #1

Repeat this, and you'll see the sequence (and therefore the drawing) getting more and more complex.



Having said that, my city generator did not use L systems.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Slyth2727
« Reply #2 - Posted 2014-07-13 18:16:33 »

Ah, so I just customize the instructions to my needs. Those two sentences made it click for me! Thanks.
Now that you say your generator did not use L systems, I'm curious what you did use? I'd like to look into many options.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sabomoth

Junior Member


Medals: 1
Exp: 2 years



« Reply #3 - Posted 2014-07-13 22:19:44 »

http://www.acc.umu.se/~antonh/tmp/p301-parish.pdf

More stuff here, even making the houses;

http://pcg.wikidot.com/pcg-algorithm:city-generation

Offline Slyth2727
« Reply #4 - Posted 2014-07-13 23:20:05 »


Thanks for the links! However, I've looked at those already.
I've already started working on the L-system thing. It's going okay I suppose.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Slyth2727
« Reply #5 - Posted 2014-07-13 23:47:06 »

Okay, after a bit of work I have a base for L-systems down. Just doing the Hello World kind of thing for L systems in this example:



Now on to the more advanced stuff.
Thanks Riven!

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!