SlideShare a Scribd company logo
1 of 43
Activity:
“Figuring with Algorithms”
Using Context Free Art Generator to figure out patterns of behaviour
Design grammars are sets of very simple non-
deterministic rules to produce images.
Context Free is a graphical environment for editing,
rendering, and exploring CFDG.
John HoriganChris Coyne Mark Lentczner
startshape startclouds
background { b -0.1 h 220 sat 0.75 }
rule startclouds {
3* { x 1 } startcloud { a -1 }
}
rule startcloud {
side { y -0.5 }
}
rule startcloud {
side { y 0.5 }
}
rule cloud {
step { }
horiz { s 0.7 }
side { }
}
rule side {
step { }
cloud { x -1 a 0.0005 s 0.99 }
}
rule side {
step { }
cloud { x 1 a 0.001 s 0.99 }
}
rule horiz {
step { }
rotatecloud { y -1 }
}
rule side {}
rule horiz {
step { }
rotatecloud { y 1 }
}
rule rotatecloud {
cloud { r 15 }
}
rule rotatecloud {
cloud { r -15 }
}
rule step {
SQUARE { b 1 }
}
rule step {
CIRCLE { b 1 }
}
Start with a root symbol/shape (the startshape) and use grammar
rules to elaborate this into a sentence of symbols/shapes.
When Context Free draws a shape it remembers some state
information for the shape (colour, xyz position, size, rotation). To
draw the shape Context Free evaluates a rule for the shape and
replaces the shape with the shapes listed in the rule. The state for
these replacement shapes is relative to the state of the parent
shape.
https://www.contextfreeart.org/gallery/search.php?by=lazymoon
https://www.contextfreeart.org/gallery/search.php?by=lazymoon
https://www.contextfreeart.org/gallery/search.php?by=lagroue
https://www.contextfreeart.org/gallery/search.php?by=Guigui
https://www.contextfreeart.org/gallery/search.php?by=Guigui
https://www.contextfreeart.org/gallery/search.php?by=craftycurate
https://www.contextfreeart.org/gallery/search.php?by=benjy
https://www.contextfreeart.org/gallery/search.php?by=bluesky
https://www.contextfreeart.org/gallery/search.php?by=bluesky
https://www.contextfreeart.org/gallery/search.php?by=chris
https://www.contextfreeart.org/gallery/view.php?id=2592
https://www.contextfreeart.org/gallery/view.php?id=697
https://www.contextfreeart.org/gallery/view.php?id=3215
Start with a simple example
Copy and Paste into Context Free Art and hit Ctrl + R (Render)
startshape tree
shape tree
rule {
SQUARE []
tree [ s .99 r 2 y .995]
}
rule 33 {
SQUARE []
tree [ s .99 r 2 y .995 flip 90]
}
rule {
SQUARE []
tree [[ s .5 r 10 y .995 b .07 z -.07 ]]
tree [ s .99 y .995 flip 90 ]
tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]]
}
rule 3 {
SQUARE []
tree [[ sat 0.5 b 0.1 s .8 r 10 y .995 b .01 z -.001]]
tree [[ sat 0.5 b 0.1 s .8 flip 90 r 10 y .995 b .01 z -.001]]
}
startshape tree
shape tree
rule {
SQUARE []
tree [ s .99 r 2 y .995]
}
rule 33 {
SQUARE []
tree [ s .99 r 2 y .995 flip 90]
}
rule {
SQUARE []
tree [[ s .5 r 10 y .995 b .07 z -.07 ]]
tree [ s .99 y .995 flip 90 ]
tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]]
}
rule 3 {
SQUARE []
tree [[ hue 30 sat 0.5 b 0.1 s .8 r 10 y .995 b .01 z -.001]]
tree [[ hue 30 sat 0.5 b 0.1 s .8 flip 90 r 10 y .995 b .01 z -.001]]
}
Using colour to figure out what rules generate trunk,
main and secondary branches
startshape tree
shape tree
rule {
SQUARE []
tree [ hue 30 sat 0.5 b 0.1 s .99 r 2 y .995]
}
rule 33 {
SQUARE []
tree [ hue 30 sat 0.5 b 0.1 s .99 r 2 y .995 flip 90]
}
rule {
SQUARE []
tree [[ s .5 r 10 y .995 b .07 z -.07 ]]
tree [ s .99 y .995 flip 90 ]
tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]]
}
rule 3 {
SQUARE []
tree [[ s .8 r 10 y .995 b .01 z -.001]]
tree [[ s .8 flip 90 r 10 y .995 b .01 z -.001]]
}
Using colour to figure out what rules generate trunk,
main and secondary branches
startshape tree
shape tree
rule {
SQUARE []
tree [ s .99 r 2 y .995]
}
rule 33 {
SQUARE []
tree [ s .99 r 2 y .995 flip 90]
}
First two rules generate thick, mainly vertical
arrangement of squares: ‘trunk’
startshape tree
shape tree
rule {
SQUARE []
tree [ s .99 r 2 y .995]
}
rule {
SQUARE []
tree [ s .99 r 2 y .995 flip 90]
}
Change the odds for each rule to trigger to see effects
in the type of trunks generated
startshape tree
shape tree
rule {
SQUARE []
tree [ s .99 r 2 y .995]
}
rule 33 {
SQUARE []
tree [ s .99 r 2 y .995 flip 90]
}
Second rule is called 33x more than the first rule
startshape tree
shape tree
rule {
SQUARE []
tree [ s .99 r 2 y .995]
}
rule 33 {
SQUARE []
tree [ s .99 r 2 y .995 flip 90]
}
rule {
SQUARE []
tree [[ s .5 r 10 y .995 b .07 z -.07 ]]
tree [ s .99 y .995 flip 90 ]
tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]]
}
rule 3 {
SQUARE []
tree [[ sat 0.5 b 0.1 s .8 r 10 y .995 b .01 z -.001]]
tree [[ sat 0.5 b 0.1 s .8 flip 90 r 10 y .995 b .01 z -.001]]
}
Play with the third and fourth rules to see branching
effects. Remember to “Render” a few times to see
variations due to randomness
First… some mechanics
(It’s way easier than you may have been led to believe)
startshape PLANT
shape PLANT {
CIRCLE [ ]
}
Starting point:
This code draws a simple black circle,
we arbitrarily call the function “PLANT”:
startshape PLANT
shape PLANT {
BL [ h 10 sat 1 b 1 ]
}
shape BL {
CIRCLE [ ]
}
Two changes:
1. The “CIRCLE” definition moved to a function that we call “BL”
2. Shape parameters are sent when invoking BL:
a) hue 10
b) saturation 1
c) brightness 1
startshape PLANT
shape PLANT {
BL [ h 10 sat 1 b 1 ]
}
shape BL {
CIRCLE [ ]
BL [size (0.95) y 1 ]
}
Recursion:
We introduce an operation after the CIRCLE, which
the program applies in a loop (until the shapes are
too small to be rendered, then it stops).
The new line is effectively, updating itself (shape BL)
scaling down its size and moving in the y axis 1 unit
up
startshape PLANT
shape PLANT {
BL [ h 10 sat 1 b 1 ]
}
shape BL {
CIRCLE [ ]
BL [size (0.95) y 1 x 1 ]
}
Recursion:
Now each new shape is moved one unit up and one
unit right on every step
startshape PLANT
shape PLANT {
BL [ h 10 sat 1 b 1 ]
}
shape BL
rule {
CIRCLE [ ]
BL [size (0.95) y 1 x 1]
}
Randomness:
This is exactly the same code as before, it just shows
that shapes can have more than one operations, i.e.,
“rules”. Here BL has a single rule, the same as the
previous step
startshape PLANT
shape PLANT {
BL [ h 10 sat 1 b 1 ]
}
shape BL
rule {
CIRCLE [ ]
BL [size (0.95) y 1 ]
}
rule {
CIRCLE [ ]
BL [size (0.95) x 1 ]
}
Randomness: Now the fun begins: randomness. When two rules
are defined for a shape, then the software chooses
randomly only one of them to execute. The results
start being a bit unpredictable…
startshape PLANT
shape PLANT {
BL [ h 10 sat 1 b 1 ]
}
shape BL
rule {
CIRCLE [ ]
BL [ rotate randint(0, 8) size (0.95) y 1 ]
}
rule {
CIRCLE [ ]
BL [ rotate randint(0, 8) size (0.95) x 1 ]
}
More randomness: Now we also add a random rotation (an integer
value between 0 and 8), so every time that the code
is executed, it renders a slightly different image:
overall the same logic, but with the specific details
different every time.
startshape PLANT
shape PLANT {
BL [ sat 1 b 1 ]
}
shape BL
rule {
CIRCLE [ ]
BL [ h randint(0, 360) rotate randint(0, 8) size (0.95) y 1 ]
}
rule {
CIRCLE [ ]
BL [ h randint(0, 360) rotate randint(0, 8) size (0.95) x 1 ]
}
Even more randomness:
We take the hue parameter out from the BL
definition in “shape PLANT” and make it random too
every time BL is called in a rule.
But now the code is getting “messy” and things are
duplicated… let’s do some cleaning next
startshape PLANT
shape PLANT {
BL [ sat 1 b 1 ]
}
shape BL {
CIRCLE [ ]
WL [ size (0.985) y 1 ]
}
shape WL
rule { BL [ h randint(0, 360) rotate randint(0, 8)] }
Recursion between shapes:
Compare the code with the previous version. Shape
BL now declares a circle and calls shape WL with a
change in size and location in y axis
And shape WL has one rule where it calls shape BL
with a change in hue and rotation. The program
continues with this recursive loop until it can’t
render new shapes because they are too small
startshape PLANT
shape PLANT {
BL [ sat 1 b 1 ]
}
shape BL {
CIRCLE [ ]
WL [ size (0.985) y 1 ]
}
shape WL
rule 50 { BL [ h randint(0, 360) rotate randint(0, 8)] }
rule { BRANCH [] }
shape BRANCH {
BL [ rotate 1 flip 90]
BL [ rotate -1 flip 90]
}
Recursion between shapes: The advantage of separating and calling shapes
recursively, is that we can create routines with
several rules, each with a “weight” or probability of
being chosen and executed.
This is how the shape BRANCH looks, and we add a
weight of 50 to the rule that calls shape BL.
Now every instance looks quite different! (within a
shared generative grammar)
Download and install: https://www.contextfreeart.org
To Do:
- Play with the code
- Document and share your results in your blog
Credits:
Chris Coyne designed the CFDG grammar and wrote the original command-line version.
Mark Lentczner saw Chris' site and decided he had to have an interactive version. He is responsible for the Macintosh version.
John Horigan got sucked into this project and it immediately ate all of his spare time. He wrote the Windows version. Mark and John
jointly maintain the common code base and the Posix/Unix version.
Activity: Figuring with Algorithms 2020

