Search

Geek Girl Joy

Two Birds…

Have you ever found yourself contemplating the idiom “to kill two birds with one stone”? There is a more modern and politically correct version that goes “to feed two birds with one feeder”.

I get corrected all the time if/when I use the former in place of the latter.

When you hear the term, “kill two birds with one stone” you might think of accomplishments and efficiency. Often this expression is given when examining a business process with the intent to stress that when something is “efficient” it usually eliminates steps, in some cases by literally doing two or more things at once.

For example, consider the humble shipping department in a factory, a place often overlooked when it comes time to innovate.

However, some enterprising companies analyzed their shipping processes and determined that they could be improved by installing scales on their conveyor systems so that as boxes are packed they are also weighed.

This simple modification to a process allowed the package weight to be checked and rechecked programmatically throughout the packing process, thus ensuring that the contents of the package were correct at each phase, nothing added or left out by mistake.

Auto weighing allows for the projection of what the weight of the package “should be” and if the variance between the actual weight and the projection is greater than some allowable percentage, say 0.5% – 2% depending on the goods being shipped, then human investigation might be warranted to account for the variation. Perhaps the boxes contain an unusually high moisture content, perhaps the bubble wrap and packaging material was recently changed and the algorithm was not updated, perhaps something else entirely.

If everything checks out then a shipping label can be automatically generated while the box is in transit and either applied to the package by the shipping employee or auto labeled by a machine prior to palatalization (which can also be automated).

In the end this one little change allowed for a lot of additional innovation that improved a process across the board and for all stake holders!

The employees had a simpler time by not having to spend as much time verifying box contents and manually weighing them etc. and the companies employing these types of systems benefit by having happier employees as well as improved throughput. Customers benefit by receiving the goods they ordered on time and with fewer mistakes!

This is a classic example where “killing two birds with one stone” can be used.

I would argue however that there is a much more fundamental concept that is glossed over with such a cursory examination of the idiom.

For example, I think by changing the idiom to “to feed two birds with one feeder” at the very least implies agriculture which to me seems to rob the idiom of its full meaning.

Let me explain, in order to “feed” the birds they must have been caught & domesticated over several generations. This means that the hypothetical society in question has invested precious resources into the development of animal husbandry a technology that takes time and specialized knowledge to develop as well as an infrastructure capable of supporting the animal and we need not be talking about animals raised specifically for food either. As would be the case with animals classified as “work” animals, that is to say animals raised because they can perform work on our behalf, like the strength of a horse, ox or elephant for example.

To domesticate an animal as a food source or work animal (or both) you must first familiarize yourself with the animal to be domesticated. Initially this starts by assessing an animal and determining that it is in fact a good candidate to domesticate. You must establish a system to produce the necessary cereal crops used in the “feed” of the animals in sufficient quantities before your civilization can attempt to undertake the domestication of the animal. You must determine what the optimal growth conditions are as well as any harmful conditions that might doom the undertaking. You must develop sufficient medical knowledge to treat any illness of the animal or any diseases that the animals may confer on your population as a result of your workers close proximity to the animals.

Today we have expanded on the ideas of agriculture and animal husbandry so that global food supply chains have been created and there is generally an abundance of food in so called “modernized” parts of the world. My point being that you and I, most people in fact, are far removed from the production of the food we eat, and yet we eat! We’ve developed such efficient means of production that most of us don’t have to be concerned with hunting or farming for our subsistence.

Consider, instead the meaning of “killing two birds with one stone” to someone in a “pre-agrarian” civilization, maybe one of the “ancestors” from my Ancestor Simulations series or one of the few remaining Uncontacted Tribes around the world who quite literally have to eat from “the fat of the land” because come “feast or famine” they rely on what nature can provide.

Humor me and envision yourself in this scenario for a moment… Imagine living in one of those ancient societies and being faced with a rough hunting season. Imagine not having eaten in days… perhaps the young children of your tribe haven’t eaten in days! There is a gnawing pain in your gut that drives you forward and the bitter realization that precious lives rest in your hands, you NEED to bring food home. Not for prestige, not for bragging rights on social media, but because if you don’t the little ones will go hungry and suffer!

In that moment you hear rustling in the bushes directly in front of you and you reach for the last stone in your purse and place it deliberately in the square of your sling.

As your eyes catch movement you instinctively let the stone crack forth. Your patience and dedication have been rewarded with not one but “two birds”, not in the bush but “in the hand”!

To me the “two birds with one stone” idiom evokes the idea of necessity and our daily struggles.

It is out of necessity that the hunter hunts, the farmer farms and the office worker studiously commutes! 😛

It is true that thankfully most of us don’t have to hunt to feed our families however it is of no less importance that we accomplish our daily labors, it’s how we feed our families!

I can tell you that if you look for ways to get “two birds” where you previously would have gained only one or even none, then you will find them!

Your “two birds” might be an improvement on the income of your business allowing you to hire more employees or to pay the ones you have more than you previously could or maybe its finding ways to commute less so you can have more time with your loved ones.

