#### Coding for Fun..

Although coding is generally associated with a professional career, I feel that there is a lot of scope for programming as a hobby, for creative exploration, as a source of fun and pleasure and even self-discovery. When the World Wide Web appeared in the early 90’s it was not commercial at all, it was all bottom-up, populated by pages developed by people who wanted to publish stories, poems, and ideas, or provide online resources for community or educational organizations. Much of it was creative or educational, and free of commercial content. Page links were used to interconnect writings and ideas of different people, and weave the world together in interesting and different ways. Of course all of this is still possible and available to any of us, but many aren’t aware just how easy and fun it can be. Programming is not hard, and it combines the pleasure of problem-solving, that many of us enjoy in puzzles and brain teasers, with creativity and productivity and explration. Unlike a Soduku puzzle, or a crossword, or other puzzles, as a programmer you get to produce something of your own that you can use for your own purposes, or share with others. And that something could be a game, an animation or other work of art, a Web site, a database of a collection of some kind, an interactive poem, you name it..

With this in mind I’m thinking about trying to create some introductory material to help anyone open their own door into coding. The two languages that come to mind are Processing, ideal for more visually oriented and often animated applications, and HTML/Javascript, allowing you to create interactive and useful Web pages. Actually Processing has just been “ported” into Javascript in the form of p5.js, giving you the best of both worlds.

Here’s a very simple interactive Processing example, that consists of just a few lines of code. Just move the mouse around in the box on the right.. Click the mouse button to change the shape between triangle, circle, and square.

#### Bottom-up Coding - Discovering Not Controlling..

My own coding interests are focused on “bottom-up” programming: an approach based on a digital simulation of natural processes. In evolution, organisms and behaviors change, or evolve, not by top-down design but by local responses to local conditions (exhibiting “emergent” behavior). With computers we can experiments with simple universes of our devising, where we define the rules of the universe (which can be extremely simple), assign initial conditions (the initial state of the elements in the universe), and then “run” the universe to see what happens as the rules are applied to the conditions. We can also introduce “evolutionary surprises” by introducing some degree of error as the system evolves. This kind of modelling is only possible today because computers can perform large numbers of operations extremely fast, providing mathematicians, biologists, physicists, artists, and the rest of us, with a fascinating new tool and subject for exploration. I’ve provided some examples of different models of this kind that you can extend and develop in your ways for your own purposes, along with a few references to help you get you started. Just follow the links below..

A **cellular automaton** is a model that manifests a very simple rule-based universe of 1, 2 or n dimensions, that progresses according to a clock. Each location in the universe is termed a cell and at each tick of the clock each cell has a certain state. Every cell’s state at the next tick of the click is determined by applying the rules of the universe to its current state. In other words by applying the rules to the current state we determine the next state (so this is a recursive activity: where the current state is recurrently used to find out the next state). That might sound quite complicated but it can be extremely very simple, since usually there are very few rules and very few states for each cell. For example a 1-dimensional Wolfram Cellular Automaton consists of a single “row” of cells each of which can be in a state 0 or 1, and whose state changes based on the cell’s current state and the states of its two neighbors. Amazingly this simple world creates some fascinating and unpredictable behaviors, which have intrigued mathematicians, physicists, biologists, and more recently, artists, since Wolfram first developed the model.

What makes cellular automata fun for the rest of us is that they are easy to program, can be extended and modified in any way you want, and provide a wonderful experience of an evolutionary, bottom-up world: you set the rules and the initial conditions (initial states of each cell), then run the program and observe the results as the universe evolves. Press one of the buttons below to explore a working example and learn how they work..

#### More Examples of Recursion: Deterministic Chaos and the Mandelbrot Set

There are many examples of deterministic chaos, where a simple recursive model can shift from a predictable and orderly oscillating behavior to unpredictability (chaos). This coded example replicates the work of Robert May, who recursively ran a simple population formula x = rx(1-x), where each result was fed back into the next x value, and the result mapped into a graph for many different rates of r. The graph is extraordinary, showing increasingly bifurcating results for different rates of r, leading to chaos, but then revealing self-similar behaviors within the chaotic bands, where the entire pattern replicates on a different scale, seemingly infinitely.

EXPLORE A WORKING EXAMPLE

The Mandelbrot is another example of a formula recursively fed back into itself.

LEARN MORE ABOUT THE MANDELBROT SET

#### More Code Examples..

Placeholder for more examples..