More Related Content

Similar to Activity: Figuring with Algorithms 2020

2012 University of Dayton .docx
2012   University of Dayton                   .docx2012   University of Dayton                   .docx
2012 University of Dayton .docx
eugeniadean34240
 
Rpartii 131126003007-phpapp01
Rpartii 131126003007-phpapp01Rpartii 131126003007-phpapp01
Rpartii 131126003007-phpapp01
Sunil0108
 
Basic Control System unit6
Basic Control System unit6Basic Control System unit6
Basic Control System unit6
Asraf Malik
 
WRI Sales Compensation Plan
WRI Sales Compensation PlanWRI Sales Compensation Plan
WRI Sales Compensation Plan
Scott Pickering
 

Similar to Activity: Figuring with Algorithms 2020 (20)

2012 University of Dayton .docx
2012   University of Dayton                   .docx2012   University of Dayton                   .docx
2012 University of Dayton .docx
 
Relatório
RelatórioRelatório
Relatório
 
R part II
R part IIR part II
R part II
 
Rpartii 131126003007-phpapp01
Rpartii 131126003007-phpapp01Rpartii 131126003007-phpapp01
Rpartii 131126003007-phpapp01
 
Shaped blade centeress_grinding_v0
Shaped blade centeress_grinding_v0Shaped blade centeress_grinding_v0
Shaped blade centeress_grinding_v0
 
