A playground for University of Bologna Students and a 6-days seminar about digital tools.

Digital generative tools are a very important part of architectural education. Andrew Kudless during his conference at SimAE was telling about chinese traditional woodcraftsmen: they spend their first two years of apprentice in making their own tools. Today, we have a large pool of digital ready made tools, built to respond to more or less specific problems or tasks, while keeping a level of flexibility and personalization. The majority of these tools have hidden capabilities, which can only be accessed bypassing the conventional interface and getting close to the machine logic of programming or building parametric components which generate shapes. Thus, seriality, differentiation, complexity can be implemented in architectural projects through code, in order to exploit the power of algorithmic based complex systems which are the basis of biological systems.


But, before going through such complexity, we must start with simple tasks and simple rules. Before playing seriously we need practice. This is the playground where a bunch of students will start to practice, a pool where they will share their results and questions. Maybe the stuff here that will be posted will seem obvious or naive to the navigated code-monkey, but, as I mentioned before, we all start from the basics and this is intended as a place to start. However, any comment and contribution is appreciated.

Playground is open, let's play! _ Alessio

2.11.09

L-system [test]

Working on the same principles of my last post I realized a new script based on self-learning system.
The concept is easy. A simple L-system start to grown randomly from a seed, and after every generation it try to touch other L-systems, that are growing from different one seed.

[edit]
I forgot to explain some aspects. In this script singles L-system recive a feedback from others, because configuration of every generation depend on configuration of previous one.
Unlike my previous script there isn't only one final perfect configuration, but infinity ones... because every random event of system "A" affects other systems in next generation, thus itself in following one.
[/edit]


Option Explicit
' Script written by Alessandro Zomparelli
' alessandro.zomparelli@gmail.com
' http://alessandrozompa.altervista.org/
' Script version domenica 1 novembre 2009 14.40.18

Call Main()
Sub Main()
'picking seed points
Dim arrSeed, arrSub
ReDim arrSeed(0)
arrSeed(0)=Rhino.GetObjects("pick seed points",1)

'defining number of branch
Dim dblBrN
dblBrN=Rhino.GetInteger("number of branches",2,1)

'defining number of branch generation
Dim dblBranch
dblBranch=Rhino.GetInteger("number of branch generation",3,1)
ReDim Preserve arrSeed(dblBranch)

Dim arrData, dblVote, arrVote
ReDim arrData(dblBranch), arrVote(0)

'defining number of generations and amount of mutation between following generations
Dim dblGen, dblMut, strLine
dblGen=Rhino.GetInteger("set number of generations",100,2,10000)
dblMut=Rhino.GetReal("set mutation value",2,0.1,100)

Call Rhino.EnableRedraw(False)

'starting evolution system
Dim i,j,z,k,y,m,a

Dim dblDis, arrDist, strC1, strC2
ReDim arrDist(0)

'generation of different layers
Dim strL1: strL1="lines"
Call Rhino.AddLayer(strL1)

'evaluation of distance between seed points for a better L-System scale
dblDist=Rhino.Distance(Rhino.PointCoordinates(arrSeed(0)(0)),Rhino.PointCoordinates(arrSeed(0)(1)))
For i=0 To ubound(arrSeed(0))
For j=0 To ubound(arrSeed(0))
If i<>j Then
If Rhino.Distance(Rhino.PointCoordinates(arrSeed(0)(i)),Rhino.PointCoordinates(arrSeed(0)(j)))<>0 Then
arrSeed(i)=arrSub
End If
arrData(i)=arrSub
For j=0 To ubound(arrSeed(i))
arrData(i)(j)=array(0,array(0,0,0),array(0,0,0),dblDis)
Next
Next


For z=0 To dblGen-1
Call Rhino.Print(int(z*100/(dblGen-1))&"%")
For i=1 To dblBranch
'generation of branches
For j=0 To ubound(arrSeed(i-1))

For y=0 To dblBrN-1
'defining vector scattering direction
arrData(i)(j*(dblBrN)+y)(2)=array(arrData(i)(j*(dblBrN)+y)(1)(0)+dblMut*(dblGen-z)/dblGen*(rnd-rnd),arrData(i)(j*(dblBrN)+y)(1)(1)+dblMut*(dblGen-z)/dblGen*(rnd-rnd),arrData(i)(j*(dblBrN)+y)(1)(2)+dblMut*(dblGen-z)/dblGen*(rnd-rnd))

'propotional scaling factor
arrData(i)(j*(dblBrN)+y)(2)=Rhino.VectorUnitize(arrData(i)(j*(dblBrN)+y)(2))
arrData(i)(j*(dblBrN)+y)(2)=Rhino.VectorScale(arrData(i)(j*(dblBrN)+y)(2),arrData(i)(j*(dblBrN)+y)(3)/i/3)
arrSeed(i)(j*(dblBrN)+y)=Rhino.CopyObject(arrSeed(i-1)(j),arrData(i)(j*(dblBrN)+y)(2))