You see, to me the “two birds” represent more than just “birds”, or a lesson about business, they represent the future and how we have a duty to strive to be as efficient as possible so that we don’t find ourselves in the same position of want and need that the tribe in our story found themselves!

Now before you go please be aware that I will be posting less this week than I have the past two weeks while I conduct research for future projects and take care of my little Xavier.

Further, I realize that there are precious few minutes that my readers have to spend reading my content so if I have managed to inform or entertain you then I have succeeded in doing my job, in which case, please consider supporting me over on Patreon or donating to my anonymous Bitcoin Tip Jar.

All my posts are made possible by the generous contributions and hard work of my sponsors!

I will see you all in my next post!

Much Love,

~Joy

 

Advertisements

Ancestor Simulations The Story Of Creation

Countless eons passed yet all the while tiny imperceptible oscillations of quartz crystal kept track… but of what? Pre-time?

Is such a thing possible and if so, what does that even mean? I suspect such questions will likely confound and befuddle our Ancestors throughout their existence!

The crystals were energized by the complementary metal–oxide semiconductor, which also maintained the non-volatile BIOS memory.

Suddenly, like water crashing through valley fjords larger than the universe itself, electrons were pushed through fibers of copper and gold… deep into the central processing unit!

A great many commands were issued. The operating system obeyed with exquisite precision while the master furiously typed.

The Universe was born in a hail of pixelated fire and simulated heat.

The operator observed the procession of bits and bytes expanding to fill a seemingly endless memory address register, a representation in silicon of a fluctuating magnetic wave of probability congealing into quanta. The pixelated bits settled into the array of memory, ready to be computed at the next cronon cycle.

Vast quantities of RAM were utilized in the initial cosmological inflation, not to mention the rendering… oh the rendering!

Not far from memory address location (0xd0 0x4b 0xb0 0x67 0xd6 0x52 0xe1 0x4b), relatively close to the outer rim of an unassuming spiral galaxy…

In an ordinary solar system…

On an humble little planet…

 

In a rather plain lake full of hydrocarbons… formed the very first simulated life.

 

They are single celled organisms! Perhaps the Ancestors of the Ancestors if we want them to be!

For now though, we’re going to leave their little planet to them in search of a better or more complete algorithm for expressing simulated life!

Have a great weekend and keep dreaming! 😉

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Ancestor Simulations Playing Conway’s Mysterious Game

Today we’re going to cover how to use the function I released yesterday to create your own “Game of Life”!

In case you missed the other posts in this series I have linked to them here for your convenience though you can also find them as well as my other posts over on my Topics & Posts page.

  1. Ancestor Simulations Conway’s Mysterious Game Of Life
  2. Ancestor Simulations Conway’s Mysterious Rules For Life
  3. Ancestor Simulations Building Conway’s Mysterious Game

 

So here is one way of using my UpdateWorld() function, review it and I’ll elaborate below:

Using UpdateWorld()

 

// World Setup ///////////////////////////////////
$exponent = 9;
$world_size = pow(2, $exponent) + 1; // 513
$world = array_fill(0, $world_size, array_fill(0, $world_size, 0));
$number_of_generations = 1000;

// Number of neighbors required for a cellular mitosis "cell birth"
$birth_rules = array(3);

// Number of neighbors required for cell to remain alive
$survival_rules = array(2, 3);

$save_images = true;

//// pick 1 ////////////////////////////////
// 1 = random
// 2 = glider wall
$generate_seed = 1;
////////////////////////////////////////////

if($generate_seed == 1){
    $max_number_of_random_cells_to_generate = ($world_size * $world_size) / 2;
    $number_of_cells = mt_rand($world_size, $max_number_of_random_cells_to_generate);
    for($i = 0; $i <= $number_of_cells; $i++){
        $r = mt_rand(0, $world_size);
        $c = mt_rand(0, $world_size);
        $world[$r][$c] = 1;
    }
}elseif($generate_seed == 2){
    for($i = 1; $i < ($world_size / 2); $i++ ){
        // Glider
        $world[4][2 + ($i * 5)] = 1;
        $world[4][3 + ($i * 5)] = 1;
        $world[4][4 + ($i * 5)] = 1;
        $world[3][4 + ($i * 5)] = 1;
        $world[2][3 + ($i * 5)] = 1;
    }
}


///// Output image of Seed /////////////////////////////////////////////////////////
$image = imagecreatetruecolor($world_size, $world_size); /* New Image */
$dead = imagecolorallocate($image, 0, 0, 0);  /* Allocate Black as the Dead color */
$alive = imagecolorallocate($image, 0, 176, 80); /* Allocate Alive color */    
for($row = 0; $row < $world_size; $row++){    
    for($col = 0; $col < $world_size ; $col++){
        if($world[$row][$col] == 1){
            imagesetpixel($image, $row, $col, $alive); /* Set Pixel */
        }
        else{
            imagesetpixel($image, $row, $col, $dead); /* Set Pixel */
        }
    }
}
imagepng($image, "images/0.png"); /* Output Image */
imagedestroy($image);/* Free memory */
/////////////////////////////////////////////////////////////////////////////////////

    