Row Pattern Matching 12c MATCH_RECOGNIZE OOW14
Row Pattern Matching 12c MATCH_RECOGNIZE OOW14Row Pattern Matching 12c MATCH_RECOGNIZE OOW14
Row Pattern Matching 12c MATCH_RECOGNIZE OOW14
 
Different Types of Machine Learning Algorithms
Different Types of Machine Learning AlgorithmsDifferent Types of Machine Learning Algorithms
Different Types of Machine Learning Algorithms
 
Numerical Investigation of Aerodynamic Performance of H-Rotor Darrieus Wind T...
Numerical Investigation of Aerodynamic Performance of H-Rotor Darrieus Wind T...Numerical Investigation of Aerodynamic Performance of H-Rotor Darrieus Wind T...
Numerical Investigation of Aerodynamic Performance of H-Rotor Darrieus Wind T...
 
130070119095_2151908
130070119095_2151908130070119095_2151908
130070119095_2151908
 
Autocad electrical
Autocad electricalAutocad electrical
Autocad electrical
 
Electrical engg material
Electrical engg material Electrical engg material
Electrical engg material
 
R Programming Homework Help
R Programming Homework HelpR Programming Homework Help
R Programming Homework Help
 
Basic Control System unit6
Basic Control System unit6Basic Control System unit6
Basic Control System unit6
 
