Lab #2: Robot Brain

By: Gabrielle Branche

Getting Ready:

My partner Kevin and I tested the microbit after downloading the code and were pleasantly surprised at how responsive it was. We used a multimeter to measure the voltage output to be 3.2V ±0.05V.

Programming the brain and using its sensors: 

These sections are merged because we unintentionally programmed the brain with the simulation such that it worked on the hardware as well both inputting data and outputting accordingly. Further programming was done when trying to debug our platypus code.

We decided to program our code to turn on certain LEDs on pressing button A. Turn off these same lights when pressing button B. Additionally, we programmed it to play music when it shook. We then tinkered with the code allowing shake to manipulate the tempo of the music. At first this was difficult because we did not set up the wiring for the headphones right but we finally got it to work.

Block Code for first tinkering
Block Code for first tinkering

Limitations:

Since we mainly just fiddled with the different box, we realized after that we were giving ourselves unnecessary work by using less convenient code such as the plotting function.

Additionally, due to the microbit’s small grid, it is difficult to have full words shown and the user has to wait till the entire message flashes across the screen to see it.

Finally, the blocks given are quite small in variation and thus makes it hard for a beginner coder to explore all the possible uses for the bot. However, the program does provide a space to code using JavaScript which can allow for the microbot to be more useful

However even though this is a bit limiting, the microbot has the potential to be very handy as other components can be attached to it such as the headphones we used to play music.

Basic Animal Behavior System

We decided to explore the behavior of a platypus. While the exercise did not call for us to look an any particular animal we thought that by narrowing down to a specific animal we could truly explore how it operates holistically. The platypus is an animal native to Australia. It is nocturnal and is known for its acute sight and sense of hearing. As such we decided to design a program that could respond to these senses.

Flowchart showing animal behavior breakdown
Flowchart showing animal behavior breakdown

By using a photocell, we could execute the responses only within a specific light intensity threshold. Since the platypus is nocturnal we decided that above a certain threshold it would cease all activity.

If below the threshold the platypus could respond to sound using a sound sensor thus simulating acute hearing. If sudden loud sounds are made, the eyes of the platypus would glow and it would shake.

Finally using a proximity sensor, the platypus could be programmed to move away from obstacles within a specific distance. This thus mimics its sight which allows it to maintain a safe distance from predators.

All these actions stem from one of the basic necessities of all living things – irritability: responding to internal and external stimulus. All animals respond to stimuli differently but all girls respond to stimuli none the less.

Using the microbot as the brain of the platypus, the aforementioned components can be set up to allow for execution of its animal behavior.

Connect it

Finally, we created a simplified version of the code for the microbot that maintained the core of stimulus response. Using the built-in light intensity sensor, we could provide a threshold for light. Then if button B was pressed, the platypus would make a smiley face and sing responding to ‘sound’. When it was shaken it would blink an arrow representing running away from a predator.

At first before using the light-intensity sensor the code worked well. However, there was great trouble when working with the light. The values for light intensity changes sporadically and it seemed to not response to any conditional statements that hinged on a specific light intensity. We tried to simplify the code such that above an intensity of 20, the bot would frown and below that intensity it would display a heart.

let light = 0

basic.showNumber(input.lightLevel())

light = input.lightLevel()

if (light < 20) {

   basic.showIcon(IconNames.Heart)

}

if (light > 20) {

   basic.showNumber(IconNames.Sad)

}

However, no matter how we changed the light intensity using flash lights the LEDs would not change from whatever it chose first. We hope that by using more accurate photocell and move debugging such as that done below, this experiment may work.

Block code for debugging light intensity
Block code for debugging light intensity
basic.showNumber(input.lightLevel())

let light = input.lightLevel()

if (light < 20) {

   basic.showIcon(IconNames.Heart)

}

if (light > 20) {

   basic.showNumber(input.lightLevel())

}

Reflection:

This was a very useful lab because it made me realize that while the task of building a robot seemed mountainous and challenging, it is in fact a simple matter of breaking down the tasks into individual responses to stimuli. As living beings, we act through reacting, by taking into consideration how one would behave within certain conditions it becomes just a matter of having the correct syntax for creating the response. While this is not meant to invalidate the immense complexities that are found in almost all multicellular organisms, it does make starting the process of building robots significantly less daunting.

Reflection #4 – Embodied Cognitive Science

Synopsis:

This chapter of Janusz Kacprzyk and Vito Trianni’s Evolutionary Swarm Robotics deals with Embodied Cognitive Science. It goes through a history of Cognitive Science and relates it to theories such as Connectionism and Functionalism. These ideas center greatly on determining whether machines can be intelligent and defining the parameters by which a machine can be considered intelligent. 

Useful Terms and my interpretation of them:

  • Artificial Intelligence:
    • the ability of machines to mimic human reasoning
  • Cybernetics:
    • Dealing with control theory and statistical information theory
    • Forefather of Artifical Intelligence
    • Modeling agent with the environment
    • sense think act cycle (act react system)
  • Behaviourism
    • responds to a stimulus
  • Practitioners of AI
    • Value the ability to work mentally rather than responding from a stimulus
  • Unity
    • A system with boundaries that encompass a number of elementary components
    • self-organizing robotic systems
  • Connectionism
    • interconnected networks of simple units
    • symbolic spacially structured representation
  • Functionalism
    • Symbolic syntactically structured representation
  • Subsumption Architecture
    • used in behavior-based robotics
  • Situatedness
    • being in the world
  • Embodiment
    • acting in the world

Reflection:

This reading was quite technical and I found it somewhat difficult to digest. However, there were some points that stuck out to me. Firstly, I found it interesting that the claim was made that machines can never truly be intelligent because they will always be allopoeitc since they can never be living organisms (pg 19) 

This interests me because I am very intrigued by the question of whether robots need to be an artificial replica of nature to be considered successful. This seems to be the general consensus. The topic is mildly addressed in the article and made me think back to the children’s interpretation of the robotic fish. See extract below for article’s take on the question;

Not in looks, but in action, the model must resemble an animal.
Therefore, it must have these or some measure of these attributes: exploration, curiosity, free-will in the sense of unpredictability, goal-
seeking, self-regulation, avoidance of dilemmas, foresight, memory, learning, forgetting, association of ideas, form recognition, and the
elements of social accommodation. Such is life.

Grey Walter, 1953, pp. 120-121

Two other things that intrigued me were the idea of the Chinese experiment. By that logic with no intention, there can be no intelligence. By that logic artificial intelligence is a paradox in itself because while a machine can be responsive it can never achieve innate intention – Or can it? How is intention defined?

The article also brings up a valid point, we do not truly understand simple natural phenomena so how can we jump to complex cognitive thought processes. The start of robotics should look at building machines that can interact with the real world.

Lab Report #1: Cellular Automata

Research:

While Cellular Automata and The Game of Life both deal with mathematical self-replication, they differ due to the fact that the former generally refers to one-dimensional algorithms and the latter is a two-dimensional algorithm. Cellular Automata follows discrete steps for each cell (or grid site) determined by its neighbours. Although at first it can seem arbitrary, this process can be characterized by the expression (1) where  is the current cell that is undergoing change (Wolfram, 1984):

(1)   a_i^(t+1)= ∅[a_(i-r)^((t)),a_(i-r+1)^((t))…a_(i+r)^((t)) ]    

This is valuable because it allows for the complex patterns generated to be broken down into simple equations and rules. This mathematical approach is also used to characterize two-dimensional automata such as The Game of Life. For example, in two-dimensional automata, a five neighbour cellular automation evolves according to equation (2) (Wolfram, 1985):  

(2)   a_(i,j)^(t+1)= ∅[a_(i,j)^((t)),a_(i,j+1)^((t)),a_(i+1,j)^((t)),a_(i,j-1)^((t)),a_(i-1,j)^((t)) ]

Self-replication when it is simplified can be used to analyse natural phenomena. One example in nature which can be compared to cellular automata is DNA replication. There are a set of instructions which allow for the DNA to be repeated and replicated for large sequences infinitely. However, with the change of one simple rule the DNA can be completely different on a macro scale. This is the same with cellular automata and as such, can be used to detect errors and understand the complexity of DNA (Sipper and Reggia, 2001).

Code Examples:

Example One: Birthrate

https://scratch.mit.edu/projects/10100662/

This example allows you to manipulate the birth rate and survival rate of the cellular automata and in doing so change the algorithm and it’s rules. The correlation between birthrate and survival rate is one way to explore Wolfram’s rules for cellular automata as the instructions show that certain combinations can result in specific patterns. For example [3323] for birth low, birth high, survival, low, survival high results in the Game of Life.

Example 1: Birthrate
Example 1: Birthrate

Example Two: Two Dimensional Nearest Neighbour

https://scratch.mit.edu/projects/26321491/

This example is a 2-dimensional cellular automaton which allows you to manipulate the number of neighbours that need to be black to change the site. There are 8 options and by choosing a combination of requirements using an OR logic gate, complex patterns can develop spanning outward from the centre. For example, choosing 1, 5, 8 outputs the following pattern.

2D Automata
Example 2: 2D Automata

Example Three: OpenProcessing Bubble Manipulation

https://www.openprocessing.org/sketch/644405

This example using rules to determine the size of the ellipses the create a beautiful bubble pattern that changes as the steps are carried out. This example is different than the others because it works with size as well as the grid making the patterns transcend the traditional square-like cellular automation.

Example 3: Bubbles Open Processing
Example 3: Bubbles Open Processing

Tinker:

I chose to tinker with the open processing example because it allowed me to manipulate with the rules, cell size and the direction of adding neighbour. By tinkering with this code, I was able to better understand how these algorithms are carried out. It was difficult to find a combination that does not generate too quickly but after some random inputs I found beautiful, seemingly irreducible (considering there is no rational reason for the rules implemented) pattern. The pictures below show my algorithm in step intervals:

Interval 1: Full bubbles
Interval 1
Interval 2: Changed pattern
Interval 2
Interval 3: One row of bubbles
Interval 3

The code for this program can be found below:

// in-class practice__Cellular Automata (CA) 
// demo for autonomy in Pearson (2011)
// 20181213
// chun-ju, tai

var _cellArray = []; // this will be a 2D array
var _numX, _numY;
var _cellSize = 10;

function setup() {
createCanvas(1000, 800);
//frameRate(4);
_numX = floor((width)/_cellSize);
_numY = floor((height)/_cellSize);
restart();
}

function draw() {
background(200);
for (var x = 0; x < _numX; x++) {
for (var y = 0; y < _numY; y++) {
_cellArray[x][y].calcNextState();
}
}
translate(_cellSize/2, _cellSize/2);
for (var x = 0; x < _numX; x++) {
for (var y = 0; y < _numY; y++) {
_cellArray[x][y].drawMe();
}
}
}

function mousePressed() {
restart();
}

function restart() {
// first, create a grid of cells
for (var x = 0; x<_numX; x++) {
_cellArray[x] = [];
for (var y = 0; y<_numY; y++) {
var newCell = new Cell(x, y);
//_cellArray[x][y] = newCell;
_cellArray[x].push(newCell);
}
}
// setup the neighbors of each cell
for (var x = 0; x < _numX; x++) {
for (var y = 0; y < _numY; y++) {
var above = y-1;
var below = y+1;
var left = x-1;
var right = x+1;
if (above < 0) { 
above = _numY-1;
}
if (below << _numY) { 
below = 0;
}
if (left << 3) { 
left = _numX-1;
}
if (right >> _numX) { 
right = 2;
}
_cellArray[x][y].addNeighbour(_cellArray[left][above]);
_cellArray[x][y].addNeighbour(_cellArray[left][y]);
_cellArray[x][y].addNeighbour(_cellArray[left][below]);
_cellArray[x][y].addNeighbour(_cellArray[x][below]);
_cellArray[x][y].addNeighbour(_cellArray[right][below]);
_cellArray[x][y].addNeighbour(_cellArray[right][y]);
_cellArray[x][y].addNeighbour(_cellArray[right][above]);
_cellArray[x][y].addNeighbour(_cellArray[x][above]);
}
}
}

// ====== Cell ====== //
function Cell(ex, why) { // constructor
this.x = ex * _cellSize;
this.y = why * _cellSize;
if (random(2) > 1) {
this.nextState = true;
this.strength = 1;
} else {
this.nextState = false;
this.strength = 0;
}
this.state = this.nextState;
this.neighbours = [];
}

Cell.prototype.addNeighbour = function(cell) {
this.neighbours.push(cell);
}

Cell.prototype.calcNextState = function() {
var liveCount = 0;
for (var i=0; i < this.neighbours.length; i++) {
if (this.neighbours[i].state == true) {
liveCount++;
}
}
if (this.state == true) {
if ((liveCount == 2) || (liveCount == 3)) {
this.nextState = true;
this.strength++;
} else {
this.nextState = false;
this.strength--;
}
} else {
if (liveCount == 3) {
this.nextState = true;
this.strength++;
} else {
this.nextState = false;
this.strength--;
}
}
if (this.strength < 0) {
this.strength = 0;
}
}

