Inactive Procedural Architecture Grammar

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Name: Procedural Architecture Grammar
Summary: Grammar based system for automatic procedural building generation.
Scope: Module
Current Goal: Read custom grammar files; refine the system.
Phase: Implementation
Curator: Skaldarnar, sdab
Related: Villages and AI Concepts, Preview Renderer, #123, Wiki

The Procedural Architecture Grammar (PAG) is a grammar based system for generating buildings and other architecture related stuff. The building's general appeareance will be defined via a grammar file (*.pag), containing production rules for the automated generation process.

The principles of operation are scopes and shapes. Scopes restrict shapes along the three axis and contain a shape. The derivation process starts with a rough bounding box for the building as scope. This bounding box is dependent on the parcel the buidling is going to be placed in (namely width x height x depth).

Each production rule describes a modification of the current scope. For further information have a look at the wiki page.

Edit (06-20-13): You can find the grammar specification here.

I am looking forward to work on this together with sdab, who helped a lot with the language specification and general brainstorming about the system. Hopefully we can provide some new version soon.

  • grammars as assets, which can be added easily
  • create/implement a parser for *.pag grammar files (ANTLR, alternatives?)
  • review and improve current generation logic (floating point calculations, ...)

Must:
  • read in and parse *.pag grammar files (feature reduced, simple rules only)
  • use parse result to create structures with reduced feature set
  • reduced features: Base Rules without special roofs, no occlusion/sight checks.
  • start with rectangular footprints
  • provide API for usage by other modules
Should:
  • use guards for rule selection
  • use correct probabilities for rule alternatives
  • basic variable definitions (= direct assignments)
Could:
  • have at least one special roof type
Would:
  • deal with special blocks/placement (e.g. stairs and slopes)

In addition to this I would like to see a good github wiki documentation, providing a lot of examples on how to use the grammar and how it acutally works.

---------------------------------
My old TODO list ;)
So, what exactly am I planning to do?

Rule Implementation
  • [Done] Set rule
  • [Done] Divide rule
  • [Done] Split rule
  • Repeat rule
Grammar functionality
  • Guards/Conditions
  • Occlusion Queries
  • Snapping
Expansions
  • [Done] /build console command
  • arbitrary footprints
  • scopes of multiple shapes
  • more primitive shaps (cylinder, sphere, ...)
  • user defined attributes
  • generic rules
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Looking forward to seeing more of this! :)

From my understanding this will allow the writing of PAG files that'll support generating stuff to fit certain patterns, like buildings. Curiously, will it also work the other way around - analyzing something to see if it qualifies to be something specific?

My favorite example is as always a portal. I can picture writing a portal.pag that can generate a portal in various shapes or sizes easily, but could the player build an arbitrary structure in-game then try to "qualify" it as fitting the definition of said portal? It sounds to me like that would be doable, if tricky for larger structures (nested definitions?) which would be awesome :)
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Hmm, that could be quite tricky...I think I will be working towards this...I think the problem is that the derivation trees could get quite big (or complex, due to the different rules) and that you can test an existing structure only against a primitive (though, you cannot read the structure block by block an choose the production rules as with a simple word problem or such...).
Maybe we can test it for simple structures like portals (and I don't think that it would be quite useful for more complex strucures/buildings...)
 

Nym Traveel

Active Member
Contributor
Art
World
Phew, read through the wiki article and this here - quite crazy stuff upcomming :)
I like it very much (though I understand not too much)
In my head the upcomming world looks like skyrim/oblivion just in 1m³ cubes and procedurally generated :D
(so like nearly infinite versions of the TES series, weeee:omg: )

I know this woun't help you much but to give you a source of inspiration:
Buildcraft/Mystcraft/TheRailthingyIDontRemember have all such things as you described, Cervator
For example the posrtals of any shape by Mystcraft, the coke ovens of Railcraft (I think it's called like this ;) ) and some fancy tanks by Buildcraft. You can scroll through direwolf20's server play to see some of them (no idea what episodes, sry :p )
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Skaldarnar - Merging the initial pull request now and leaving this link to the files here for reference to easily look at all the neat new stuff :)

And I might add it looks no less than freaking neat to boot! New badge-worthy, methinks, even if I don't fully understand all the terminology either - the PAG files seem like something you could learn though :D

I see BuildingGeneratorTest.java as runnable and it produces output when I run it. But changing the width/height/depth parameters doesn't seem to change said output, nor does the BlockCollection appear to be filled with anything. How functional is it? I need to get that debug tool back so you can place a BlockCollection / Blueprint in the world again :)

And there are even a couple unit tests! Woo. Could use more Javadoc at some point though :geek:

One of the tests fails in Jenkins, any idea? Also some error output about loading block shapes. The namespace setup might have changed slightly since you started, or maybe the test just doesn't get asset loading initialized like the full game does?