Bode
BodeBode
Bode
 
BALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptxBALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptx
 
WRI Sales Compensation Plan
WRI Sales Compensation PlanWRI Sales Compensation Plan
WRI Sales Compensation Plan
 
Project ppt 18 june.pptx
Project ppt 18 june.pptxProject ppt 18 june.pptx
Project ppt 18 june.pptx
 
s1233587_Report
s1233587_Reports1233587_Report
s1233587_Report
 
General pipeline concepts
General pipeline conceptsGeneral pipeline concepts
General pipeline concepts
 
Oracle SQL Model Clause
Oracle SQL Model ClauseOracle SQL Model Clause
Oracle SQL Model Clause
 

More from R. Sosa

More from R. Sosa (20)

Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
 
Week 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo SosaWeek 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo Sosa
 
Causation
CausationCausation
Causation
 
100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN
 
Edgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideasEdgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideas
 
USYD Virtual Design lecture
USYD Virtual Design lectureUSYD Virtual Design lecture
USYD Virtual Design lecture
 
Design School Confidential Class Projects
Design School Confidential Class ProjectsDesign School Confidential Class Projects
Design School Confidential Class Projects
 
La Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio RamonetLa Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio Ramonet
 
Apocalípticos e Integrados
Apocalípticos e IntegradosApocalípticos e Integrados
Apocalípticos e Integrados
 
Understanding Computers and Cognition
Understanding Computers and CognitionUnderstanding Computers and Cognition
Understanding Computers and Cognition
 
Convivial Toolbox
Convivial ToolboxConvivial Toolbox
Convivial Toolbox
 
Brecht on Theatre.pdf
Brecht on Theatre.pdfBrecht on Theatre.pdf
Brecht on Theatre.pdf
 
Simulation (or Computation) and its Discontents
Simulation (or Computation) and its DiscontentsSimulation (or Computation) and its Discontents
Simulation (or Computation) and its Discontents
 
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdf
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdfGui Bonsiepe: Las Siete Columnas del Diseño_.pdf
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdf
 
The Invention of Creativity by Reckwitz.pdf
The Invention of Creativity by Reckwitz.pdfThe Invention of Creativity by Reckwitz.pdf
The Invention of Creativity by Reckwitz.pdf
 
Write your Thesis using AI
Write your Thesis using AIWrite your Thesis using AI
Write your Thesis using AI
 