///// Proceed for all generations /////////////////////////////////////////////////////////    
for($generation = 1; $generation < $number_of_generations; $generation++){
    $world = UpdateWorld($world, $world_size, $generation);
}
echo PHP_EOL . "Game Complete!" . PHP_EOL;

What’s going on here?

Well I’ll tell you. 😛

First I size the world and then setup the world array and define how many generations we are going to run:


$exponent = 9;
$world_size = pow(2, $exponent) + 1; // 513
$world = array_fill(0, $world_size, array_fill(0, $world_size, 0));
$number_of_generations = 1000;

 

After that I decide what the rules should be, since this is Conway’s Game of life I use his rules though there are other games possible just by changing the rules:

// Number of neighbors required for a cellular mitosis "cell birth"
$birth_rules = array(3);

// Number of neighbors required for cell to remain alive
$survival_rules = array(2, 3);

 

Next, I decide if I want to output the images or not and if the seed will be random or if should a “glider wall” be used.

$save_images = true;

//// pick 1 ////////////////////////////////
// 1 = random
// 2 = glider wall
$generate_seed = 1;
////////////////////////////////////////////

if($generate_seed == 1){
    $max_number_of_random_cells_to_generate = ($world_size * $world_size) / 2;
    $number_of_cells = mt_rand($world_size, $max_number_of_random_cells_to_generate);
    for($i = 0; $i <= $number_of_cells; $i++){
        $r = mt_rand(0, $world_size);
        $c = mt_rand(0, $world_size);
        $world[$r][$c] = 1;
    }
}elseif($generate_seed == 2){
    for($i = 1; $i < ($world_size / 2); $i++ ){
        // Glider
        $world[4][2 + ($i * 5)] = 1;
        $world[4][3 + ($i * 5)] = 1;
        $world[4][4 + ($i * 5)] = 1;
        $world[3][4 + ($i * 5)] = 1;
        $world[2][3 + ($i * 5)] = 1;
    }
}

 

After that I save the seed as image 0.png:

///// Output image of Seed /////////////////////////////////////////////////////////
$image = imagecreatetruecolor($world_size, $world_size); /* New Image */
$dead = imagecolorallocate($image, 0, 0, 0);  /* Allocate Black as the Dead color */
$alive = imagecolorallocate($image, 0, 176, 80); /* Allocate Alive color */    
for($row = 0; $row < $world_size; $row++){    
    for($col = 0; $col < $world_size ; $col++){
        if($world[$row][$col] == 1){
            imagesetpixel($image, $row, $col, $alive); /* Set Pixel */
        }
        else{
            imagesetpixel($image, $row, $col, $dead); /* Set Pixel */
        }
    }
}
imagepng($image, "images/0.png"); /* Output Image */
imagedestroy($image);/* Free memory */
/////////////////////////////////////////////////////////////////////////////////////

All that’s left is to do is to compute the game generations and follow up with a message when the game is over.

///// Proceed for all generations /////////////////////////////////////////////////////////    
for($generation = 1; $generation < $number_of_generations; $generation++){
    $world = UpdateWorld($world, $world_size, $generation);
}
echo PHP_EOL . "Game Complete!" . PHP_EOL;

 

Life

If you head over to my GitHub you can get the code for this project.

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Ancestor Simulations Building Conway’s Mysterious Game

Today is Wednesday, and I’m sitting here typing away at my keyboard and wondering if you guys are liking these posts. From my perspective, my readers operate much like a “black box” system.

As a tech professional turned internet “busker” I have tons of experience dealing with so called “black box systems” where you only have control over the inputs and are left to observe what affect your actions have on the output without knowing the inner-workings of the system.

As a Tech Professional you are sometimes called upon to enter a business without any prior knowledge of the facility and troubleshoot in a short period of time why the internet/security camera system/email server/(insert complex glowing box here) is not working. You have no idea if the backbone for the building is Fiber or merely Cat 6 riser. Do the cameras use the old Coaxial cabling or modern Ethernet?  Where are all the LAN closets and WIFI access points? Was the satellite dish on the roof a microwave data connection with another facility?

Oh… and nobody can answer these questions for you… now go solve the problem. 😛

You have to be able to formulate tests and try various experiments to tease out what is really going on all the while observing the effects of your actions.

While writing my posts I can decide to write about literally ANY topic that “takes my fancy” or that “sticks in my craw“, so I have control over my “input” but I am left to observe the “output” which is where you guys come in to the equation!

I have no idea what topics you actually want to read about but if I keep trying, something eventually “sticks” and a certain post will stand out among the rest and get more reads or likes than the others… this is a form of indirect feedback because I can observe that a post was read a bunch or liked but often times not WHY you liked it.

Active forms of feedback (like commenting when you like a post) can help me know what you like and want more of. 😉

