#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Permutations of 2x2 Truchet Tiles

edited May 2016 By Paolo Gibellini Original uploader was P.gibellini at it.wikipedia - Transferred from it.wikipedia; transfer was stated to be made by User:p.gibellini. (Original text : myself), Public Domain, https://commons.wikimedia.org/w/index.php?curid=4158376

Given the above image of Truchet Tiles. I would like to draw out every single permutation of Truchet Tiles via processing. However with an important caveat. The traditional Truchet Tile has half of it's square area filled by a black triangle. I would like to treat a single tile as composed of 4 "Truchet Tiles" (or a 2x2 Truchet Tile).

What the image above is missing (in my opinion) however and I would like to include is the case when a tile may be completely white. So all together each of the 4 squares that make up one 2x2 Truchet Tile has 5 distinct possibilities.

That should result in (5 * 5 * 5 * 5=) 625 total permutations!

So in sum, I would like to be able to first procedurally draw out every single one of these permutations, and then eventually be able to store them somehow and randomly generate patterns that are composed of different combinations of these unique looking tiles.

I am curious as to whether these patterns will look different or significantly depart from traditional truchet tiles. When truchet tiles are normally in a pattern, they may end up neighboring each other to create 2x2 Truchet tiles, but I wonder if making the tiles grouped together like this to begin with will result in more interesting 4x4 neighbors. In the above image, just to clarify. The red outlines a traditional truchet tile. In blue is outlined a 2x2 truchet tile, which I am interested in permutating.

Tagged:

• edited May 2016 Answer ✓

Step 1: Draw all 625 possible combinations.

``````int type[] = {
0, 0, 0, 0
};

void setup() {
size(501, 501);
background(255);
fill(0);
noStroke();
for (int y=0; y<25; y++) {
for (int x=0; x<25; x++) {
pushMatrix();
translate(20*x, 20*y);
tile(type);
translate(10, 0);
tile(type);
translate(-10, 10);
tile(type);
translate(10, 0);
tile(type);
translate(-10,-10);
next_type();
pushStyle();
noFill();
stroke(0, 0, 255);
rect(0, 0, 20, 20);
popStyle();
popMatrix();
}
}
noLoop();
}

void tile(int kind) {
if (kind == 1) triangle(0, 0, 10, 0, 0, 10);
if (kind == 2) triangle(10, 0, 10, 10, 0, 10);
if (kind == 3) triangle(0, 0, 10, 0, 10, 10);
if (kind == 4) triangle(0, 0, 10, 10, 0, 10);
}

void next_type() {
type++;
if (type==5) {
type=0;
type++;
if (type==5) {
type=0;
type++;
if (type==5) {
type=0;
type++;
if (type==5) {
type=0;
}
}
}
}
}
``````
• You can use save to store results

You could also store the pattern as an abstract String (basically type) on the hard drive as a String, load it with another new sketch