Tikanga Māori
Tikanga MāoriTikanga Māori
Tikanga Māori
 
The richness of life, Stephen Jay Gould
The richness of life, Stephen Jay GouldThe richness of life, Stephen Jay Gould
The richness of life, Stephen Jay Gould
 
Las Ideas Estéticas de Marx.pdf
Las Ideas Estéticas de Marx.pdfLas Ideas Estéticas de Marx.pdf
Las Ideas Estéticas de Marx.pdf
 
Māori Philosophies
Māori PhilosophiesMāori Philosophies
Māori Philosophies
 

Recently uploaded

In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in RiyadhIn Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
ahmedjiabur940
 
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
awasv46j
 
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
khuurq8kz
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
eqaqen
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
mark11275
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
eeanqy
 
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
drmarathore
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
wpkuukw
 

Recently uploaded (20)

Spring Summer 2026 Inspirations trend book Peclers Paris
Spring Summer 2026 Inspirations trend book Peclers ParisSpring Summer 2026 Inspirations trend book Peclers Paris
Spring Summer 2026 Inspirations trend book Peclers Paris
 
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in RiyadhIn Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
 
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
 
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
 
Redefining Affordable Housing in Gurgaon The Role of Housing Architects from ...
Redefining Affordable Housing in Gurgaon The Role of Housing Architects from ...Redefining Affordable Housing in Gurgaon The Role of Housing Architects from ...
Redefining Affordable Housing in Gurgaon The Role of Housing Architects from ...
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptx
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
 
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
Essential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideEssential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive Guide
 
Academic Portfolio (2017-2021) .pdf
Academic Portfolio (2017-2021)      .pdfAcademic Portfolio (2017-2021)      .pdf
Academic Portfolio (2017-2021) .pdf
 
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
 
Morgenbooster: Storytelling in Identity Design
Morgenbooster: Storytelling in Identity DesignMorgenbooster: Storytelling in Identity Design
Morgenbooster: Storytelling in Identity Design
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
 
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
18+ Young ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Girl Serviℂ...
18+ Young ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Girl Serviℂ...18+ Young ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Girl Serviℂ...
18+ Young ℂall Girls Vadodara Book Esha 7427069034 Top Class ℂall Girl Serviℂ...
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
 

