Cellular automaton house generator by VanlindtMarc 3d model
3dmdb logo
Thingiverse
Cellular automaton house generator by VanlindtMarc

Cellular automaton house generator by VanlindtMarc

by Thingiverse
Last crawled date: 3 years ago
Made with OpenSCAD
/ [Pamètres de bases] /
//Hauteur de la structure
Profondeur=17;
//Nombre d'étages
Etages=14;
// Redimensionnement
Redim = 2.01;
/ [Conditions de vie] /
// 0 cellule vivante
cell0=false;
// 1 cellule vivante
cell1=true;
// 2 cellules vivantes
cell2=false;
// 3 cellules vivantes
cell3=false;
// 4 cellules vivantes
cell4=false;
// 5 cellules vivantes
cell5=false;
// 6 cellules vivantes
cell6=false;
// 7 cellules vivantes
cell7=false;
// 8 cellules vivantes
cell8=false;
Taille=(Profondeur*2)+2; Hauteur=Profondeur+Etages; Mid=ceil(Taille/2);
points = [for (a = [0 : Taille]) [for (b = [0 : Taille]) if(b!=Mid || a!=Mid) 0 else 1 ]];
translate([-Mid-Redim/2,-Mid-Redim/2,Hauteur+1])
suite(it=1,maxit=Hauteur);
module suite()
{
translate([0,0,-it1])
for(i=[0:Taille])
{
for(j=[0:Taille])
{
translate([i,j])
if(points[i][j]==1)
{
color([1/maxit(it-1)/Taillei,0.5-maxit(it-1)/Taillej,1-(1/maxit(it-1))/Taille*(i+j)/2.1,1])
scale(Redim)
cube(1);
}
}
}
if(it<=maxit)
{
points2 = [
for (a = [0 : Taille])
[for (b = [0 : Taille])
if(a==0 ||
b==0 ||
a==Taille ||
b==Taille ||
voisinage(x=a,y=b,p=points)==(cell0==false ? 0 : 1) ||
voisinage(x=a,y=b,p=points)==(cell1==false ? 1 : 0) ||
voisinage(x=a,y=b,p=points)==(cell2==false ? 2 : 0) ||
voisinage(x=a,y=b,p=points)==(cell3==false ? 3 : 0) ||
voisinage(x=a,y=b,p=points)==(cell4==false ? 4 : 0) ||
voisinage(x=a,y=b,p=points)==(cell5==false ? 5 : 0) ||
voisinage(x=a,y=b,p=points)==(cell6==false ? 6 : 0) ||
voisinage(x=a,y=b,p=points)==(cell7==false ? 7 : 0) ||
voisinage(x=a,y=b,p=points)==(cell8==false ? 8 : 0) ) 0
else 1 ]];
suite(it=it+1,maxit=maxit,points=points2);
}
}
function voisinage(x,y,p) = (p[x-1][y-1]+p[x][y-1]+p[x+1][y-1]+p[x-1][y]+p[x+1][y]+p[x-1][y+1]+p[x][y+1]+p[x+1][y+1]);

Tags