<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ben Thompson &#187; doing &#8211; mirrors</title>
	<atom:link href="http://dm.ncl.ac.uk/benthompson/category/doing-mirrors/feed/" rel="self" type="application/rss+xml" />
	<link>http://dm.ncl.ac.uk/benthompson</link>
	<description>Digital Media</description>
	<lastBuildDate>Tue, 06 Sep 2011 11:11:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>well that wasn&#039;t supposed to happen&#8230;</title>
		<link>http://dm.ncl.ac.uk/benthompson/2010/03/17/well-that-wasnt-supposed-to-happen/</link>
		<comments>http://dm.ncl.ac.uk/benthompson/2010/03/17/well-that-wasnt-supposed-to-happen/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 12:11:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[doing - mirrors]]></category>

		<guid isPermaLink="false">http://dm.ncl.ac.uk/benthompson/?p=114</guid>
		<description><![CDATA[as it stands right now&#8230; (4 hours until exhibition time) &#8230;my processing sketch does not work as anticipated. this is down to two reasons - #1 in the example game of life the board start with well dispersed black and white squares like so&#8230; &#8230;however when you start the board with the live video foot [...]]]></description>
				<content:encoded><![CDATA[<p>as it stands right now&#8230; (4 hours until exhibition time) &#8230;my processing sketch does not work as anticipated. this is down to two reasons -</p>
<h1>#1</h1>
<p>in the example game of life the board start with well dispersed black and white squares like so&#8230;</p>
<p><img class="aligncenter size-full wp-image-115" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/Picture-8.png" alt="Picture 8" width="569" height="428" /></p>
<p>&#8230;however when you start the board with the live video foot age the black and white squares are clumped together like so&#8230;</p>
<p><img class="aligncenter size-full wp-image-117" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/Picture-9.png" alt="Picture 9" width="565" height="423" /></p>
<p>&#8230;the result of this is that the rules of the game still work but very few of the cells (pixels) survive beyond one generation.</p>
<h1>#2</h1>
<p>i get the impression that there is something not quite right in the code. for some reason only the top line of pixels is being affected by the game&#8230; even    though &#8220;printLn&#8221; is showing the results to be correct.</p>
<p>i am not entirely dissatisfied with the outcome, but it was not what i had anticipated. as oppose to &#8216;evolving&#8217; like this&#8230;..</p>
<p><img class="aligncenter size-full wp-image-120" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/Picture-4.png" alt="Picture 4" width="587" height="441" /></p>
<p>&#8230;it has taken on a more linear formation&#8230;.</p>
<p><img class="aligncenter size-full wp-image-121" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/Picture-1.png" alt="Picture 1" width="571" height="428" /></p>
<p>&#8230;this is not what i expected nor what was supposed to happen.</p>
<p>onwards and forwards!</p>
]]></content:encoded>
			<wfw:commentRss>http://dm.ncl.ac.uk/benthompson/2010/03/17/well-that-wasnt-supposed-to-happen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mirrors-game of life</title>
		<link>http://dm.ncl.ac.uk/benthompson/2010/03/10/mirrors-game-of-life/</link>
		<comments>http://dm.ncl.ac.uk/benthompson/2010/03/10/mirrors-game-of-life/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 12:29:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[doing - mirrors]]></category>

		<guid isPermaLink="false">http://dm.ncl.ac.uk/benthompson/?p=102</guid>
		<description><![CDATA[while playing around with processing, trying to learn the fundamentals (if/else/boolean/for/while/{}/arrays/etc.etc.etc) i hadn&#8217;t been giving much time to a concept behind the &#8216;mirrors&#8217; theme. i had been thinking of creating an evolving mirror or a degenerating mirror, something that related to fractal mathematics, maybe even horoscopes&#8230; then through experiments with logic sequences, attempting to change [...]]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-105" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/lifespinner1.jpg" alt="lifespinner" width="398" height="375" /></p>
<p>while playing around with processing, trying to learn the fundamentals (if/else/boolean/for/while/{}/arrays/etc.etc.etc) i hadn&#8217;t been giving much time to a concept behind the &#8216;mirrors&#8217; theme. i had been thinking of creating an evolving mirror or a degenerating mirror, something that related to fractal mathematics, maybe even horoscopes&#8230; then through experiments with logic sequences, attempting to change rectangle colours in relation to their position and the colour of their neighbours, i was introduced to &#8216;the game of life&#8217; (not the one pictured above, but the example featured below.)</p>
<p><img class="aligncenter size-full wp-image-107" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/Gospers_glider_gun.gif" alt="Gospers_glider_gun" width="250" height="180" /></p>
<p>explanation provided by the wikipedia entry&#8230;.</p>
<p>&#8220;The <strong>Game of Life</strong>, also known simply as <strong>Life</strong>, is a <a title="Cellular automaton" href="http://en.wikipedia.org/wiki/Cellular_automaton">cellular automaton</a> devised by the <a title="United Kingdom" href="http://en.wikipedia.org/wiki/United_Kingdom">British</a> <a title="Mathematician" href="http://en.wikipedia.org/wiki/Mathematician">mathematician</a> <a title="John Horton Conway" href="http://en.wikipedia.org/wiki/John_Horton_Conway">John Horton Conway</a> in 1970.<sup><a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#cite_note-0">[1]</a></sup> It is the best-known example of a cellular automaton.</p>
<p>The &#8220;game&#8221; is a <a title="Zero-player game" href="http://en.wikipedia.org/wiki/Zero-player_game">zero-player game</a>, meaning that its evolution is determined by its initial state, requiring no further input from humans. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.</p>
<h2><span>Rules</span></h2>
<p>The universe of the Game of Life is an infinite two-dimensional <a title="Orthogonal" href="http://en.wikipedia.org/wiki/Orthogonal">orthogonal</a> grid of square <em>cells</em>, each of which is in one of two possible states, <em>live</em> or <em>dead</em>. Every cell interacts with its eight <em><a title="Moore neighborhood" href="http://en.wikipedia.org/wiki/Moore_neighborhood">neighbors</a></em>, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:</p>
<ol>
<li>Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.</li>
<li>Any live cell with more than three live neighbours dies, as if by overcrowding.</li>
<li>Any live cell with two or three live neighbours lives on to the next generation.</li>
<li>Any dead cell with exactly three live neighbours becomes a live cell.</li>
</ol>
<p>The initial pattern constitutes the <em>seed</em> of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a <em>tick</em> (in other words, each generation is a pure function of the one before). The rules continue to be applied repeatedly to create further generations.&#8221;</p>
<p>various processing sketches exist playing with the algorithm and changing,tweaking,bastardising the original code as is the way with programming. the one i have chosen to play around with comes courtesy of mr daniel shiffman (see below)&#8230;</p>
<pre>// Daniel Shiffman, Nature of Code
// &lt;http://www.shiffman.net&gt;

// A basic implementation of John Conway's Game of Life CA
// how could this be improved to use object oriented programming?
// think of it as similar to our particle system, with a "cell" class
// to describe each individual cell and a "cellular automata" class
// to describe a collection of cells

int cellsize = 2;
int COLS, ROWS;
// Game of life board
int[][] old_board, new_board;

void setup()
{
  size(200, 200);
  smooth();
  // Initialize rows, columns and set-up arrays
  COLS = width/cellsize;
  ROWS = height/cellsize;
  old_board = new int[COLS][ROWS];
  new_board = new int[COLS][ROWS];
  // Call function to fill array with random values 0 or 1
  initBoard();
}

void draw() {
  background(255);

  // Loop through every spot in our 2D array and check spots neighbors
  for (int x = 0; x &lt; COLS;x++) {
    for (int y = 0; y &lt; ROWS;y++) {
      int nb = 0;
      // Note the use of mod ("%") below to ensure that cells on the edges have
      //"wrap-around" neighbors
      // above row
      if (old_board[(x+COLS-1) % COLS ][(y+ROWS-1) % ROWS ] == 1) { nb++; }
      if (old_board[ x                ][(y+ROWS-1) % ROWS ] == 1) { nb++; }
      if (old_board[(x+1)      % COLS ][(y+ROWS-1) % ROWS ] == 1) { nb++; }
      // middle row
      if (old_board[(x+COLS-1) % COLS ][ y                ] == 1) { nb++; }
      if (old_board[(x+1)      % COLS ][ y                ] == 1) { nb++; }
      // bottom row
      if (old_board[(x+COLS-1) % COLS ][(y+1)      % ROWS ] == 1) { nb++; }
      if (old_board[ x                ][(y+1)      % ROWS ] == 1) { nb++; }
      if (old_board[(x+1)      % COLS ][(y+1)      % ROWS ] == 1) { nb++; }

      // RULES OF "LIFE" HERE
      if      ((old_board[x][y] == 1) &amp;&amp; (nb &lt;  2)) { new_board[x][y] = 0; }
      //loneliness
      else if ((old_board[x][y] == 1) &amp;&amp; (nb &gt;  3)) { new_board[x][y] = 0; }
      //overpopulation
      else if ((old_board[x][y] == 0) &amp;&amp; (nb == 3)) { new_board[x][y] = 1; }
      //reproduction
      else                                          { new_board[x][y] = old_board[x][y];
    }  //stasis
    }
  }

  // RENDER game of life based on "new_board" values
  for ( int i = 0; i &lt; COLS;i++) {
    for ( int j = 0; j &lt; ROWS;j++) {
      if ((new_board[i][j] == 1)) {
        fill(0);
        stroke(0);
        rect(i*cellsize,j*cellsize,cellsize,cellsize);
      }
    }
  }

  // Swap old and new game of life boards
  int[][] tmp = old_board;
  old_board = new_board;
  new_board = tmp;
}

// Init board with random "alive" squares
void initBoard() {
  background(0);
  for (int i =0;i &lt; COLS;i++) {
    for (int j =0;j &lt; ROWS;j++) {
      if (int(random(2)) == 0) {
        old_board[i][j] = 1;
      } else {
        old_board[i][j] = 0;
      }
    }
  }
}

// reset board when mouse is pressed
void mousePressed() {
  initBoard();
}</pre>
<p>as seen in the rules of the &#8216;game&#8217; it is non-player, the only human interaction comes from the initial setup of the board, i am attempting to have the inbuilt webcam capturing and pixelating the viewer until a keypress/mousepress/other signal, indicates to start the game of life useing the viewers face as the initial setup for the board. something like this&#8230;..</p>
<p><img class="aligncenter size-full wp-image-110" src="http://dm.ncl.ac.uk/benthompson/files/2010/03/Picture-2.png" alt="initial board example" width="600" height="450" /></p>
<p>and the code (bastardised processing example code)&#8230;.</p>
<p>import processing.video.*;</p>
<p>int videoScale = 8;</p>
<p>int cols, rows;</p>
<p>Capture video;</p>
<p>void setup() {<br />
size(640,480);<br />
noStroke();</p>
<p>cols = width/videoScale;<br />
rows = height/videoScale;<br />
video = new Capture(this,cols,rows,30);<br />
}</p>
<p>void draw() {</p>
<p>if (video.available()) {<br />
video.read();<br />
}<br />
video.loadPixels();</p>
<p>for (int i = 0; i &lt; cols; i++) {</p>
<p>for (int j = 0; j &lt; rows; j++) {</p>
<p>int x = i*videoScale;<br />
int y = j*videoScale;</p>
<p>int loc = (video.width &#8211; i &#8211; 1) + j*video.width;</p>
<p>float b = brightness(video.pixels[i + j*video.width]);<br />
if(b&gt;=60){<br />
fill(255);<br />
}else{<br />
fill(0);<br />
}</p>
<p>rect(x,y,videoScale,videoScale);<br />
}<br />
}<br />
}</p>
<p>all i have to do now is get them both working together in harmony, booleans/ifs/ands/and all! then sort out the setup&#8230; projected again,size and scale issues.</p>
<p>also i like the way it progresses from the MaxMSP echoes project&#8230;a further example of mirrored evolution.</p>
<p>best get on with it. POW!</p>
]]></content:encoded>
			<wfw:commentRss>http://dm.ncl.ac.uk/benthompson/2010/03/10/mirrors-game-of-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
