Wednesday, November 7, 2012

More Thoughts About Grammars and Buildings


Grammatical constructions complete!  Using the idea of a formal grammar evolving a string of symbols (letters) into a new string of symbols we can make use of two categories: terminal and non-terminal symbols.  Terminals have associated geometry specified in the mapping section and non-terminals evolve into a new string of symbols.  For clarity I have reserved a few symbols: 's' is the start symbol, 'g' is the ground floor, 'v' creates a column based layout, 'h' creates a row based layout.  The evolutions or children of these symbols still need to be defined in the rules of the grammar, but these will have special behavior without extra rules.  Rules take the form: "symbol child_string" where multiple instances of the same symbol create multiple children.  The mapping section defines its symbols as terminals and gives the name of the element from the library that they map to.  Terminals can only have one mapping, randomality should be introduced with a non-terminal that have multiple non-terminals as children.  These building show row and column based layouts built from the following grammar.
From the input file:

grammar:
    s gv //start rules
    s gh
    g df //ground floor rules
    f bf
    v bwq //vertical rules
    q bwq
    h bwwe //horizontal rules
    e bwwe
end

mapping:
    d TestArchDoor
    b TestWall
    w TestWindow
end

Here 'f'', 'q', and 'e' are non-terminals that serve only to repeat their patterns.  The building on the left is from the horizontal rule 'e' with a wall and two windows repeating in each row.  On the right 'q' alternates walls and windows in each column.  From here the next step is to test increased randomality by adding more symbols and terminal geometry.

No comments:

Post a Comment