-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from nhartland/dev
v0.3
- Loading branch information
Showing
34 changed files
with
884 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||
<head> | ||
<title>forma Reference</title> | ||
<link rel="stylesheet" href="../ldoc.css" type="text/css" /> | ||
</head> | ||
<body> | ||
|
||
<div id="container"> | ||
|
||
<div id="product"> | ||
<div id="product_logo"></div> | ||
<div id="product_name"><big><b></b></big></div> | ||
<div id="product_description"></div> | ||
</div> <!-- id="product" --> | ||
|
||
|
||
<div id="main"> | ||
|
||
|
||
<!-- Menu --> | ||
|
||
<div id="navigation"> | ||
<br/> | ||
<h1>forma</h1> | ||
|
||
<ul> | ||
<li><a href="../contents.html">Index</a></li> | ||
</ul> | ||
|
||
|
||
|
||
<h2>Examples</h2> | ||
<ul class="nowrap"> | ||
<li><a href="../examples/async_automata.lua.html">async_automata.lua</a></li> | ||
<li><a href="../examples/binary_space_partition.lua.html">binary_space_partition.lua</a></li> | ||
<li><a href="../examples/bubbles.lua.html">bubbles.lua</a></li> | ||
<li><a href="../examples/cellular_automata.lua.html">cellular_automata.lua</a></li> | ||
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li> | ||
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li> | ||
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li> | ||
<li><strong>readme.lua</strong></li> | ||
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li> | ||
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li> | ||
</ul> | ||
<h2>Modules</h2> | ||
<ul class="nowrap"> | ||
<li><a href="../modules/forma.cell.html">forma.cell</a></li> | ||
<li><a href="../modules/forma.pattern.html">forma.pattern</a></li> | ||
<li><a href="../modules/forma.primitives.html">forma.primitives</a></li> | ||
<li><a href="../modules/forma.subpattern.html">forma.subpattern</a></li> | ||
<li><a href="../modules/forma.automata.html">forma.automata</a></li> | ||
<li><a href="../modules/forma.neighbourhood.html">forma.neighbourhood</a></li> | ||
</ul> | ||
<h2>Readme</h2> | ||
<ul class="nowrap"> | ||
<li><a href="../readme/README.md.html">README</a></li> | ||
</ul> | ||
|
||
</div> | ||
|
||
<div id="content"> | ||
|
||
<h2>readme.lua</h2> | ||
<pre> | ||
<span class="comment">-- Readme example | ||
</span><span class="comment">-- This generates the example used in the readme. Runs a 4-5 rule CA for 'cave | ||
</span><span class="comment">-- generation and then computes the contiguous sub-patterns and prints them. | ||
</span> | ||
<span class="comment">-- Load forma modules, lazy init is also available, i.e | ||
</span><span class="comment">-- require('forma') | ||
</span><span class="keyword">local</span> primitives = <span class="global">require</span>(<span class="string">'forma.primitives'</span>) | ||
<span class="keyword">local</span> subpattern = <span class="global">require</span>(<span class="string">'forma.subpattern'</span>) | ||
<span class="keyword">local</span> automata = <span class="global">require</span>(<span class="string">'forma.automata'</span>) | ||
<span class="keyword">local</span> neighbourhood = <span class="global">require</span>(<span class="string">'forma.neighbourhood'</span>) | ||
|
||
<span class="comment">-- Generate a square box to run the CA inside | ||
</span><span class="keyword">local</span> domain = primitives.square(<span class="number">80</span>,<span class="number">20</span>) | ||
|
||
<span class="comment">-- CA initial condition: 800-point random sample of the domain | ||
</span><span class="keyword">local</span> ca = subpattern.random(domain, <span class="number">800</span>) | ||
|
||
<span class="comment">-- Moore (8-cell) neighbourhood 4-5 rule | ||
</span><span class="keyword">local</span> moore = automata.rule(neighbourhood.moore(), <span class="string">"B5678/S45678"</span>) | ||
|
||
<span class="comment">-- Run the CA until converged or 1000 iterations | ||
</span><span class="keyword">local</span> ite, converged = <span class="number">0</span>, <span class="keyword">false</span> | ||
<span class="keyword">while</span> converged == <span class="keyword">false</span> <span class="keyword">and</span> ite < <span class="number">1000</span> <span class="keyword">do</span> | ||
ca, converged = automata.iterate(ca, domain, {moore}) | ||
ite = ite+<span class="number">1</span> | ||
<span class="keyword">end</span> | ||
|
||
<span class="comment">-- Access a subpattern's cell coordinates for external use | ||
</span><span class="keyword">for</span> icell <span class="keyword">in</span> ca:cells() <span class="keyword">do</span> | ||
<span class="comment">-- local foo = bar(icell) | ||
</span> <span class="comment">-- or | ||
</span> <span class="comment">-- local foo = bar(icell.x, icell.y) | ||
</span><span class="keyword">end</span> | ||
|
||
<span class="comment">-- Find all 4-contiguous segments of the CA pattern | ||
</span><span class="comment">-- Uses the von-neumann neighbourhood to determine 'connectedness' | ||
</span><span class="comment">-- but any custom neighbourhood can be used) | ||
</span><span class="keyword">local</span> segments = subpattern.segments(ca, neighbourhood.von_neumann()) | ||
|
||
<span class="comment">-- Print a representation to io.output | ||
</span>subpattern.print_patterns(domain, segments)</pre> | ||
|
||
|
||
</div> <!-- id="content" --> | ||
</div> <!-- id="main" --> | ||
<div id="about"> | ||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> | ||
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i> | ||
</div> <!-- id="about" --> | ||
</div> <!-- id="container" --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.