<?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>Recreational | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/recreational/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Thu, 25 Mar 2021 10:41:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>Recreational | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>A week off</title>
		<link>https://learncgames.com/a-week-off/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-week-off</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 25 Mar 2021 00:00:46 +0000</pubDate>
				<category><![CDATA[Recreational]]></category>
		<category><![CDATA[time-off]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2952</guid>

					<description><![CDATA[<p>I&#8217;m taking seven days off.  Given that I&#8217;ve just published 391 blogs including tutorials over the last 391 days, I think I deserve a short break&#8230; Back soon&#8230;</p>
The post <a href="https://learncgames.com/a-week-off/">A week off</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:82,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/fancycrave1-1115284\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=819362&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:83,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=819362&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:38:03&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-21 02:36:51&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 11:04:45&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-06 14:55:50&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-09 21:15:19&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-13 22:54:07&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-21 05:41:45&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-30 20:40:58&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 09:29:54&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-09 05:33:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 07:31:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 15:32:43&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-20 09:40:37&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 09:40:37&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2953" aria-describedby="caption-attachment-2953" style="width: 150px" class="wp-caption alignleft"><img decoding="async" class="size-thumbnail wp-image-2953" src="https://learncgames.com/wp-content/uploads/2021/03/coffee-819362_640-150x150.jpg" alt="Coffee" width="150" height="150" srcset="https://learncgames.com/wp-content/uploads/2021/03/coffee-819362_640-150x150.jpg 150w, https://learncgames.com/wp-content/uploads/2021/03/coffee-819362_640-250x250.jpg 250w" sizes="(max-width: 150px) 100vw, 150px" /><figcaption id="caption-attachment-2953" class="wp-caption-text">Image by <a href="https://pixabay.com/users/fancycrave1-1115284/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=819362">fancycrave1</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=819362">Pixabay</a></figcaption></figure>
<p>I&#8217;m taking seven days off.  Given that I&#8217;ve just published 391 blogs including tutorials over the last 391 days, I think I deserve a short break&#8230; Back soon&#8230;</p>The post <a href="https://learncgames.com/a-week-off/">A week off</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2952</post-id>	</item>
		<item>
		<title>How to calculate how effective a Riffle is</title>
		<link>https://learncgames.com/how-to-calculate-how-effective-a-riffle-is/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-calculate-how-effective-a-riffle-is</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 02 Sep 2020 23:00:14 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Recreational]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[riffle]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1325</guid>

					<description><![CDATA[<p>In my previous post I mentioned about writing a program to determine how effective a riffle shuffle was. So here&#8217;s the code. How it works I&#8217;m using an array of 52 chars to hold the deck. I&#8217;m only interested in the card&#8217;s position in the deck so each card is initialised with a value in [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-calculate-how-effective-a-riffle-is/">How to calculate how effective a Riffle is</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:535,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/422737-422737\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=627167&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:536,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=627167&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 15:57:27&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-15 11:44:29&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-21 02:36:50&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 11:04:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-09 21:15:19&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-14 12:23:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-21 05:41:45&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-30 20:40:58&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 09:29:47&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-09 05:33:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 07:31:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 15:32:43&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-20 09:40:36&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 09:40:36&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_1329" aria-describedby="caption-attachment-1329" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-1329" src="https://learncgames.com/wp-content/uploads/2020/09/cards-627167_640-300x225.jpg" alt="deck of cards" width="300" height="225" srcset="https://learncgames.com/wp-content/uploads/2020/09/cards-627167_640-300x225.jpg 300w, https://learncgames.com/wp-content/uploads/2020/09/cards-627167_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-1329" class="wp-caption-text">Image by <a href="https://pixabay.com/users/422737-422737/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=627167">Hebi B.</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=627167">Pixabay</a></figcaption></figure>
<p>In my previous post I mentioned about writing a program to determine how effective a riffle shuffle was. So here&#8217;s the code.</p>
<h3>How it works</h3>
<p>I&#8217;m using an array of 52 chars to hold the deck. I&#8217;m only interested in the card&#8217;s position in the deck so each card is initialised with a value in the range 0-51. I&#8217;m using three other similar sized arrays.</p>
<ul>
<li><strong>tempCards</strong> are used purely for doing the riffle.</li>
<li><strong>distances</strong> are used to calculate the maximum distance the card moved</li>
<li><strong>startPos</strong> tracks the cards starting position 0-51 before doing lots of rounds of riffles.</li>
</ul>
<p>The program starts by picking up ( as a parameter) how many rounds you want it to run. It defaults to 10 if no value is input.</p>
<p>It then clears distances and inits cards. In each round, it starts by storing card positions in startPos. It then does seven riffles and works out how far a card has moved. If it has moved more than before (in distances) it stores it in distances.</p>
<p>DoRiffle works by indexing through the two 1/2 deck piles taking a card from each and a 50:50 random chance determines which of the two cards goes into the shuffled deck first and then second.</p>
<p>Here&#8217;s the listing.</p>
<pre><code class="language-c" data-line="">// riffle.c by D. Bolton (C) 2020 Learncgames.com - TYou are free to redistribute but please keep this line in

#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;time.h&gt;

// #defines
#define MAXROUNDS 10
#define NUMRIFFLES 7
#define NUMCARDS 52

// variables
int NumRounds;
char cards[NUMCARDS],tempCards[NUMCARDS],startPos[NUMCARDS];
int distances[NUMCARDS];
time_t t;

// functions

// Convert string to int calling strtol
int GetIntArg(char* str) {
	char* ptr;
	return strtol(str, &amp;ptr, 10);
}

// Merges two cards a and b. 50:50 chance that a above b or other way
void DoRiffle() {
	// Copy cards into tempCards
	memcpy(tempCards, cards, sizeof(cards));
	// Merge each pair of cards tempCards[i] and TempCards[i+26]
	int cardIndex = 0;
	for (int i = 0; i &lt; NUMCARDS / 2; i++) {
		if (rand() % 2) {
			cards[cardIndex++] = tempCards[i];
			cards[cardIndex++] = tempCards[i + 26];

		}
		else {
			cards[cardIndex++] = tempCards[i + 26];
			cards[cardIndex++] = tempCards[i];
		}
	}
}

// Works out how far cards have moved, added to distances
void CalculateDistances() {
	for (int i = 0; i &lt; NUMCARDS; i++) {
		int moved = abs(cards[i] - startPos[i]);
		if (moved &gt; distances[i])
			distances[i] = moved;
	}
}

void DoShuffles() {
	// Clear distances and init cards
	for (char i = 0; i &lt; NUMCARDS; i++) {
		distances[i] = 0;		
		cards[i] = i;
	}
    // do Numrounds  rounds
	for (int round =0;round&lt;NumRounds;round++){
		// Mark where the card starts
		for (char i = 0; i &lt; NUMCARDS; i++) {
			startPos[i] = cards[i];
		}
		// Do seven riffles
		for (int i = 0; i &lt; NUMRIFFLES; i++) {
			DoRiffle();
		}		
		CalculateDistances();
	}
	int furthest = 0;
	for (int i = 0; i &lt; NUMCARDS; i++) {
		printf(&quot;Distance[%d]=%d\n&quot;, i, distances[i]);
		if (distances[i]&gt; furthest) {
			furthest = distances[i];
		}
	}
	printf(&quot;furthest moved is %d\n&quot;, furthest);
}


int main(int argc, char* argv[]) {
	srand((unsigned)time(&amp;t));
	if (argc ==1 || argc== 2) {
		NumRounds = MAXROUNDS;
		if (argc == 2) {
			NumRounds = GetIntArg(argv[1]);
			printf(&quot;Numrounds = %d\n&quot;, NumRounds);
		}
		DoShuffles();
	}
	else {
		printf(&quot;Please supply 0 or 1 arguments e.g. riffle 60\n&quot;);
	}
}</code></pre>
<p>Even with ten rounds I&#8217;ve seen cards move 51 positions. With 5,000 rounds all cards but one moved by 51 and one by 50.</p>The post <a href="https://learncgames.com/how-to-calculate-how-effective-a-riffle-is/">How to calculate how effective a Riffle is</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1325</post-id>	</item>
		<item>
		<title>John Conways Game of Life</title>
		<link>https://learncgames.com/john-conways-game-of-life/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=john-conways-game-of-life</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 03 Jun 2020 23:00:52 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Recreational]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[John Conway]]></category>
		<category><![CDATA[life]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=730</guid>

					<description><![CDATA[<p>An English mathematician John Conway (who died not that long ago) came up with a very simple cellular automaton that he called Life. This was back in the 1970s and I remember finding his original article in Scientific American while at University. We had no internet then and I whiled away 10 or so hours [&#8230;]</p>
The post <a href="https://learncgames.com/john-conways-game-of-life/">John Conways Game of Life</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:159,&quot;href&quot;:&quot;https:\/\/en.wikipedia.org\/wiki\/Conway%27s_Game_of_Life&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206124258\/https:\/\/en.wikipedia.org\/wiki\/Conway%27s_Game_of_Life&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:32,&quot;href&quot;:&quot;https:\/\/sourceforge.net\/projects\/golly&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251221195135\/https:\/\/sourceforge.net\/projects\/golly\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:04:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-09 20:19:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 22:35:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 19:52:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 02:01:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 00:15:22&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-27 00:41:45&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-03 20:07:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-06 21:54:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-10 18:30:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 16:16:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-18 16:51:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 08:32:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 13:35:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-30 20:41:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-03 02:45:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-08 00:33:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-12 05:32:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-16 15:32:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 09:40:42&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 09:40:42&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:696,&quot;href&quot;:&quot;https:\/\/github.com\/lamine2000\/game_of_life&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206175220\/https:\/\/github.com\/lamine2000\/game_of_life&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-08 03:38:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 04:16:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 14:38:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 11:04:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 20:07:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 21:54:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-10 18:30:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-18 16:51:23&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 15:45:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-30 20:41:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-04 08:37:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 00:33:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-12 07:31:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-16 15:32:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-20 09:40:40&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 09:40:40&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img decoding="async" class="alignleft size-medium wp-image-732" src="https://learncgames.com/wp-content/uploads/2020/06/golly-300x233.png" alt="Golly - Life simulator" width="300" height="233" srcset="https://learncgames.com/wp-content/uploads/2020/06/golly-300x233.png 300w, https://learncgames.com/wp-content/uploads/2020/06/golly.png 618w" sizes="(max-width: 300px) 100vw, 300px" />An English mathematician John Conway (who died not that long ago) came up with a very simple cellular automaton that he called <a title="Link to Life on Wikipedia" href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" target="_blank" rel="nofollow noopener noreferrer">Life</a>. This was back in the 1970s and I remember finding his original article in Scientific American while at University.</p>
<p>We had no internet then and I whiled away 10 or so hours trying to make my version of Life run faster. Given that this was 1978 and it was written in BASIC, it&#8217;s not surprising that it only did a couple of generations per second on a mainframe. They didn&#8217;t give us much CPU time and it was an ICL 1900. My iPhone is probably more powerful!</p>
<p>The rules are simple enough to implement but it&#8217;s unlikely you&#8217;ll outperform <a title="Link to Golly on Sourceforge" href="https://sourceforge.net/projects/golly/" target="_blank" rel="nofollow noopener noreferrer">Golly</a> which is what the image shows. That&#8217;s written in C++ and has been under near continuous development for the last 15 years.</p>
<p>But part of the fun is writing your own life simulator and watching the patterns explode. I&#8217;d call it the minecraft of its day given the amount of computing time spent on this since the 1970s. There are some amazing creations all following these three simple rules.</p>
<ul class="i8Z77e">
<li class="TrT0Xe">Any live cell with two or three live neighbours survives.</li>
<li class="TrT0Xe">Any dead cell with three live neighbours becomes a live cell.</li>
<li class="TrT0Xe">All other live cells die in the next generation. Similarly, all other dead cells stay dead.</li>
</ul>
<p>The grid is just a simple bit field. Each cell is either on or off and the rules determine if new cells are created or if patterns die out.</p>
<p>There are innumerable ones on the web. Here for example is a <a title="Link to SDL + C Life on GitHub" href="https://github.com/lamine2000/game_of_life" target="_blank" rel="nofollow noopener noreferrer">C/SDL version</a>. Note, it uses SDL1. When I get the time, I&#8217;ll build and run it. Comments are in French!</p>The post <a href="https://learncgames.com/john-conways-game-of-life/">John Conways Game of Life</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">730</post-id>	</item>
	</channel>
</rss>
