Amazing! Generative Design with the Wave Function Collapse Algorithm
Information about Generative Design with the Wave Function Collapse Algorithm
One of the main algorithms in this game is the wave function breakdown algorithm. Originally developed for Generate images from a small input, its principle can be applied to many use cases, such as urban planning, Wedding seating plan and even poetry.
The main idea behind the algorithm for collapsing the wave function starts with a grid. On this grid we place an element from a list (a list pixel to create an image or a list of buildings / streets to create a city). When placing the first element, a number of rules restrict which elements can be placed near the grid.
i stole the great example of Robert Heaton to explain how this algorithm works.
Let’s say we want to create a simple landscape. In this landscape we can either have land, sea, coast or mountains. Each type of terrain is represented by a square tile:
These four tiles can be placed anywhere on a grid:
Rules then limit the position of a tile relative to one another. Here,
- Sea can only be near coast or itself
- The mountain can only be near land or itself
- Coast must have land on one side and sea on the other
We then select a first case on the grid and randomly select the first tile. Here we go with a mountain tile:
Since the mountain can only be near land or itself, we can place the following tokens near it. If we have more than one option, we will randomly choose the tile from the options:
Then we keep filling the grid, following the rules for each successive tile:
In the end we have a beautiful landscape. With such an algorithm, you can create a lot of landscape by changing the position or type of the first tile. A weighting system that allows the algorithm to choose among the possible tiles can also replace the random part of this implementation.
This idea seemed quite interesting for generating an office floor plan. To implement this system in Revit, I’ll start by drawing the tile as a Revit group. I start with a 2.70m * 2.70m tile. In this square I model an office room with a partition wall and three facade segments.
Then I use a group to create a single tile from those models.
In order to be able to connect these tiles together, we have to rotate them. Instead of implementing the rotation in code, I created four groups for each tile, with each group containing the tile rotated a quarter turn.
In the end, we have 16 Revit groups that form the basis for creating our floor plan.
I also add a 17th group called “Void” to represent the space outside the building.
I then create an Excel spreadsheet in which I formalize all the rules of adjacency. In this table I describe for each tile, i.e. each Revit group, which group can be appended top, bottom, left or right. The last column, “Weight”, allows you to put some tiles on top of the others.
I then create a C # console application which contains the actual implementation of the Wave Function Collapse. This application takes the table of rules and outputs a CSV file that describes the resulting raster. This csv file contains the name of the group to be created for each position in the grid.
I then use this file in a small Dynamo solution to place all group instances in the model.
By doing this process for a long time, I get a number of floor plans completely modeled in Revit.
The resulting layouts aren’t very interesting. Even if they more or less “look good” with real office space enclosed by a facade, they are not credible architectural solutions. And the Ability to do a lot of them won’t make them any better. Since the algorithm creates the entire floor plan by just looking at the surrounding tiles, it seems fine locally, but is still a mess globally. The algorithm lacks some kind of global overview of the target.
But even if my naive approach of generating an entire floor plan with it doesn’t work, the principle still seems interesting, perhaps for something like facade design.
Right now, running the entire system in Revit is a bit of a hassle. I hope to improve it by putting all of the code into Dynamo. I will then be able to use it on different use cases.
Breaking Story – Generative Design with the Wave Function Collapse Algorithm
The Latest News on Generative Design with the Wave Function Collapse Algorithm
Original Source: https://www.bim42.com/2020/09/generative-design-with-the-wave-function-collapse-algorithm
Category – BIM