<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cellular-automata-from-first-principles examples on Programmer.ie: Modern AI programming</title>
		<link>http://programmer.ie/examples/cellular-automata-from-first-principles/</link>
		<description>Recent content in cellular-automata-from-first-principles examples on Programmer.ie: Modern AI programming</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
		
			<atom:link href="http://programmer.ie/examples/cellular-automata-from-first-principles/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>One rule, one row, and a step that never mixes time</title>
				<link>http://programmer.ie/examples/cellular-automata-from-first-principles/02-chapter/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>http://programmer.ie/examples/cellular-automata-from-first-principles/02-chapter/</guid>
				<description>&lt;p&gt;A cellular automaton is four things: space, state, neighborhood, rule. This&#xA;chapter takes the smallest version of that list. One row of 41 cells on a ring,&#xA;each cell empty or active, and one local rule: a cell becomes active when&#xA;exactly one of its three neighborhood cells is active.&lt;/p&gt;&#xA;&lt;p&gt;The program below is that automaton and nothing else. It prints the world as&#xA;text, one row per generation, so the space-time diagram can be read without a&#xA;plotting library. Rows are time, columns are space, and the row wraps: a&#xA;pattern leaving the right edge reappears on the left.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Count the neighbors, then decide</title>
				<link>http://programmer.ie/examples/cellular-automata-from-first-principles/06-chapter/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>http://programmer.ie/examples/cellular-automata-from-first-principles/06-chapter/</guid>
				<description>&lt;p&gt;Conway&amp;rsquo;s Game of Life is the same machinery as the one-dimensional rules with a&#xA;larger lookup: a two-dimensional grid, two states, the Moore neighborhood, and&#xA;one local rule. The rule is usually written B3/S23: a dead cell is born with&#xA;exactly 3 live neighbors, and a live cell survives with 2 or 3. Every cell&amp;rsquo;s&#xA;fate depends on nine bits rather than three.&lt;/p&gt;&#xA;&lt;p&gt;The program below seeds the chapter&amp;rsquo;s blinker, counts neighbors with eight&#xA;array rolls, applies B3/S23, and prints the region around the pattern as text.&#xA;Four generations are enough to show the whole cycle.&lt;/p&gt;</description>
			</item>
			<item>
				<title>A car moves only when the road ahead is empty</title>
				<link>http://programmer.ie/examples/cellular-automata-from-first-principles/11-chapter/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>http://programmer.ie/examples/cellular-automata-from-first-principles/11-chapter/</guid>
				<description>&lt;p&gt;Rule 184 is a one-dimensional ring road where &lt;code&gt;1&lt;/code&gt; is a car and &lt;code&gt;0&lt;/code&gt; is empty&#xA;road, and the whole rule is one sentence: a car moves one cell to the right&#xA;when the cell ahead is empty. Nothing about lanes, speeds, queues or&#xA;congestion is written down.&lt;/p&gt;&#xA;&lt;p&gt;This program runs that rule: it prints the road before and after ten steps,&#xA;checks that the car count has not changed, and sweeps the density to measure&#xA;how much traffic actually moves.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Diffusion is only nearest-neighbor exchange</title>
				<link>http://programmer.ie/examples/cellular-automata-from-first-principles/12-chapter/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>http://programmer.ie/examples/cellular-automata-from-first-principles/12-chapter/</guid>
				<description>&lt;p&gt;Until now every cell has stored a discrete state: empty or active, road or car,&#xA;tree or fire. This chapter changes the cell to hold a continuous quantity and&#xA;the transition to local exchange. The state is a concentration, and the update&#xA;is the difference between a cell and its nearest neighbors.&lt;/p&gt;&#xA;&lt;p&gt;The program below starts with all the concentration in one cell, spreads it&#xA;with a four-neighbor Laplacian, checks that the total did not change, and&#xA;measures how far it traveled.&lt;/p&gt;</description>
			</item>
			<item>
				<title>One Python loop against eight array rolls</title>
				<link>http://programmer.ie/examples/cellular-automata-from-first-principles/51-chapter/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>http://programmer.ie/examples/cellular-automata-from-first-principles/51-chapter/</guid>
				<description>&lt;p&gt;A cellular automaton is local, and that does not mean it should be updated&#xA;cell by cell in Python. For a dense grid the same local rule is applied&#xA;everywhere, and that regularity is what array programming is good at.&lt;/p&gt;&#xA;&lt;p&gt;This program runs both versions on the same random grid and asserts that they&#xA;agree exactly: reference first, speed second, and the proof is the assertion.&lt;/p&gt;&#xA;&lt;h2 id=&#34;run-it&#34;&gt;Run it&lt;/h2&gt;&#xA;&lt;p&gt;Save this as &lt;code&gt;vectorize.py&lt;/code&gt; and run it with Python 3.11 or later. It needs&#xA;NumPy only.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Pad first, roll second, transform third</title>
				<link>http://programmer.ie/examples/cellular-automata-from-first-principles/53-chapter/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>http://programmer.ie/examples/cellular-automata-from-first-principles/53-chapter/</guid>
				<description>&lt;p&gt;For a periodic domain, convolution in space is multiplication in frequency. The&#xA;catch is that the kernel&amp;rsquo;s center has to sit at the array origin first, which&#xA;is where the FFT bug in this book lived. This program convolves a random&#xA;field with a 7 by 7 Gaussian bump three ways: the centered construction, the&#xA;naive &lt;code&gt;fft2&lt;/code&gt; of the raw kernel, and &lt;code&gt;ifftshift&lt;/code&gt; before padding.&lt;/p&gt;&#xA;&lt;h2 id=&#34;run-it&#34;&gt;Run it&lt;/h2&gt;&#xA;&lt;p&gt;Save this as &lt;code&gt;fft_neighborhood.py&lt;/code&gt; and run it with Python 3.11 or later. It&#xA;needs NumPy only.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