Activity: Figuring with Algorithms 2020

  • 1. Activity: “Figuring with Algorithms” Using Context Free Art Generator to figure out patterns of behaviour
  • 2. Design grammars are sets of very simple non- deterministic rules to produce images. Context Free is a graphical environment for editing, rendering, and exploring CFDG. John HoriganChris Coyne Mark Lentczner
  • 3. startshape startclouds background { b -0.1 h 220 sat 0.75 } rule startclouds { 3* { x 1 } startcloud { a -1 } } rule startcloud { side { y -0.5 } } rule startcloud { side { y 0.5 } } rule cloud { step { } horiz { s 0.7 } side { } } rule side { step { } cloud { x -1 a 0.0005 s 0.99 } } rule side { step { } cloud { x 1 a 0.001 s 0.99 } } rule horiz { step { } rotatecloud { y -1 } } rule side {} rule horiz { step { } rotatecloud { y 1 } } rule rotatecloud { cloud { r 15 } } rule rotatecloud { cloud { r -15 } } rule step { SQUARE { b 1 } } rule step { CIRCLE { b 1 } }
  • 4. Start with a root symbol/shape (the startshape) and use grammar rules to elaborate this into a sentence of symbols/shapes. When Context Free draws a shape it remembers some state information for the shape (colour, xyz position, size, rotation). To draw the shape Context Free evaluates a rule for the shape and replaces the shape with the shapes listed in the rule. The state for these replacement shapes is relative to the state of the parent shape.
  • 9.
  • 10.
  • 11.
  • 12.
  • 22. Start with a simple example Copy and Paste into Context Free Art and hit Ctrl + R (Render)
  • 23. startshape tree shape tree rule { SQUARE [] tree [ s .99 r 2 y .995] } rule 33 { SQUARE [] tree [ s .99 r 2 y .995 flip 90] } rule { SQUARE [] tree [[ s .5 r 10 y .995 b .07 z -.07 ]] tree [ s .99 y .995 flip 90 ] tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]] } rule 3 { SQUARE [] tree [[ sat 0.5 b 0.1 s .8 r 10 y .995 b .01 z -.001]] tree [[ sat 0.5 b 0.1 s .8 flip 90 r 10 y .995 b .01 z -.001]] }
  • 24.
  • 25. startshape tree shape tree rule { SQUARE [] tree [ s .99 r 2 y .995] } rule 33 { SQUARE [] tree [ s .99 r 2 y .995 flip 90] } rule { SQUARE [] tree [[ s .5 r 10 y .995 b .07 z -.07 ]] tree [ s .99 y .995 flip 90 ] tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]] } rule 3 { SQUARE [] tree [[ hue 30 sat 0.5 b 0.1 s .8 r 10 y .995 b .01 z -.001]] tree [[ hue 30 sat 0.5 b 0.1 s .8 flip 90 r 10 y .995 b .01 z -.001]] } Using colour to figure out what rules generate trunk, main and secondary branches
  • 26. startshape tree shape tree rule { SQUARE [] tree [ hue 30 sat 0.5 b 0.1 s .99 r 2 y .995] } rule 33 { SQUARE [] tree [ hue 30 sat 0.5 b 0.1 s .99 r 2 y .995 flip 90] } rule { SQUARE [] tree [[ s .5 r 10 y .995 b .07 z -.07 ]] tree [ s .99 y .995 flip 90 ] tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]] } rule 3 { SQUARE [] tree [[ s .8 r 10 y .995 b .01 z -.001]] tree [[ s .8 flip 90 r 10 y .995 b .01 z -.001]] } Using colour to figure out what rules generate trunk, main and secondary branches
  • 27. startshape tree shape tree rule { SQUARE [] tree [ s .99 r 2 y .995] } rule 33 { SQUARE [] tree [ s .99 r 2 y .995 flip 90] } First two rules generate thick, mainly vertical arrangement of squares: ‘trunk’
  • 28. startshape tree shape tree rule { SQUARE [] tree [ s .99 r 2 y .995] } rule { SQUARE [] tree [ s .99 r 2 y .995 flip 90] } Change the odds for each rule to trigger to see effects in the type of trunks generated
  • 29. startshape tree shape tree rule { SQUARE [] tree [ s .99 r 2 y .995] } rule 33 { SQUARE [] tree [ s .99 r 2 y .995 flip 90] } Second rule is called 33x more than the first rule
  • 30. startshape tree shape tree rule { SQUARE [] tree [ s .99 r 2 y .995] } rule 33 { SQUARE [] tree [ s .99 r 2 y .995 flip 90] } rule { SQUARE [] tree [[ s .5 r 10 y .995 b .07 z -.07 ]] tree [ s .99 y .995 flip 90 ] tree [[ s .5 flip 90 r 10 y .995 b .07 z -.07]] } rule 3 { SQUARE [] tree [[ sat 0.5 b 0.1 s .8 r 10 y .995 b .01 z -.001]] tree [[ sat 0.5 b 0.1 s .8 flip 90 r 10 y .995 b .01 z -.001]] } Play with the third and fourth rules to see branching effects. Remember to “Render” a few times to see variations due to randomness
  • 31. First… some mechanics (It’s way easier than you may have been led to believe)
  • 32. startshape PLANT shape PLANT { CIRCLE [ ] } Starting point: This code draws a simple black circle, we arbitrarily call the function “PLANT”:
  • 33. startshape PLANT shape PLANT { BL [ h 10 sat 1 b 1 ] } shape BL { CIRCLE [ ] } Two changes: 1. The “CIRCLE” definition moved to a function that we call “BL” 2. Shape parameters are sent when invoking BL: a) hue 10 b) saturation 1 c) brightness 1
  • 34. startshape PLANT shape PLANT { BL [ h 10 sat 1 b 1 ] } shape BL { CIRCLE [ ] BL [size (0.95) y 1 ] } Recursion: We introduce an operation after the CIRCLE, which the program applies in a loop (until the shapes are too small to be rendered, then it stops). The new line is effectively, updating itself (shape BL) scaling down its size and moving in the y axis 1 unit up
  • 35. startshape PLANT shape PLANT { BL [ h 10 sat 1 b 1 ] } shape BL { CIRCLE [ ] BL [size (0.95) y 1 x 1 ] } Recursion: Now each new shape is moved one unit up and one unit right on every step
  • 36. startshape PLANT shape PLANT { BL [ h 10 sat 1 b 1 ] } shape BL rule { CIRCLE [ ] BL [size (0.95) y 1 x 1] } Randomness: This is exactly the same code as before, it just shows that shapes can have more than one operations, i.e., “rules”. Here BL has a single rule, the same as the previous step
  • 37. startshape PLANT shape PLANT { BL [ h 10 sat 1 b 1 ] } shape BL rule { CIRCLE [ ] BL [size (0.95) y 1 ] } rule { CIRCLE [ ] BL [size (0.95) x 1 ] } Randomness: Now the fun begins: randomness. When two rules are defined for a shape, then the software chooses randomly only one of them to execute. The results start being a bit unpredictable…
  • 38. startshape PLANT shape PLANT { BL [ h 10 sat 1 b 1 ] } shape BL rule { CIRCLE [ ] BL [ rotate randint(0, 8) size (0.95) y 1 ] } rule { CIRCLE [ ] BL [ rotate randint(0, 8) size (0.95) x 1 ] } More randomness: Now we also add a random rotation (an integer value between 0 and 8), so every time that the code is executed, it renders a slightly different image: overall the same logic, but with the specific details different every time.
  • 39. startshape PLANT shape PLANT { BL [ sat 1 b 1 ] } shape BL rule { CIRCLE [ ] BL [ h randint(0, 360) rotate randint(0, 8) size (0.95) y 1 ] } rule { CIRCLE [ ] BL [ h randint(0, 360) rotate randint(0, 8) size (0.95) x 1 ] } Even more randomness: We take the hue parameter out from the BL definition in “shape PLANT” and make it random too every time BL is called in a rule. But now the code is getting “messy” and things are duplicated… let’s do some cleaning next
  • 40. startshape PLANT shape PLANT { BL [ sat 1 b 1 ] } shape BL { CIRCLE [ ] WL [ size (0.985) y 1 ] } shape WL rule { BL [ h randint(0, 360) rotate randint(0, 8)] } Recursion between shapes: Compare the code with the previous version. Shape BL now declares a circle and calls shape WL with a change in size and location in y axis And shape WL has one rule where it calls shape BL with a change in hue and rotation. The program continues with this recursive loop until it can’t render new shapes because they are too small
  • 41. startshape PLANT shape PLANT { BL [ sat 1 b 1 ] } shape BL { CIRCLE [ ] WL [ size (0.985) y 1 ] } shape WL rule 50 { BL [ h randint(0, 360) rotate randint(0, 8)] } rule { BRANCH [] } shape BRANCH { BL [ rotate 1 flip 90] BL [ rotate -1 flip 90] } Recursion between shapes: The advantage of separating and calling shapes recursively, is that we can create routines with several rules, each with a “weight” or probability of being chosen and executed. This is how the shape BRANCH looks, and we add a weight of 50 to the rule that calls shape BL. Now every instance looks quite different! (within a shared generative grammar)
  • 42. Download and install: https://www.contextfreeart.org To Do: - Play with the code - Document and share your results in your blog Credits: Chris Coyne designed the CFDG grammar and wrote the original command-line version. Mark Lentczner saw Chris' site and decided he had to have an interactive version. He is responsible for the Macintosh version. John Horigan got sucked into this project and it immediately ate all of his spare time. He wrote the Windows version. Mark and John jointly maintain the common code base and the Posix/Unix version.