Thursday, January 30, 2014

The Meaning of The Game of Life


When it was family board game night in the '70s, I always picked The Game of Life or Careers (or sometimes Masterpiece ... I was a weird kid), not Uno or Aggravation. I guess I liked the complexity; I even found Monopoly too predictable (it's a Markov chain, after all). My love of complexity was given a mainline overdose in 1979 when my dad became the first person in our town to own a home computer, a Texas Instruments TI-99/4 with a whopping 4K of RAM. (That's 1/16 as much as a Commodore 64.) He also had a subscription to a programming magazine, so every month I would read through mostly incomprehensible (to me) lines of badly-typset BASIC (a different dialect than TI BASIC, which caused me no end of grief), and occasionally laboriously type some in. There was Eliza the automated psychotherapist, the Lissajous fractal generator ... and Conway's Game of Life.

In 1970, British mathematician John Conway invented a set of rules for cellular automata that would allow you to start off with any combination of black and white squares on a grid like a chessboard and by applying three simple rules determine whether in the next turn a square would stay the same or change colour. Since computer time was too precious to be wasted on mere experimentation, Conway designed Life with pen and paper and only computerized it when he knew he would get a passable result. And what a result! While most cellular automata (a concept invented as a side project by scientists working on nuclear bombs) until then had been uninteresting, quickly gravitating to all black or all white squares, Conway's developed long, sometimes extremely stable cycles, with some shapes persisting, some cycling, some even spawning other shapes, looking like birds or stars or spaceships or even cells... it was a perfect storm of mathematics, armchair philosophy and whimsy at a time when computing was just starting to be able to accommodate all three.

There are many websites (and a humungous wiki with hundreds of named patterns) devoted to The Game of Life, but it seems to have lost its place in the geek imagination over the last ten years or so: most of these sites use Java applets that are routinely disallowed by modern browsers. To see Life in action, you pretty much are now stuck with Animated GIFs or downloadable freeware. Life is the first computer program I actually understood. I typed it into my poor overworked computer (it got so hot I actually burned my elbow once), and when it ran, the 7 or 8 second pause for recalculation between iterations didn't bother me. (At the time, everyone compared computer pauses to how long it would take a human to do with a slide rule and graph paper, so it was miraculous.) Then in the next issue, there was a revised code of the same program that ran over twice as fast by holding only three lines in memory at a time instead of the entire array. My mind was blown and I sat down with a pencil for hours and marked up the code to understand why this was so.

Then I gave up coding for 30 years to study opera and work in underground journalism, but that's another story.

(I've come full circle with keyboards, however: I now use the first chicklet keyboard I've had since 1979. Oh, and in the meantime Steven Wolfram claims to have reinvented science (or something, I only understand about 5% of it) using cellular automata with catchy names like Rule 90, not to be confused with Rule 34... don't worry, the link is safe for work).

To celebrate The Game of Life, I've rewritten some BASIC code using Joshua Bell's terrific javascript emulator (he was kind enough to help me implement it, since my BASIC is way better than my javascript). Enjoy, and marvel at what passed for computer graphics when Jimmy Carter was president. If you're a programmer, feel free to look at the code and smirk at the LET syntax, lack of ELSE statements and highly vulnerable GOTOs (I wrote so many infinite loops it was practically my breakfast cereal ... unlike Mikey, who preferred Life).

Note: Blogger seems a little finicky (and/or I'm a little incompetent) when it comes to displaying javascript. If you don't see a big black box above this sentence, click here or here. But not here or here. And definitely don't click here.

Wednesday, January 22, 2014

The irony of Soviet silver fox domestication


Left: wild silver fox (grr!) Right: domesticated silver fox (aww!)
Genetics was an outlaw science in the early Soviet Union: the idea that characteristics are inheritable smacked of an elitist plot to claim the class system was biologically predetermined.

Biologist Dmitri Belyaev (1917-1985) was dismissed from his post in a Moscow fur breeding laboratory in 1948 for his insistence that Darwinian artificial selection could produce rapid evolutionary change. During the Khrushchev ideological thaw, he was appointed head of a genetics institute in southern Siberia, safely away from the establishment.

From 1959 until his death, he was responsible for a spectacular experiment. Silver foxes were highly prized for their pelts, but they did not fare well in captivity. The obvious solution: breed them for docility. Belyaev patiently selected the foxes that were the least agitated around humans, and after only 40 generations had basically recapitulated the domestication of the wolf into the dog.

The Wild foxes had pointed ears, strong jaws, long tails, and silver coats.

The domesticated foxes had floppy ears, overbites, short tails which they wagged -- and, ironically, piebald coats which were basically useless to furriers!

These are all characteristics which, along with playfulness and trust of humans, they share with infant feral foxes. The wild ones grow out of these traits, but the domesticated ones were bred to retain them. (Evolutionary change to retain childlike characteristics is called neoteny, and it's an important part of hominid evolution: humans look much more like baby apes and chimpanzees than we do the adult primates.)

There's a sad coda to this tale: the breeding was continued after Belyaev's death, and is still ongoing, but the domesticated fox population is severely reduced due to post-Soviet economic troubles; many of them were sold as pets.

Bibliography:
Belyaev, D. K., Ruvinsky, A.o., Trut, L.N. 1981. Inherited activation-inactivation of the star gene in foxes. The Journal of Heredity 72:264–274.
Trut, L.N. 1999) Early Canid Domestication: The Farm-Fox Experiment. American Scientist 87(2): 160

If you want to read more, here is a great article written by the scientist who inherited the experiment from Belyaev.






Thursday, January 16, 2014

To baldly gif where no man has giffed before

If you're epileptic, click here right now. Otherwise, keep on reading. 

This is a "sundry flight of whimsy" week while I work on more serious stuff for later posts.

I've been a major contributor (39 so far by my count) to the r/FullMovieGifs subreddit; my latest contribution is J.J. Abrams's Star Trek (2009), with only the scenes with lens flares. Which is pretty much most of them. (I uploaded the whole movie as well.) Click on the image if you want to see it bigger.


I've been on a bit of a Star Trek gif tear; there are just so many visually odd moments in The Original Series that lend themselves to being taken out of context. Here are some of my creations:

I wonder our science fiction is as bad at projecting design into the future.
What kind of a ship are they running?

"Laugh-outs" were way too common in Star Trek
It's fun to reassemble scenes from different episodes
To those who say Spock never shows emotion.
Sulu is Japanese, and yet the Japanese language doesn't have the letter "L".
A Han and Leia moment.

Finally, a still image with a rather awful pun:


Wednesday, January 8, 2014

The Monty Hall Problem is cognitive Three-Card Monte


(See what I did there in the title?)

The Monty Hall Problem is a rather famous brain teaser, a rare mathematical puzzle that entered pop culture so successfully it was featured in a movie. I'm not that interested in providing yet another explanation of its counterintuitive correct answer; there are dozens on the Internet, for example here and here and here and here and here.

What fascinates me is why so many smart people get the answer wrong: I'll admit, the first time I encountered it, I picked the intuitive, incorrect answer. When The Problem first became famous in a newspaper column in 1990, over 1,000 Ph.D.s wrote letters to argue argue that the correct solution was, in fact, wrong; one world famous mathematician took a lot of convincing before he came around. Like most people when their backs up are against a wall, they dig their heels in, and when they are finally shown their error to their satisfaction (often with the help of computer simulations), they grumble that the question was posed ambiguously (for example, it doesn't explicitly state that space aliens aren't manipulating Monty Hall's behaviour... okay, I'm exaggerating, but that's the tenor of it).

Here's a quick rundown of The Problem. You're on a game show (presumably Let's Make a Deal, which Monty Hall hosted off and on for over 30 years), and there are three doors: you get whatever is behind the door you choose. One has a car, the other two have goats. (The delicious cheese isn't a bad consolation prize, if you ask me.)

You make a preliminary choice, then Monty opens one of the other two doors to reveal a goat. You can either stick with your original choice or choose the other unopened door. Should you change? Should you stay? Does it matter?

Short answer: it matters. You should change to the other door, you double your chances of winning the car. Most people instinctively think it doesn't matter whether they stick or change.Once it's explained, it takes a while to process, but eventually it's like an optical illusion: you couldn't see it at all at first, and now you can't not see it, and it's difficult to imagine why other people don't see it too. (Again, I'm not going to get into the explanation, other people have done it far more thoroughly than I ever could, click the links above or Google it if you need it proven to you).

Studies have shown that psychology plays a factor in perception (people want to stick with their first choice for emotional reasons), and I'll buy that, but it doesn't explain why really, really smart people are so prone to making fools of themselves trying to prove a fallacy.

Actually, I think the answer is rather simple: it's a mental card trick. The Problem is like a short con artist playing Three-Card Monte, making you think the queen is moving when it's staying in one hand. The problem has the appearance of randomness when it is anything but: the participation of Monty Hall himself in the Monty Hall Problem is what changes the odds.

If you first pick a door with a goat behind it, you don't know what you've just picked -- but Monty does. He has to, otherwise he has a 50% chance of ruining the game by revealing the car. (Unless that makes you win the car, but that would be a different game, and much less of a Problem in both senses of the word). Here is the kicker: Monty is constrained in what door he opens for you; it is not a random selection. He has to open a door with a goat: by doing so, he has passed information to you and changed the odds of the game. He has the appearance of a random player, but he is anything but.

(At this point, most people still don't believe Monty has passed information to the player. He has, I guarantee it, Google it and eventually your brain will warp enough to understand how. I'll dispel the most common objection right now: if you picked the door with the car first, Monty's choice is indeed random, but you've only got a 1 in 3 chance of that happening. Two out of three times, Monty is 100% constrained, which means overall he's 66% constrained. Now back to your regular programming.)

There's been a lot of academic attention on Bayesian probability in the past decade, for good reason: it works. The Monty Hall problem is a textbook (literally) demonstration as to the value of Bayes' theorem. I won't get into the details, I'll just pass along the best analogy of the Bayesian approach I ever heard: If you toss a coin and get heads nine times in a row, a traditional mathematician will say the chance of a head on the next toss is 50% because each toss is an independent event. A Bayesian mathematician will say the chance of a head on the next toss is just about 100%, because given the fact that you got nine heads in a row, it's a virtual certainty that you're using a two-headed coin.

Popular Posts

Scroll To Top