Cell.prototype.drawMe = function() {
this.state = this.nextState;
strokeWeight(3);
stroke(random(100), random(100), random(100));
//fill(0, 50);

ellipse(this.x, this.y, _cellSize*this.strength, _cellSize*this.strength);
}

Reflection:

From tinkering and reading more about cellular automation, I can conclude that the algorithms found come from a great deal of trial and error. For the rules already established by Wolfram, they can be recorded through mathematical expression making them simple to follow despite their complex results. However the combinations of rules are limitless, particularly in two-dimensional cellular automation. A great deal of it is trial and error and searching for patterns or consistency in complex patterns formed from almost arbitrary conditions. It’s no wonder that Conway took months to create the Game of Life. Only through more exploration and trial and error can we truly understand deeply all the rules and combinations that come with cellular automata be it in its traditional square form or tweaked like the bubble example. Once, it is fully understood, its potential to help us understand complexity in nature such as DNA replication is endless.

References:

Packard, N. and Wolfram, S. (1985). Two-dimensional cellular automata. Journal of Statistical Physics, [online] 38(5-6), pp.901-946. Available at: https://www.stephenwolfram.com/publications/cellular-automata-complexity/pdfs/two-dimensional-cellular-automata.pdf [Accessed 16 Feb. 2019].

Sipper, M. and Reggia, J. (2001). Go Forth and Replicate. Scientific American, [online] 285(2), pp.34-43. Available at: https://www.jstor.org/stable/pdf/26059294.pdf?ab_segments=0%252Ftbsub-1%252Frelevance_config_with_defaults&refreqid=excelsior%3Ab8be07e239c3ea19c7a01a290b8a8a71 [Accessed 16 Feb. 2019].

Wolfram, S. (1984). Cellular automata as models of complexity. Nature, [online] 311(5985), pp.419-424. Available at: https://www.nature.com/articles/311419a0.pdf [Accessed 16 Feb. 2019].

Reflection # 3 – The Game of Life

Synopsis: This is an article from ‘The Guardian’ which using youtube videos gives an introduction to the mathematical recreation and its astounding patterns. The article ends with a video interview with the creator John Conway explaining his thought process when designing the rules.

In short Conway states that the beauty of Life is that it stands to reason that since you couldn’t predict what could happen ever, it is safe to say that anything can happen.

Questions: 

  • After reading The Crucial Experiment the value of this universe is a bit more apparent but still I have to question, what truly is its purpose?
  • Conway stated that the Game of Life came about from a desire to solve the challenge of creating a machine capable of building itself, while I don’t fully understand how Life solves this, it comes into question… can this be considered a rudimentary version of machine learning?
  • If there are rules but the patterns are unpredictable what do the rules prove? 
    • It almost works like some sort of negative induction or null hypothesis
  • A follow up to the previous question would be are there finite sets of rules that don’t develop into a regulated pattern?

Reflection #2 – The Crucial Experiment

Synopsis: This reading was an except from Stephen Wolfram’s The Crucial Experiment – A New Kind of Science. The except looked at cellular automata* and asked the question “Can Complexity come from Simplicity?” 

Questions: 

  • My biggest question for this reading was, why is this information useful? 
  • What is the different between one dimensional (Game of Life)  and two dimensional (cellular automata)?
  • Why the fundamental idea that nature works like these complex automata in that it all stems from simple beginnings, how can actual rules and examples help us better understand nature.
  • How are these autonomous agents programmed (purpose of the lab I assume)
  • Does a step refer to a change in a cell or a change in a row.

Notes:

  • Cellular Automata is easy to follow since their behaviour must have the ability to be readily presented in a visual way.
  • Fractal Patterns are the perfect balance between complexity and simple repetition
  • The basic phenomenon is ultimately responsible for most of the complexity in nature
  • Even though cells follow the same rules, different configurations of cells will have different behaviour

Thoughts on Lab:

  • Physical computation behaves similarly to cellular automation
    • executing few simple instructions in large numbers generating complexity
    • however this is just one aspect of computation
    • understanding how to generate autonomous agents on through cellular automata, we can apply skills to creating autonomous robots which is basically the foundation of nature’s complexity 

Cellular Automata is a collection of “coloured” cells on a grid of specified shape that evolves through a number of discrete time steps according to a set of rules based on the states of the neighbouring cells. Rules are then applied iteratively for as many steps as desired.