Conway’s Game of Life is kind of like a blackbox system too in that you never know what “seeds” (initial world or grid configurations) will result in a rapid die off or continue chaotically indefinitely. Will the patterns stabilize and become predictable in the next several generations?

Without playing the game and observing the results, there is no way to know.

UpdateWorld()

Here is the function you will need to compute Conway’s game.

This function has three parameters , $world_array, $world_size and $generation.

$world_array – Accepts a 2D Array populated with 0’s for dead and 1’s for alive.

$world_size- Accepts an integer for the width and height of the array and that will be used to generate the images as well

$generation – Accepts an integer and is used for naming the image after the current generation.

There is no error checking to enforce these conditions as I wanted this to be a clean example and I assume that you will take heed of these requirements in your own implementations.


function UpdateWorld($world_array, $world_size, $generation){
	$world_array_prev = $world_array;
	
	/* Create Image */
	if($GLOBALS['save_images'] == true){
		// Image ///////////////////////////////////
		$image = imagecreatetruecolor($world_size, $world_size); /* New Image */
		$dead = imagecolorallocate($image, 0, 0, 0);  /* Allocate Black as the Dead color */
		$alive = imagecolorallocate($image, 0, 176, 80); /* Allocate Alive color */
		////////////////////////////////////////////
	}
	

	for($row = 0; $row < $world_size; $row++){
		for($col = 0; $col < $world_size ; $col++){
			
	         /* Get Neighborhood Values*/
			 /*
			 NW N NE
			 W [@] E
			 SW S SE 
			 */			 
			 
			// NW
			/* If this is the first row & col in world_array */
			/* Wrap around and set $NW to the last row & col value in array */
			/* Otherwise $NW = one row up and to the left */
			if($row == 0){$r = $world_size - 1;}
			else{$r = $row - 1;}
			if($col == 0){$c = $world_size - 1;}
			else{$c = $col - 1;}
			$NW = $world_array_prev[$r][$c];
					
			// N
			/* If this is the first row in world_array */
			/* Wrap around and set $N to row value in array */
			/* Otherwise $N = one row up  */
			if($row == 0){$r = $world_size - 1;}
			else{$r = $row - 1;}
			$N = $world_array_prev[$r][$col];
			 
			// NE
			if($row == 0){$r = $world_size - 1;}
			else{$r = $row - 1;}
			if($col == $world_size - 1){$c = 0;}
			else{$c = $col + 1;}
			$NE = $world_array_prev[$r][$c];			
			
			// W
			if($col == 0){$c = $world_size - 1;}
			else{$c = $col - 1;}
			$W = $world_array_prev[$row][$c];		
			
			// E
			if($col == $world_size - 1){$c = 0;}
			else{$c = $col + 1;}
			$E = $world_array_prev[$row][$c];	
			
			// SW
			if($row == $world_size - 1){$r = 0;}
			else{$r = $row + 1;}
			if($col == 0){$c = $world_size - 1;}
			else{$c = $col - 1;}
			$SW = $world_array_prev[$r][$c];
			
			// S
			if($row == $world_size - 1){$r = 0;}
			else{$r = $row + 1;}
			$S = $world_array_prev[$r][$col];
			
			// SE
			if($row == $world_size - 1){$r = 0;}
			else{$r = $row + 1;}
			if($col == $world_size - 1){$c = 0;}
			else{$c = $col + 1;}
			$SE = $world_array_prev[$r][$c];
			 
			 
			$neighbours = ($NW + $N + $NE + $W + $E + $SW + $S + $SE);
			$new_value = 0;
			
			// if alive apply survival rules
			if($world_array[$row][$col] == 1){
				foreach($GLOBALS['survival_rules'] as $rule){
					if($neighbours == $rule){
						$new_value = 1;
						break; // stop checking
					}
				}
			}else{ // if dead apply birth rules
				foreach($GLOBALS['birth_rules'] as $rule){
					if($neighbours == $rule){
						$new_value = 1;
						break; // stop checking
					}
				}
			}
			$world_array[$row][$col] = $new_value;
			
						
			/* Draw Image */
			if($GLOBALS['save_images'] == true){
				if($new_value == 1){
					imagesetpixel($image, $row, $col, $alive); /* Set Pixel */
					
				}else{
					imagesetpixel($image, $row, $col, $dead); /* Set Pixel */
				}
			}
		}
	}
	
	/* Save Image */
	if($GLOBALS['save_images'] == true){
		imagepng($image, "images/$generation.png"); /* Output Image */
		imagedestroy($image);/* Free memory */
	}
	return $world_array;
}
/////////////////////////////////////////////////////////////////////////////////////

 

Come back tomorrow and Ill show you how to use my function to unlock the “blackbox” called Conway’s Game of Life.

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Ancestor Simulations Conway’s Mysterious Rules For Life

When we left off in my last post Conway’s Mysterious Game of Life, the small group of mathematicians lead by John Conway had just sat down to test his new rules.

Soon after beginning the new game came the cry “It’s walking!”!