'drawing last generation
If z=dblGen-1 Then
strLine=Rhino.AddLine(Rhino.PointCoordinates(arrSeed(i-1)(j)),Rhino.PointCoordinates(arrSeed(i)(j*(dblBrN)+y)))
Call Rhino.objectlayer(strLine,strL1)
If i=1 Then
strC1=Rhino.AddCircle(Rhino.PlaneFromNormal(Rhino.PointCoordinates(arrSeed(i-1)(j)),arrData(i)(j*(dblBrN)+y)(2)),arrData(i-1)(j)(3)/20/i)
Else
strC1=Rhino.AddCircle(Rhino.PlaneFromNormal(Rhino.PointCoordinates(arrSeed(i-1)(j)),arrData(i)(j*(dblBrN)+y)(2)),arrData(i-1)(j)(3)/40/(i-1))
End If
strC2=Rhino.AddCircle(Rhino.PlaneFromNormal(Rhino.PointCoordinates(arrSeed(i)(j*(dblBrN)+y)),arrData(i)(j*(dblBrN)+y)(2)),arrData(i)(j*(dblBrN)+y)(3)/40/i)
Call Rhino.AddLoftSrf(array(strC1,strC2))
If i=1 Then
Call Rhino.AddSphere(Rhino.PointCoordinates(arrSeed(i-1)(j)),arrData(i-1)(j)(3)/20/i)
'Else
' Call Rhino.AddSphere(Rhino.PointCoordinates(arrSeed(i-1)(j)),arrData(i-1)(j)(3)/30/(i-1))
End If
Call Rhino.AddSphere(Rhino.PointCoordinates(arrSeed(i)(j*(dblBrN)+y)),arrData(i)(j*(dblBrN)+y)(3)/40/i)
Call Rhino.DeleteObjects(array(strC1,strC2))
End If

'for display colors of different generation
'If z/10=int(z/10) Then
' strLine=Rhino.AddLine(Rhino.PointCoordinates(arrSeed(i-1)(j)),Rhino.PointCoordinates(arrSeed(i)(j*2+y)))
' Call Rhino.ObjectColor(strLine, RGB(255-255/dblGen*z,0,255/dblGen*z))
'End If
Next
Next

'recordn data of individual branches
For j=0 To ubound(arrSeed(i-1))
For y=0 To dblBrN-1
a=-1
'defining votes for branches generated from different seeds
For k=0 To ubound(arrSeed(i-1))
If int(k/(dblBrN^(i-1)))<>int(j/(dblBrN^(i-1))) Then
For m=0 To dblBrN-1
a=a+1
ReDim Preserve arrVote(a), arrDis(a+1)
'defining a vote for element efficiency
arrVote(a)=(Rhino.Distance(PointCoordinates(arrSeed(i-1)(j)),Rhino.PointCoordinates(arrSeed(i-1)(k)))-Rhino.Distance(Rhino.PointCoordinates(arrSeed(i)(j*(dblBrN)+y)),Rhino.PointCoordinates(arrSeed(i-1)(k))))
'recording distance from detected points
arrDist(a)=Rhino.Distance(PointCoordinates(arrSeed(i-1)(j)),Rhino.PointCoordinates(arrSeed(i-1)(k)))
Next
End If
Next
dblVote=Rhino.Max(arrVote)

'recording dist for nearest point
For k=0 To ubound(arrVote)
If arrVote(k)=dblVote Then
arrDist(a+1)=arrDist(k)
End If
Next

'recording data about the new element
If dblVote>arrData(i)(j*(dblBrN)+y)(0) Then
arrData(i)(j*(dblBrN)+y)(0)=dblVote
arrData(i)(j*(dblBrN)+y)(1)=arrData(i)(j*(dblBrN)+y)(2)
arrData(i)(j*(dblBrN)+y)(3)=arrDist(a+1)
End If
Next
Next

Next
For i=1 To dblBranch
Call Rhino.DeleteObjects(arrSeed(i))
Next

Next
Call Rhino.LayerVisible(strL1,False)
Call Rhino.EnableRedraw(True)
Call Rhino.Print("100%")

End Sub

39 comments:

  1. 看看blog調整心情,又要來繼續工作,大家加油........................................

    ReplyDelete
  2. Never put both feet in your mouth at the same time, because then you will not have a leg to stand on.............................................

    ReplyDelete
  3. 開懷幸福的生活,是每個人的夢想~~希望大家都能夠實現!..............................

    ReplyDelete
  4. 生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。....................................................................

    ReplyDelete
  5. 文章是心情的反應~~祝妳天天寫的都是讓人開心的好文章哦!!............................................................

    ReplyDelete
  6. 最敏捷的,未必贏得競賽:最強大的,未必贏得戰爭:時間與機會才是主人................................................

    ReplyDelete
  7. 河水永遠是相同的,可是每一剎那又都是新的。. . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ReplyDelete
  8. 在莫非定律中有項笨蛋定律:「一個組織中的笨蛋,恆大於等於三分之二。」. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ReplyDelete
  9. 一時的錯誤不算什麼,錯而不改才是一生中永遠且最大的錯誤..................................................

    ReplyDelete
  10. Judge not a book by its cover.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ReplyDelete
  11. 死亡是悲哀的,但活得不快樂更悲哀。. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ReplyDelete