Nym Traveel - yeah. I noticed that Mystcraft portal of any size thing, is indeed exactly what I want, also with horizontal portals :D
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Ok, I've to admit that the output is not very clear... it shows just which rule/shape is active during the derivation process, but not its scope or something.

The funcitonality is quite non-existent I fear, the part of creating a BlockCollection out of the derivation is what I am currently working on.

I've no clue about the unit test failing. If I want Intellij to show me the difference it only states: "Contents are identical", but still it fails the test...

So, I'll try to actually create a BlockCollection from the BuildingGeneratorTest, which should create a structure like in the attached screens. For this structure the parameters would be like width=6, depth=7, height=4. The height is minor for the generation (the structure will always be 4 blocks high), but if you change width and depth the footprint should change.

NOTE: The building is handbuild, no automatic generation yet :(
 

Attachments

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Ok, its time for an update! :omg:
I've managed to implement a simple build command (/build <width> <height> <depth>) to test the building generation. View the attachted files for some example runs, both single buildings and running the command several times to cobine the structures...
At the moment there are still some problems, such as that it works perfectly for square footprints (same value for width and depth), but if they are different there are some strange edges on two sides of the building (you can see that in some of the pictures). I've to investigate that, can't wait to use those debug tools again :ajconfused:
121215193817170.png121215193832423.png121215193226593.png

Edit: I've solved the edge issue. Have a look at my git hub branch, I will make a pull request tomorrow.

The predefined grammar will just generate a simple building, with cobblestone walls and a flat, 1 block thick wooden plank "roof". At the moment there are no doors or windows, although one should be able to add them via the grammar (will try that out tomorrow). The building will be as high as you specify, so you can build up towers and stuff...
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
... must... find... time to review ARGH! I want to play with the building toys :(
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
It works! Had a chance to try it for myself. Neat. Can definitely picture it getting more detailed and creating sophisticated buildings :)

Also takes surprisingly long, are these buildings being put together by hamsters? :D
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
I noticed this for myself, but as far as I can tell it is due to placing the blocks in the world. The generation itselft takes only a few ms (BuildingGeneratorTest runs the sample grammar, for example), so it must be the lighting propagation or something... maybe there is potential for tweaking the block placement in the world provider.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Oho, that's true. If each block is placed individually in the world stuff might happen per-block all at once. Reminds me of the ideal to "stagger" the activation of physics cubes when you blow something up to limit performance spikes. Maybe we could do something similar with the placement of BlockCollections - add the blocks to a queue and pop one independently into the world every 100 ms or so. Could be a neat visual effect even?
 

pencilcheck

New Member
Contributor
I would like to try it out sooner, but I wonder if it is possible to collaborate on placing block collection structure?
Right now I am getting to the point where I need a system to handle blocks to build dynamic structure out of functional block collections. And what you are tackle could be applied to my problem as well.


However, I also need a system to handle them in user inventory as well (been trying to add a new toolbar for functional blocks :))

What do you think?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
The area definitely needs work, on several angles :D

Skaldarnar - can has PR soon? What's next? :geek:
 

overdhose

Active Member
Contributor
Design
World
GUI
/me is anxious to see how this will evolve...

Just an early stage idea here, but I was planning to combine this with zone blocks so you could define a layout of a city and then have minions build it... given the available resources. Bit like sim city, you'd have a zoning tool that lets you place blocks, like in this minecraft example:

2013-01-02_19.51.04.png2013-01-02_19.51.18.png2013-01-02_19.51.37.png2013-01-02_19.52.13.png2013-01-02_19.52.22.png2013-01-02_19.52.45.png

each block holds an int of metadata linking it to a zone, the zone contains the type, dimensions, names etc, letting you build an infrastructure of streets which could be used for pathfinding, and distributing goods. The mailboxes for example check for the zoneblock under it and display a house number assigned to a zone. Similar you could create road signs that actually show road names etc... The idea is to let minions clear the area above the zone, and once cleared let you select a type of building, depending on size and type of the zone.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
That sounds great and the MC mod looks interesting. Which one is that?

Those zones sound like the same goal I had in mind for designating workshops and such. And I love the idea of being able to help guide traffic - I think DF had something similar to that too. Pathfinding can only get so good, if there is a simple way for the player to easily enhance it then that's great.
 

overdhose

Active Member
Contributor
Design
World
GUI
uch that mod is my unrealeased sim-u-revamp mod :D
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
OOhhh - nice! Build it for us then already :laugh:

Code all the things!
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
This meta information thing sounds a bit like the "city egg" for houses :D But of course your concept would fit perfect with the grammar system, as it only generates structures and is totally unaware of the city layout. I'll push the grammar itself further before I start thinking about the actual city placement, but if you want to play with it, feel free to do so ;)
 

overdhose

Active Member
Contributor
Design
World
GUI
will do that soon I hope. Or if not, at least plant a little seed of ideas
 
Top