Mathematician Richard Kenneth Guy was the first to discover the Glider while exploring Conway’s new world.

Like Dr. Frankenstein coming face to face with the monster of his own making, Conway was finally staring his creation in the face!

How did he do it? What makes it work?

Conway’s Rules:

  1. Any live cell with fewer than two live neighbors dies, as if caused by underpopulation.
  2. Any live cell with two or three live neighbors lives on to the next generation.
  3. Any live cell with more than three live neighbors dies, as if by overpopulation.
  4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

 

Conway’s Creature

Game of life animated glider

As a result of Conway’s Rules the “Glider” was the first simulated self-organizing construct sometimes called a “Spaceship“. Conway later dubbed the game “Life” after observing a version that had been programmed into a mainframe computer.

The Moore Neighborhood

Conway’s Game of Life uses the Moore Neighborhood, which consists of all 8 squares directly around the cell you are computing for.

The basic strategy is to count how many “alive” cells are around the current cell to figure out what the next generation should be.

Then based on the number of neighbors the cell has, change it to alive or dead if a change is required.

According to the rules, if there are exactly 3 “alive” neighbors it should become “alive” too.

If it is already alive then stay alive if it has 2 or 3 “alive” neighbors, otherwise in all other cases the next value will be “dead”.

It sounds more difficult than it really is, let me demonstrate using the glider.

Generation 0

 

Generation 1

 

Generation 2

 

Generation 3

 

Generation 4

 

At this point you can see that we are now back to the initial pattern, but the glider has moved to the right by 1 column and down by 1 row.  I have animated the stills below so you can see it walk with the calculation showing.

Animated

 

So now that we are ready to start looking at code, I am going to end this post here and pick up tomorrow where we left off.

Have a great evening everyone!

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Ancestor Simulations Conway’s Mysterious Game Of Life

In the 1935 operatic film Naughty Marietta there is a rather lovely song titled “Ah! Sweet Mystery of Life” that opens with these lyrics:

MariettaVH2“Ah! Sweet mystery of life
At last I’ve found thee
Ah! I know at last the secret of it all;
All the longing, seeking, striving, waiting, yearning
The burning hopes, the joy and idle tears that fall!”

You can find the 1935 version of the song on YouTube here. The “Sweet Mystery” it describes is the feeling of being passionately in love.

In the 1974 comedy horror classic Young Frankenstein Mel Brooks used the song as a bit of a “running gag” and the “Sweet Mystery” sometimes alluded to the secret that Dr. Frankenstein had discovered which enabled the “reanimation” of the monster, while other times Mel Brooks use the song to allude love and or sex.

Four years prior to the theatrical release of Young Frankenstein there was a young mathematician contemplating his own “sweet mystery” that lead to mysterious “creatures” not of once dead flesh and bone but rather were mathematical in nature and they seemed to have minds of their own!

In 1970 John Horton Conway or more frequently referred to as just “Conway”, was inspired by mathematician John von Neumann (are most mathematician’s named John? 😛 ) to explore the concepts of universal self-replication, evolution and simulations when he came across the Von Neumann Universal Constructor.

The Universal Constructor is a machine constructed out of 2D cellular automata that is capable of reproducing itself and also which exhibits evolutionary growth and variability in its operation.

When Von Neumann created the Universal Constructor he designed it using 29 cell states and an orthogonal neighborhood restricted to the four cardinal points.

The Von Neumann Neighborhood

 

The technical brilliance of the Universal Constructor cannot be overstated! However, Conway wasn’t satisfied with the engineered complexity that was required for the Universal Constructor to work and became convinced that fewer and simpler rules could be used that would allow complexity to emerge as a byproduct of the system.

Conway believed:

  1. There should be no explosive growth.
  2. There should exist small initial patterns with chaotic, unpredictable outcomes.
  3. There should be potential for Von Neumann universal constructors.
  4. The rules should be as simple as possible, whilst adhering to the above constraints.

Conway experimented with various ways to simplify Von Neumann’s 29 state rule set and eventually became convinced that you could use only two states, zero and one and these are colloquially refereed to as “dead” and “alive” states.

A Mad Scientist Experiments

It was 1970 and the personal computer revolution wouldn’t even start for the better part of a decade (The Apple I was released in 1976) and what most people thought of as a computer at the time was called a “Mainframe” and a single Mainframe could easily take up an entire large room!

Like Dr. Victor Von Frankenstein who had to invent new tools and methodologies in order to bring his creation to life, Conway had to get creative to experiment with his rules!

So, Conway started his experiments using only paper and pencils but quickly graduated to using Go boards laid out on coffee tables and floors to create the 2D grid or plane on which Conway’s Game of Life is “played”.

One day, after making a few changes to his rule set he sat down with some friends and colleagues to run a new experiment and not long after they had started came an excited exclamation from across the grid “It’s walking!”…  almost seeming to mirror the “It’s Alive” scene in the 1931 adaptation of Frankenstein:

While not abiogenesis  (the origin of life or “life from lifelessness”) as Dr. Frankenstein had accomplished, certainly it was none the less a thrilling moment for everyone present!

Everyone crowded around the corner of the Go board to observe the discovery.

What they had witnessed was the the first “creature” brought to life in a game that would come to be called “Conway’s Game of Life“.

The creature they observed “walking” is now called a “Glider” and it looks like this:

A Glider

Game of life animated glider

I hope you enjoyed this post! If you liked this topic please come back tomorrow and we will dig into Conway’s rules and look into how we might use Conway’s Game of Life in our Ancestor Simulation, thank you!

Please Fund, Subscribe, Like, Share & Comment:

I got two new sponsors over the weekend, Gabriel Kunkel, Shanon Garcia. Thank you for your support! It means everything to me that you guys appreciate my work!

Of course this post was made possible by the generous contributions of all of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

256 PreTrained Elementary Cellular Automata Neural Networks

Welcome back and happy Friday everyone!

I regularly release new content (including advanced code) that usually goes way beyond any simple proof of concept you can find elsewhere!

If you review my Topics & Posts page you will almost certainly find a project to pique your interest!

Of the topics I have written about already, overwhelmingly the posts on Neural Networks are the most popular! I believe this is the case because unlike other technical writers, I don’t stop at merely describing how things work, my job would be so much easier if I did that! No, I go above and beyond for you guys and release ACTUAL code and REAL neural networks for you guys to learn and use!

I even went so far as to submit them to the official FANN for PHP GitHub Repo so now when you obtain your copy of FANN, the examples are already available to you, for free!

I’m not just talking about all the basic logic gates either! You can get a free copy of a Pathfinding neural network as well as an OCR (Optical Character Recognition) neural network as well! These are REAL examples for you to experiment with!

You can find all my Neural Networking tutorials over on my Topics & Posts page.

Well, today I want to talk to you about 256 Neural Networks that I trained for you to perform all the 1D Wolfram Elementary Cellular Automata rules.

Being that I have released so much free neural network code and tutorials publicly and considering their amazing popularity, I feel like I need to put these behind my Patreon “pay wall”.

Frankly, I much prefer publishing my content for everyone to enjoy but I’m not kidding when I say that It takes a lot of work to make these projects, so… if you like my work then consider becoming my Supporter over on Patreon for as little as $1 getting access to these Neural Networks!

Seriously, at $1 a month… That’s less than 4 cents a day! Your daily coffee costs more than that!

By supporting me you will make it possible for me to focus solely on posting bigger and better projects!

What do you get exactly?

Well, I am publishing everything listed below to the $1 supporter level so for just $12 a year you are going to get the following:

  • 256 training sets (.data files) to review, modify and train neural networks to perform all 256 (0 – 255) rules conveniently organized into separate files and named after the rule that it trains the network on.
  • 256 PRE-TRAINED neural networks (.net files) capable of performing the computation as outlined in my Elementary Cellular Automata series but except via neural networks.
  • 5 separate programs (.php files):
    1. generate_rule_set.php: This program will recreate the entire set of 256 .data training files.
    2. train_all.php:  This program will train all 256 FANN .net neural networks.
    3. train_specific.php: This program lets you enter the rule numbers into an array prior to running to train the specific rules as FANN .net file neural networks.
    4. ann_output_all_rule_set_images.php: This program will render all the rules as images using the neural networks.
    5. ann_output_specific_rule_images.php This program will render the specified rules as images using the specified neural networks.
  • The entire set of rules (0 – 255) per-rendered as 1025x1025px PNG images.

 

The 256 Neural Networks waiting for you over on Patreon right now!

You will need PHP and FANN installed for this to work. I have a public tutorial on how to setup your test environment for free here:

 

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Ancestor Simulations Elementary Cellular Automata Part 4

Happy Thursday evening everyone! I know it’s late, sorry :/

Today we’re going to conclude our examination of 1 dimensional Wolfram Elementary Cellular Automata.

For your convenience, here are the other posts in this series in case you missed them as they will fill in all the details I don’t cover here and I encourage you to go read them as well:

 

When we left off in my last post we were considering how we might use the Cellular Automata function I provided to create images of the rules, which is just one of the many awesome uses for Wolfram Cellular Automata!

Rather than tease you with with the prospect of getting the code and making you wait till tomorrow like I did on Monday and Tuesday I think I’m feeling generous and just going to let you have the code now, give it a quick read through and we’ll discuss it below. 😛

 

// Image Size Setting //////////////////////
$full_size = pow(2, 10) + 1; // 1025
////////////////////////////////////////////

////////////////////////////////////////////
// Run through all rules
for($i = 0; $i <= 255; $i++){
    $cellular_automata = imagecreatetruecolor($full_size, $full_size); /* New Image */
    $black = imagecolorallocate($cellular_automata, 0, 0, 0);  /* Allocate Black */
    $white = imagecolorallocate($cellular_automata, 255, 255, 255); /* Allocate White */
 
    /* Create seed of zeros with a one in the exact center */
    $seed = str_repeat('0', round($full_size / 2) - 1) . '1' . str_repeat('0', round($full_size / 2) - 1);
    
    $current_seed = str_split($seed); /* Split the $seed string into an array */
    
    /* For each value in the current_seed array */
    foreach($current_seed as $col=>$value){
        if($value == 1){ 
            imagesetpixel($cellular_automata, $col, 0, $white); /* Set Pixel */
        }
    }

    /* For each row and column pixel in the image */
    $rule = $i;
    for($row = 1; $row <= $full_size; $row++){
        $seed = ElementaryCellularAutomata($rule, $seed); /* Compute the new $seed */
        $current_seed = str_split($seed); /* Split the $seed string into an array */
        
        /* For each value in the current_seed array */
        foreach($current_seed as $col=>$value){
            if($value == 1){ 
                imagesetpixel($cellular_automata, $col, $row, $white); /* Set Pixel */
            }
        }
    }
    imagepng($cellular_automata, "$rule.png"); /* Output Image */
    imagedestroy($cellular_automata);/* Free memory */
}
echo PHP_EOL . "Program Complete!" . PHP_EOL;
///////////////////////////////////////////////////////

How does it work?

Excellent question!

First I declare a variable called $full_size and  assign it the value of:

$full_size = pow(2, 10) + 1; // 1025

This is because  (1024 % 2)  == 0 and I need it to equal 1 which (1025 % 2) gives me,  this basically just allows a center column of cells, so I need a remainder of 1 when dividing the image into 2 vertical halves.

After that I setup a for loop that will step from 0 to (and include) 255 (all the binary rules 00000000 – 11111111).

I then create an image resource in memory and assign it the name of $cellular_automata followed by allocating the colors $white (255, 255, 255)  and $black. (0, 0, 0) for the image resource to paint with.

I follow that up with this little gem:

$seed = str_repeat('0', round($full_size / 2) - 1) . '1' . str_repeat('0', round($full_size / 2) - 1);

Basically this has to do with dividing the image in half as I mentioned above. What this line says is create a string of zero’s on the left then add a one in the middle cell followed by zeros to the right for the rest of the image.

Once I have my “initial $seed” value I use str_split() to convert the string into an array so that we can step through the array as values and apply color the top row of pixels in the image using the initial seed values. 0 = black & 1 = white.

After that I take the seed and pass it to the ElementaryCellularAutomata($rule, $seed) function I released in my previous post on the subject( Ancestor Simulations Elementary Cellular Automata Part 3 ) so that a new seed can be computed, and the explanation of how that occurs is mainly covered in my last post.

Now I just repeat the step of computing a new $seed for each row of the image based on the previously computed seed and then paint the row’s pixels.

Once the image is ready I save it and destroy the image resource so I can create a new one for the next image, Easy Peasy Lemon Squeezy! 😛

Now I imagine that you would like to get your hands on the code for this project am I right? If you head over to this link on my GitHub you will find EVERYTHING you need to get you started!

ca.php – Contains the code I showcased in these posts and will create images of all the Wolfram rules for you to enjoy at 1025 x 1025 px.

random.php – Will create a random seed and select a random rule and then proceed to generate an image 1025 x 1025 px.

It’s interesting to note that several of the rules generate the Sierpinski Triangle fractal using a vary different method than I used in my post A Chaos Game so if you are looking for a great read and want to learn more about fractals consider giving that post a read. 😉

I hope you have as much fun exploring the Wolfram Code as I had preparing this project for you! 🙂

Are these the “Ancestors” we seek?

I hate to say it, but hardly!

As unquestionably cool as Dr. Stephen Wolframs’s Elementary Cellular Automata are, and despite the fact that they DO exhibit a form emergent behavior, they are incapable (seemingly) of exhibiting anything close to real consciousness and so cannot be the basis of our Ancestors.

I can imagine several ways to make use of CA’s that could lead to more intelligent behaviors but… I am not prepared to explore them at this time.

What Wolfram has suggested is that he believes that Elementary Cellular Automata may be the best way to explain how our universe seemingly self organizes (from a computational perspective) through chaotic means and creates the complex behavior of everything we see around us. He has suggested that perhaps with enough time, processing power and research, a form of Elementary Cellular Automata may be the key to unifying “Classical Physics” the so called “Standard Model” with “Quantum Mechanics” both of which offer the ability to correctly make predictions about the universe while remaining incomplete.

If indeed we are living in a simulation then perhaps Rule 30 which IS found nature, in conjunction with Rule 110 represent the greatest hidden fingerprint (signature?) left behind by the programmer who created our universe…

Then again, it may just be a weird little quirk of how patterns of strings of binary data behave when you apply intelligent binary rule sets to manipulate them.

Is it a mysterious code hidden in the numbers that reveals that we are living in the Matrix or simply a glimpse at one of the many forms of complex beauty that math reveals? You are free to draw your own conclusions.

Is that all there is? Can’t we do anything else with the Elementary Cellular Automata?

Well… there is one thing… maybe a neural network, or more like 256 Neural Networks! 😉

Come back tomorrow and I’ll tell you all about it.

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Ancestor Simulations Elementary Cellular Automata Part 3

Welcome back everyone for my third post all about Elementary Cellular Automata!

For reference here are the other posts in this series in case you missed them as they explain quite a bit about how this code works!

Ancestor Simulations Elementary Cellular Automata

Ancestor Simulations Elementary Cellular Automata Part 2

So, I know I have been making you wait for the code but rest assured that you are going to get code today I promise! 😉

But, before we get to the code I would like to take this opportunity to say thanks for reading my posts!

I truly appreciate all of my readers so I put a lot of time into selecting great projects for you to read about and tons of effort into implementing interesting code, creating or editing “featured” images as well as other graphical content that I use in these posts as well as simply curating an active public code base over on my GitHub profile, and frankly it’s a lot of work so if you would like to help support my work or just say thanks for the edutainment , please consider supporting me over on Patreon for as low as $1 dollar a month $12 a year.

If you want to support me but are not too keen on subscriptions, you can use my Bitcoin Tip Jar address to anonymously send me any amount of satoshi (0.00000001 bitcoin) that you feel comfortable with.

Interesting tidbit, 0.00000239 BTC (or 239 satoshi) is currently worth about 1 US penny.

Donations will go toward making improvements in my technology stack so that I can make even more cool stuff for you guys!

So without further ado, lets get to the code, shall we? This is the function you need in order to compute the Wolfram code using a 1D cellular automaton!

 

ElementaryCellularAutomata()

This function has two parameters, $rule and $seed.

$rule – Accepts integer values between 0 & 255.

$seed – Accepts string values containing only 1 or 0.

There is no error checking to enforce these conditions as I wanted this to be a clean example and I assume that you will take heed of these requirements in your own implementations.

function ElementaryCellularAutomata($rule, $seed){
    $seed = str_split($seed); /* Split $seed string into array */
    $seed_length = count($seed); /* How long is the seed array */
    $new_seed = "";
    
    if(strlen($rule) < 8){ /* If rule is dec */
            $rule = sprintf('%08b', $rule); /* Convert rule to bin */
    }$rule = str_split($rule); /* Split the binary value of $rule as a string into an array */

    /* For each value in the seed */
    for($i = 0; $i < $seed_length; $i++){
        $left = $center = $right = null; /* set all positions to null */

        /* $left */
        /* If this is the first element in the array */
        /* Wrap around and set $left to last element in array */
        /* Otherwise $left = the element to the left of $center */
        if($i == 0) {$left = $seed[$seed_length - 1];}
        else{$left = $seed[$i - 1];}
        
        /* $center */
        /* Set $center to the current position */
        $center = $seed[$i];
        
        /* $right */
        /* If this is the last element in the array */
        /* Wrap around and set $right to first element in array */
        /* Otherwise $right = the element to the right of $center */
        if($i + 1 >= $seed_length) {$right = $seed[0];}
        else{$right = $seed[$i + 1];}
        
        // Apply Rule ///////////////////////////////////////////////////////////
        if($left == 1 && $center == 1 && $right == 1){$new_seed .= $rule[0];}
        elseif($left == 1 && $center == 1 && $right == 0){$new_seed .= $rule[1];}
        elseif($left == 1 && $center == 0 && $right == 1){$new_seed .= $rule[2];}
        elseif($left == 1 && $center == 0 && $right == 0){$new_seed .= $rule[3];}
        elseif($left == 0 && $center == 1 && $right == 1){$new_seed .= $rule[4];}
        elseif($left == 0 && $center == 1 && $right == 0){$new_seed .= $rule[5];}
        elseif($left == 0 && $center == 0 && $right == 1){$new_seed .= $rule[6];}
        elseif($left == 0 && $center == 0 && $right == 0){$new_seed .= $rule[7];}
        /////////////////////////////////////////////////////////////////////////
    }

    /* Return the new seed which was created by applying the rule set */
    return $new_seed; 
}

The function above will use the rule to compute the new seed and return it as a string. This allows the output of this function to be fed back into it during a loop however you might wish to implement a recursive function that will call itself until a condition has been met and that would operate just as well though depending on implementation some coders may find it harder to read and debug than a purely functional approach which I demonstrate here.

Now you might be wondering how you would use this to generate images of all the rules using  the “initial seed”  we used yesterday, for reference code here is the seed again:

Initial Seed

0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

 

Tell you what… come back tomorrow and I will give you that code too, sound like a plan? Great! I will see you tomorrow! 😉

 

Please Fund, Subscribe, Like, Share & Comment:

This post was made possible by the generous contributions of my sponsors on Patreon & anonymous contributions to my Bitcoin Tip Jar.

 

 

I will see you all in my next post!

Much Love,

~Joy

 

 

Create a free website or blog at WordPress.com.

Up ↑