Based on Noam Chomsky's work, the formal grammar consists in the achievement of the assignment of simple symbols regulated by rules with the aim of creating new complex, procedural and suitable formations. This process is the one we can use within a video game to generate, for example, dungeons.
The simple symbols constitute an alphabet with different possibilities where they can be distinguished:
The allocation of symbols over time is regulated by rules. To enrich the result, several rules are handled for each space of possibilities. In addition, percentages of use are assigned to the preference of each of them.
I would have to define now the units we will be using.
The smallest unit would be the box. Which carries the information of whether or not ground exists at that particular point. It is grouped into a 5x5 grid to give form to a symbol. The 5x5 grid has 4 available binding points in 2.0 / 0.2 / 2.4 / 4.2.
The symbol is a simple visual representation with information of the value of its boxes, the type of soil it is (land, vegetation, water, lava), its orientation and its open points of union (North, South, East, West). In my project, there are 8 types of symbols with 4 different orientations. They are non-terminals from number 1 to 6, and terminals from number 7 and 8. Completely different symbols can be used.
The board is the grouping of all map symbols. It has a size of 16x12 symbols (80x60 boxes) and it is where the iterative process of scenario generation is carried out.
Due to the number of symbols, the number of rules potentially increases. We would have, for example:
This means that by the non-terminal symbol of type 2 with North orientation, there are possibilities to continue with 24 different results. Thus, in order to regulate a process with so many possible choices continuously, I limit the percentages of each rule according to a process of stages. These change every 32 symbols permanently assigned on the map and regulate the choice of rules: