Press "Enter" to skip to content

Red Herrings

centaur 0

20160307_183335.jpg

So, I’m behind on my blog. And several posts have died on the vine because events have moved too fast.

So let’s get you all caught up on what’s going on.

It all appeared to start when the lights burned out on my car. This was distressing because I’d just had them replaced, twice in the last nine months, and is a real pain in the kestrel because while one of the bulbs, the left side, is easy to replace, the other, the right, is devilishly hard to get to, and even harder to put back because of a bracket that pokes right where your hand should go. The bruised back of my right hand is still hurting from the attempt to get the bulb back in - but as you can see above, I succeeded. I even took a picture, with the ripped up package that had held the new bulbs now holding the old bulbs, just to prove I did it.

20160307_190330.jpg

I felt good about that, and so had a nice meal - actually, that’s a lie. I was already heading to dinner - and actually, that’s a lie too, I was at work. I fixed my car's headlights on the first dry day after the day I bought the bulbs, squeezing it in between a bank trip to fix some Thinking Ink Press business and my usual evening “break” which consists of a drive listening to a fiction audiobook (“Imprisoned with the Pharaohs” by Lovecraft), a dinner reading technical papers (on deep learning) and a coffeehouse run working on writing stuff (more Thinking Ink Press work and research for the new opener of THE CLOCKWORK TIME MACHINE).

But, as the evening wound down and I packed it in to go to the gym with my night-owl wife, I started mentally planning a short blogpost about “So I can fix my car!” which I felt all unwontedly triumphal about since I’d tried replacing these bulbs two or three times before and always had to get it done at an auto shop, but “Look, Ma! Bruised hands!” I did it myself this time, and I felt great about it.

Until I got back to my car and it failed to start.

20160308_005423.jpg

The car’s failure mode was strange. The door opened, the lights came on and stayed on, all normal - but then all the interior displays flickered and died without starting the engine, and then progressively all electric circuits on the car locked up, including the locks and the trunk - though some weird device in the hood of the car made a sad, dying-Millennium-Falcon-hyperdrive whine. The failure was so strange, in fact, that at first I thought I’d fried a circuit when I was struggling with the light (though later I realized that would probably have just blown a fuse).

So there I was, eleven at night, with a dead car, in a sub-sub-basement parking garage in a part of Palo Alto so spooky I’ve written about it as a haunt of vampires. (In the middle part of the third Dakota Frost book, LIQUID FIRE, available on Amazon in print and on Kindle - am I spoiling the mood? I’m spoiling the mood. I’ll stop).

My night-owl wife was desperately trying to finish the antiquing on a mirror due tomorrow, so I was unable to get her on the phone - and she was forty-five minutes away regardless. So I tried to carefully think through my options: call a roadside service (which I don’t have), get the car towed to a nearby garage (a prospective gamble if the garage couldn’t take me), rent a car to get home (somewhat expensive), get a nearby hotel until the morning (probably more expensive), get a cab (certainly much more expensive), and so on, and so on. I settled on a tow truck with good Yelp ratings, only to find that they couldn’t send a truck out until morning because of the ridiculously low clearance of the sub-sub-basement of the parking garage I was parked in (6’8”).

We canceled it, and I finally got a call from my wife, who agreed to pick me up. With difficulty I extracted my work laptop from the frozen trunk of the car and sealed the car up. It was midnight, and almost everything was closed, so I then trudged to a nearby Subway and waited, starting on my work laptop the work I was fairly convinced I wouldn’t have time to get to the next morning, all the time thinking about a blogpost “So I can fry my car” while I angstily considered the wisdom of running 130,000 miles on a car, or working myself to the bone, or of a late-night coffeehouse run with my car in such a low clearance garage.

20160308_122302.jpg

The next day, after canceling my morning meetings, arranging a tow and a garage visit, and an adventure in helping my wife deliver her mirror, my wife brought me back to the parking structure. The sub-sub-basement was sealed - it’s private parking during the day - and after wandering around looking for a buzzer an eagle-eyed security guard found me and agreed to let me in. The tow was almost guaranteed to be expensive because of the clearance, so the tow company sent a battery technician out; after another adventure guiding the technician to the poorly marked garage via cell phone, we found out that the progressive death of power in the car should have been a hint. The Prius’s backup 12-volt battery, the original which came with the now six year old car, had died. Perhaps I left the lights on when I left the car, though I don’t recall doing that; the repair technician’s opinion was the battery was crap, outputting bursty voltage (? really? but it was visibly frying his instrument) and that’s what fried my lights and was on its way to frying my other electrics. Um … sure, not sure I’ve heard that failure mode before, but $300 dollars later, I had a functioning car.

20160308_122319.jpg

The thoughts that I’d fried my own electrics, or even left the lights on, were red herrings. Now, I don’t mean red herrings like those smoked fish that activists used to drag along the path of a fox to throw hounds off the scent, though that would have probably fried my electrics, or even red herrings like those false clues mystery writers use to throw the readers off the track of the real killer, though leaving my lights on to throw me off is the kind of sneaky thing that a mystery writer might do, and it is the mystery usage that inspired the sense which I do mean; no, I mean the red herrings of debugging: those things that happen right around the time a problem happened, but which have nothing to do with it - so no amount of investigation of them will make sense.

No amount of looking for a shorted wire in the hood would have revealed my dead battery in the trunk. No amount of brain wracking about whether the lights were on would have revealed anything about the age of my car. The actual solution didn’t involve more digging into the obvious possibilities, but involved doing something completely different - collecting data about a different system, using instruments I didn’t have on hand. Even without the intuition that the battery was old or the drained power was a sign of power loss or the possible lights out were a battery issue, one look under the hood of my car - where I could find no system with which I was sufficiently familiar to successfully debug or even feel safe with experimentation - should have told me to call a roadside expert to do tests I couldn’t perform myself and to effect a repair in minutes what would have taken me hours.

Similarly, the idea of running myself too hard or exposing myself to risk from a late night coffee run with my car parked in a nearby garage were red herrings. I had fun that night, fixing my car, making things happen with the small press, my car was parked conveniently, and even with the failure little more thought about the problem would have had me call out roadside service, gotten a new battery, and I could have driven it home. The long time walking around making phone calls in the dreary parking garage sucked, but no more than the time when, as a child, my dad’s motorcycle had a breakdown way out in the country, and we had to call a friend to pick us up. We waited hours then, like I waited an hour and a half that night; but the car came, the ride home happened, and then the problem was fixed. I got home late, sure, but it was after a nice ride with my wife talking about life. I missed a couple of morning meetings at work, sure, but I got to have a sandwich with my wife before she went home, and I drove my own car to my next meeting, which went swimmingly. And I even got some work done, and learned something. Studying the different methods of gradient descent, working through implementations in TensorFlow, and modeling function parameters in Mathematica, that time in the parking garage was long forgotten.

So, red herrings. Things can go wrong, but the obvious causes aren’t the obvious causes. Don’t blame the wrong thing, or you can spend a lot of effort hurting yourself. Do the due diligence to find the real causes - and then make the right choices to solve the real problems, and then move on, and on, and on, solving one problem at a time until you at last fall asleep at home, content.

That’s the only thing that really works.

-the Centaur

Obfuscated

centaur 0

Screenshot 2016-03-05 15.03.58.png

Yeah, that goop someone injected into my Dakota Frost site doesn’t look suspicious at all.

(In case you’re not a programmer, healthy code doesn’t look like that. This code has been munged and rewritten so it’s almost impossible to see what it does. Not that I care - I just deleted it. But it makes it hard for someone who needs to debug it, in the cases where you need to debug it.)

Sheesh. Get off my lawn. Still cleaning things up. More in a bit.

-the Centaur

So it was a hacked .htaccess…

centaur 0

hacked-htaccess.png

So, the Dakota Frost site got hacked. May still be hacked, for all I know, because I just found and eliminated only one error, and I still haven’t found out how they got in. Of course, I changed all my passwords everywhere else first before logging into the site, confirming no-one had hacked the user accounts, and then downloading all the code for some forensics.

But what was peculiar was that, even though I could clearly see evidence of hackery thanks to the very nice, publicly available Webmaster tools at the Google, I could not see any difference between the live site and my previous backup except for the addition of the Akismet spam filter, which I’m pretty sure I did myself.

Then I found it, when I detected a strange file named kgcakmhg.php. Tracing it back, in the root of the HTML directory, someone had modified files back in February - first to point the .htaccess to a strange file named baccus-contextually.php, which called the weirdly named file and also relied on changes to the style directory. No changes to the blog code were necessary - everything was being rewritten before it got there.

Removing those files? Easy. Site’s back to normal … I guess. Closing the open barn door? Uh …harder. Since I don’t know which door they came through.

Off to do more debugging …

-the Centaur

So, dakotafrost.com has been hacked

centaur 0

20160304_185447.jpg

So, yeah. I’ve lost sites to hacks before - the wiki on dresan.net, which I barely used - but those were obvious. This one is a subtle hack, not immediately visible, detected by the supercomputers at the Google. Will take a bit of effort to work this one out.

You see disruption here, you know why.

Sigh.

-the Centaur

I can’t channel John Scalzi

centaur 0

Screenshot 2016-03-03 20.28.41.png

Imitating Scalzi’s inimitable style (at least when he’s too busy to blog): “Has the novel been sent back to the editor? NO.”

But Debra did like the new first couple of chapters for THE CLOCKWORK TIME MACHINE, and her guidance gives me a clear path forward to cleaning them up, and the changes to the rest of the novel are minor … if I could Just. Get. More. Time. Friends from grade school are crossing the country to visit me, and friendly mathematicians are dropping by my coffeehouse table to school me on Clifford algebras and deep learning, to the point at which I finally had to turn down an impromptu lunch meeting today with someone who really wanted to know more about my team, just because I had no more time.

So, having no more time, just now I wanted to throw up a quick blogpost, other than the half dozen half-finished longer blogposts I can’t get done and still get to my own work. So I tried imitating John Scalzi’s quick posts when he’s backed up. Normally a sentence, and a photo. That’s it. But today, Google Photos and AT&T’s network and my phone and SPACE GREMLINS have conspired to make it impossible for me to upload photos in a timely fashion, I mean, dammit, how hard is it to write a sentence and post a photo?

THIS is why Scalzi is paid the megabucks.

I am no John Scalzi, so, here, you get a picture of the structure of the first 72 positions in tic-tac-toe, because I can’t not do the foundational work on a problem once I’ve thought of it, or I’ll never get back to it. This is important, it will mean something, I promise. But later.

Back to the novel.

-the Centaur

P.S. Yes I know my Mathematica could be simplified via NestList or something like that, don’t bother me, don’t bother me.
Screenshot 2016-03-03 20.34.35.png

Reminders

centaur 0
reminders.png I’m a packrat - not just the six tons of books I have in my library (as of 2006! God knows how much I’ve got now) but at work, where in last week’s office move I had thirty-two individual labeled items for the movers to move, sixteen of those boxes of stuff (again, mostly books, both for my personal library and for the robotics team library). But there were two boxes of stuff I took home, along with various bric-a-brac - mostly genre toys, a lot of them items only there for entertainment, like my large centaur statue or my mini R2D2 robot. But in that is a far more important genre of materials - in a way, the third most important category of things on my desk. The most important thing on my desk is the computer - I’m there to work, natch. The next most important thing is a picture of one of our cats - not because cats are important, but because it’s a reminder of my wife and family, of why I’m working. But the third most important thing are a set of awards, swag and trophies from work itself. These trophies include everything from a major award for a team I was on to a tiny piece of swag for hosting an intern. Not a one of them - not a one - is a major award for me in and of myself, sorry; my contributions were minor. But they are reminders that I’ve done something at work I can be proud of. As a neurotic workaholic, I need that feedback to keep going. When I’m struggling, when I’m fighting an algorithm, when I’m debugging code, I can always look to my right, see my cat sitting in front of a sabertooth skull, and remind myself why I’m doing what I’m doing; then I can look to the left, give my Google Instant globe a spin, and remind myself that hey, don’t you worry: you’ve got this. -the Centaur

Priorities

centaur 0

20160228_151829.jpg

Wow, the Vegan New Orleans and Vegan Las Vegas posts are taking a lot longer than expected - I didn’t get them out yesterday like I wanted. But that’s OK, because even more important stuff happened: Thinking Ink Press received the print proofs of THIRTY DAYS LATER, our first fiction anthology, which happens to feature Harry Turtledove. Woot! Here’s Betsy Miller, the author and publisher who did much of the work making the physical copy of this happen:

20160228_151804.jpg

I’m normally a hermit, working on my projects, but this past week has been almost totally focused on people: coffee with my thesis advisor talking about the Google, interviews, office moves with my team, coffechats with friends about the mathematical underpinnings of deep learning, dinner with my buddy Nathan Vargas, dinner with my buddy Derek Reubish planning a friends and family trip, and dinner with Derek and our buddy autocross racer Fred Zust catching up after Fred’s wife participated in a big race. No pics of that - I let Derek and Fred handle that chore - so instead I give you pics of the farmer’s wrap I had at Barnes and Noble while waiting for the call that Fred had finally hit town.

20160228_192808.jpg

Work is important - I spent the morning working on math and writing prior to meeting Betsy to talk about the page proofs, which itself was another kind of working; and as you see above, I worked while waiting for Fred to arrive.

20160228_122708.jpg

But there’s more to life than work. As another buddy, Gene Forrer, just pointed out, THIRTY DAYS LATER wouldn’t exist except for the strong camaraderie of all the authors at Clockwork Alchemy, and as Belinda Messenger-Sikes pointed out, that level of camaraderie among writers is unusual for such a small genre convention.

20160228_151748.jpg

But that camaraderie does more than just produce books; it also produces communities, long-lasting friendships, durable associations that pass the test of time. I’m happy to have all the friends I have, and even though I love being a hermit and just working on my work, I enjoy all the time I get to spend with all my friends building and building upon our friendships.

-the Centaur

I cheat …

centaur 0

20160219_170129.jpg

… using the following picture of a tree from Jackson Square in New Orleans. Trees can be awesome. What may not be clear is that this branch is spiraling out about thirty or forty feet. Hear, I show it to u:

derbranch.png

Amazing. It just seems to hover, just out of reach.

Trees are awesome.

-the Centaur

For the record …

centaur 0

A Bit Behind.png

… I appear to be about 3 posts behind for the year, depending on how you count it. Blogging every day has been really rewarding in making me open up and try new things with this blog, but man, for a man who complains that he takes on too much, I’m a man who really does have a great skill at taking on too much.

-the Centaur

Not Dead, Just Working

centaur 0

20160224_215340.jpg

I haven’t given up on blogging once a day - I just got overwhelmed at work and life and, more importantly, at friendship - hanging out with some of my best buddies and catching up, something I’ve been far too busy to do recently. But this week I put in time with a few good buddies - one from high school, one from the writing group, even one day when I was a bit under the weather working remotely with my laptop in the backyard, which was appreciated by our aging, inappropriately urinating, formerly-indoor cats.

20160223_162008.jpg

I was real stressed this week, but, objectively, things are going very well. I saved my threatened project from last year’s craziness and it’s now in use; I started a great new project with my team; even something that we thought was dead long ago got used in a great demo at work. I sent a novel to a publisher; we planned a high school friends trip to Tahoe; things are going well.

20160224_220820.jpg

One friend noted I’d been living my life the way I do - overstuffed with work, a full time software job; plus as much as a full time novelist as I can be reading over lunch and dinner, writing over coffee and occasional breakfasts; plus helping manage a small press; plus doing comics - for a while now, and he was worried the stress was getting worse. I see that, but didn’t quite agree.

20160226_192011.jpg

I’ve been this stressed before, particularly in the middle of my PhD, when I was two or three years in and thought I had two or three years more to get out … and then found out after three years of work I had several more years to go. I’ve done it to myself, taking on an 80% time job to spend time writing, but then spending a whole year filling my life with karate, improv, and weekly roundtables which filled my whole schedule to the point weeks just disappeared. As the stress builds, you just want to take a break - and if you don’t, as my friend pointed out, things may break anyway.

20160223_023946.jpg

Those periods of my life sucked, and in a way this one does too, but in another way, it’s more manageable. My crunch now is not being trapped just by doing too much to myself; it’s like being trapped by my PhD, which got delayed because I had an opportunity to work on a robotics project. Now, while I have a few things to deal with like a wrecked floor at the house, I’m mostly trapped by opportunity: the opportunity to do a great project at work, to write great books, to help bring other books to life.

Screenshot 2016-02-27 14.36.11.png

I can see an exit strategy - a couple years of work at work, three years of work on my next novels, plus maintenance of the small press and continued practice at comics, and once I get through those things, if they’re even moderately successful, I’ll be in a position of much more creative freedom. So I think it's important to not lose these opportunities - but on the other hand, it’s pointless to let your opportunities kill you. That’s why today, after I finished booking my next trip, after I finished more readings which hit the intersection of my robotics work and my urban fantasy research, but before I did any more serious work, including this blog entry … I took time out to be creative. To just draw.

20160227_135644.jpg

Well, drawing practice because I want to do comic books, but you get the idea.

-the Centaur

Back to Basics

centaur 0

20160221_152544.jpg

As a guilt-motivated ex-Catholic with a perfectionist streak, I’m constantly trying to be a better person than I am - religiously, ethically, personally, even at the level of my skills. And one of the best ways I’ve found to improve my skills is not simply to practice, or to push the bounds of your knowledge, but to step back and look again at the basics.

Screenshot 2016-02-22 20.56.24.png

For some areas of knowledge, this is obvious. We wouldn’t have gotten anywhere with number theory if we hadn’t been willing to go back, again and again, to the definitions of numbers. But it seems less obvious for skills, where our perception often is that first you are a novice, then you become skilled, then an expert, then a master.

20160219_140140.jpg

But that road can become a blind alley. Learning from a teacher can channel you into their style; self-taught artistry can create works of great power, but it can also leave you with deficiencies which no amount of further training can improve. Sometimes the only way to get better is to step back, reassess, start over.

20131209_221037.jpg

That’s why I like periodically coming back to beginning art instruction books. I find the older references somewhat more informative than the newer ones, perhaps because they’re more methodical, or perhaps because there was a greater concern for representational art - or simply because I’ve read a lot of newer references, making the old ones seem fresh.

20160218_164202.jpg

Now, I once heard an artist suggest that you should buy a pile of art instruction books, wrap them in a trash bag, and bury them in your back yard, get a big thick sketchbook and sketch people in coffeehouses until you filled the whole thing, and then, after a year or so, dig them up to start drawing. My wife, however, an accomplished artist, agrees and disagrees with this plan.

20160221_152624.jpg

She agrees with the latter two thirds - but not the start. She argues, there are so many things to learn about art that if you tried to start from just sketching, you might end up never making certain discoveries and instead get trapped in rookie mistakes. Your art might have emotional power, but you’d be handicapped if you were aiming for mastery of your tools or representational accuracy.

20160221_152553.jpg

I tend to agree. As a scientist, though, I try another approach - not just practice, but "scientific” analysis, at least the initial, data collection part of science: not just doing the practice, but carefully examining how it went, looking for successes and failures, and trying to generalize from them. I can’t double-blind A/B test myself, but I can be mindful about how I practice.

porsche-small.png

I pray it’s helping! I have a lot of art I want to do.

-the Centaur

Pictured: Exercises from Andrew Loomis’ DRAWING THE HEAD AND HANDS, folk art from the U.S. Mint in New Orleans, art books in Dauphine Street Books also in New Orleans, and various drawings I’ve done over the years, from long ago (the highly detailed centaur and the copy of the Hemingway cover) to yesterday (the basic circles and analysis of problems with my line).

It was N’awlins, y’all

centaur 0

20160215_161010.jpg

As if it wasn’t obvious. Sandi and I spent the week there in New Orleans' French Quarter - we never left it, never even rented a car, but just walked around, soaking in history and food. It was awesome, I have much to talk about, but, following the rules we’ve established, it wasn’t a business trip, so the details had to wait until my return.

I have returned. Expect a post on Vegan New Orleans soon. (Not a contradiction in terms!)

-the Centaur

I Think I’m Calling It

centaur 0

Screenshot 2016-02-20 09.40.27.png

Welp, looks like I’m not going to Comic-Con this year. My fault - I had a Professional registration, but received my renewal email when I was working to get a novel to the publisher and read the REGISTRATION DUE email as NOT DUE. Found out like the day after the professional registration closed. And then, even though I was reading the Toucan blog that announces such things, I was so busy working on another project that I missed Attendee Preregistration. And, as of now, even though I’m in line … it’s sold out:

Screenshot 2016-02-20 09.42.40.png

That happened while I was typing the above paragraph. At this point, three of the five days are sold out. My favorite night, preview night, sold out first:

Screenshot 2016-02-20 09.28.09.png

Comic-Con is awesome and overwhelming. I’d wondered if I would go back this year, but if I was not to go back, I’d prefer not to go back, like, on purpose, not through oversight, accident and bad luck. I look forward to going again next year. But perhaps I should focus less on going like a fan and more on doing the work that will get me invited there as a guest.

As my wife would say, focusing on making my next creative project spectacular.

-the Centaur

Update: while posting this …

Screenshot 2016-02-20 09.51.27.png

O.M.G. While TYPING that …

Screenshot 2016-02-20 09.52.01.png

Yeah, this ain’t Cave Johnson, but we’re done here.

Disruption

centaur 0

20160215_173705.jpg

Nothing lasts forever. Appreciate things while they’re there, because one day they’ll be gone. You will too.

-the Centaur

Are you threatening me?

centaur 0

picturesofpictures.png

Overheard from my life:

Me (talking a bit too fast): “So, it’s like filankatyafolio—“

Interlocutor (a bit surprised): “Are you … threatening me?”

Me: “I meant Phil and Kaja Foglio, of Girl Genius.”

I mean, I knew they were influential, but until now I didn’t know their names were killing words.

-the Centaur

Doppelgangers

centaur 0

20160215_222727.jpg

On two sides of the country, there’s a restaurant named after a city, serving the cuisine known from the region. They’re both high end, they’re both distinctive, and they’re both excellent … but they’re, as far as I know, completely unrelated to each other.

20140630_201006_HDR.jpg

They’re not one of a kind … but they are pretty damn good.

More on what and where they are after the trip is over.

-the Centaur

Oh no, someone’s wrong on the Internet!

centaur 0

20160214_163246.jpg

What I’ve discovered is that even if you definitively know something, that won’t stop someone online from snapping back with stupid, every step of the way. What’s worse, my rule of threes says that in any discussion, one third of their points will be wrong, one third of your points will be wrong, and the middle third will remain an area of durable disagreement.

There’s no cure for online idiots, but, fortunately, your own ignorance is correctable. Get into an argument with someone? Don’t try to get the last word - go look up the truth. (Or do the work to prove it, if it isn’t known). And be satisfied with your own answers.

Because if you found the truth and told them, that particular person isn’t likely to listen anyway.

-the Centaur

Visualizing Cellular Automata

centaur 0


cellular-automata-v1.png

SO, why's an urban fantasy author digging into the guts of Mathematica trying to reverse-engineer how Stephen Wolfram drew the diagrams of cellular automata in his book A New Kind of Science? Well, one of my favorite characters to write about is the precocious teenage weretiger Cinnamon Frost, who at first glance was a dirty little street cat until she blossomed into a mathematical genius when watered with just the right amount of motherly love. My training as a writer was in hard science fiction, so even if I'm writing about implausible fictions like teenage weretigers, I want the things that are real - like the mathematics she develops - to be right. So I'm working on a new kind of math behind the discoveries of my little fictional genius, but I'm not the youngest winner of the Hilbert Prize, so I need tools to help simulate her thought process.

And my thought process relies on visualizations, so I thought, hey, why don't I build on whatever Stephen Wolfram did in his groundbreaking tome A New Kind of Science, which is filled to its horse-choking brim with handsome diagrams of cellular automata, their rules, and the pictures generated by their evolution? After all, it only took him something like ten years to write the book ... how hard could it be?

Deconstructing the Code from A New Kind of Science, Chapter 2

Fortunately Stephen Wolfram provides at least some of the code that he used for creating the diagrams in A New Kind of Science. He's got the code available for download on the book's website, wolframscience.com, but a large subset is in the extensive endnotes for his book (which, densely printed and almost 350 pages long, could probably constitute a book in their own right). I'm going to reproduce that code here, as I assume it's short enough to fall under fair use, and for the half-dozen functions we've got here any attempt to reverse-engineer it would end up just recreating essentially the same functions with slightly different names.
Cellular automata are systems that take patterns and evolve them according to simple rules. The most basic cellular automata operate on lists of bits - strings of cells which can be "on" or "off" or alternately "live" or "dead," "true" and "false," or just "1" and "0" - and it's easiest to show off how they behave if you start with a long string of cells which are "off" with the very center cell being "on," so you can easily see how a single live cell evolves. And Wolfram's first function gives us just that, a list filled with dead cells represented by 0 with a live cell represented by 1 in its very center:

In[1]:= CenterList[n_Integer] := ReplacePart[Table[0, {n}], 1, Ceiling[n/2]]


In[2]:= CenterList[10]
Out[2]= {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}


One could imagine a cellular automata which updated each cell just based on its contents, but that would be really boring as each cell would be effectively independent. So Wolfram looks at what he calls "elementary automata" which update each cell based on their neighbors. Counting the cell itself, that's a row of three cells, and there are eight possible combinations of live and dead neighbors of three elements - and only two possible values that can be set for each new element, live or dead. Wolfram had a brain flash to list the eight possible combinations the same each way every time, so all you have are that list of eight values of "live" or "dead" - or 1's and 0's, and since a list of 1's and 0's is just a binary number, that enabled Wolfram to represent each elementary automata rule as a number:

In[3]:= ElementaryRule[num_Integer] := IntegerDigits[num, 2, 8]

In[4]:= ElementaryRule[30]
Out[4]= {0, 0, 0, 1, 1, 1, 1, 0}


Once you have that number, building code to apply the rule is easy. The input data is already a string of 1's and 0's, so Wolfram's rule for updating a list of cells basically involves shifting ("rotating") the list left and right, adding up the values of these three neighbors according to base 2 notation, and then looking up the value in the rule. Wolfram created Mathematica in part to help him research cellular automata, so the code to do this is deceptively simple…

In[5]:= CAStep[rule_List, a_List] :=
rule[[8 - (RotateLeft[a] + 2 (a + 2 RotateRight[a]))]]


... a “RotateLeft” and a “RotateRight” with some addition and multiplication to get the base 2 index into the rule. The code to apply this again and again to a list to get the history of a cellular automata over time is also simple:

In[6]:= CAEvolveList[rule_, init_List, t_Integer] :=
NestList[CAStep[rule, #] &, init, t]


Now we're ready to create the graphics for the evolution of Wolfram's "rule 30," the very simple rule which shows highly complex and irregular behavior, a discovery which Wolfram calls "the single most surprising scientific discovery [he has] ever made." Wow. Let's spin it up for a whirl and see what we get!

In[7]:= CAGraphics[history_List] :=
Graphics[Raster[1 - Reverse[history]], AspectRatio -> Automatic]


In[8]:= Show[CAGraphics[CAEvolveList[ElementaryRule[30], CenterList[103], 50]]]
Out[8]=

rule-30-evolution.png



Uh - oh. The "Raster" code that Wolfram provides is the code to create the large images of cellular automata, not the sexy graphics that show the detailed evolution of the rules. And reading between the lines of Wolfram's end notes, he started his work in FrameMaker before Mathematica was ready to be his full publishing platform, with a complex build process producing the output - so there's no guarantee that clean simple Mathematica code even exists for some of those early diagrams.

Guess we'll have to create our own.

Visualizing Cellular Automata in the Small

The cellular automata diagrams that Wolfram uses have boxes with thin lines, rather than just a raster image with 1's and 0's represented by borderless boxes. They're particularly appealing because the lines are white between black boxes and black between white boxes, which makes the structures very easy to see. After some digging, I found that, naturally, a Mathematica function to create those box diagrams does exist, and it's called ArrayPlot, with the Mesh option set to True:

In[9]:= ArrayPlot[Table[Mod[i + j, 2], {i, 0, 3}, {j, 0, 3}], Mesh -> True]
Out[9]=

checkerboard.png


While we could just use ArrayPlot, it' s important when developing software to encapsulate our knowledge as much as possible, so we'll create a function CAGridGraphics (following the way Wolfram named his functions) that encapsulates the knowledge of turning the Mesh option to True. If later we decide there's a better representation, we can just update CAMeshGraphics, rather than hunting down every use of ArrayPlot. This function gives us this:

In[10]:= CAMeshGraphics[matrix_List] :=
ArrayPlot[matrix, Mesh -> True, ImageSize -> Large]


In[11]:= CAMeshGraphics[{CenterList[10], CenterList[10]}]
Out[11]=

lines-of-boxes.png


Now, Wolfram has these great diagrams to help visualize cellular automata rules which show the neighbors up top and the output value at bottom, with a space between them. The GraphicsGrid does what we want here, except it by its nature resizes all the graphics to fill each available box. I'm sure there's a clever way to do this, but I don't know Mathematica well enough to find it, so I'm going to go back on what I just said earlier, break out the options on ArrayPlot, and tell the boxes to be the size I want:

In[20]:= CATransitionGraphics[rule_List] :=
GraphicsGrid[
Transpose[{Map[
   ArrayPlot[{#}, Mesh -> True, ImageSize -> {20 Length[#], 20}] &, rule]}]]


That works reasonably well; here' s an example rule, where three live neighbors in a row kills the center cell :

In[21]:= CATransitionGraphics[{{1, 1, 1}, {0}}]
Out[21]=

Screenshot 2016-01-03 14.19.21.png  

Now we need the pattern of digits that Wolfram uses to represent his neighbor patterns. Looking at the diagrams and sfter some digging in the code, it seems like these digits are simply listed in reverse counting order - that is, for 3 cells, we count down from 2^3 - 1 to 0, represented as binary digits.

In[22]:= CANeighborPattern[num_Integer] :=
Table[IntegerDigits[i, 2, num], {i, 2^num - 1, 0, -1}]


In[23]:= CANeighborPattern[3]
Out[23]= {{1, 1, 1}, {1, 1, 0}, {1, 0, 1}, {1, 0, 0}, {0, 1, 1}, {0, 1, 0}, {0, 0,
1}, {0, 0, 0}}


Stay with me - that only gets us the first row of the CATransitionGraphics; to get the next row, we need to apply a rule to that pattern and take the center cell:

In[24]:= CARuleCenterElement[rule_List, pattern_List] :=
CAStep[rule, pattern][[Floor[Length[pattern]/2]]]


In[25]:= CARuleCenterElement[ElementaryRule[30], {0, 1, 0}]
Out[25]= 1


With all this, we can now generate the pattern of 1' s and 0' s that represent the transitions for a single rule:

In[26]:= CARulePattern[rule_List] :=
Map[{#, {CARuleCenterElement[rule, #]}} &, CANeighborPattern[3]]

In[27]:= CARulePattern[ElementaryRule[30]]
Out[27]= {{{1, 1, 1}, {0}}, {{1, 1, 0}, {1}}, {{1, 0, 1}, {0}}, {{1, 0, 0}, {1}}, {{0,
   1, 1}, {0}}, {{0, 1, 0}, {1}}, {{0, 0, 1}, {1}}, {{0, 0, 0}, {0}}}


Now we can turn it into graphics, putting it into another GraphicsGrid, this time with a Frame.

In[28]:= CARuleGraphics[rule_List] :=
GraphicsGrid[{Map[CATransitionGraphics[#] &, CARulePattern[rule]]},
Frame -> All]


In[29]:= CARuleGraphics[ElementaryRule[30]]
Out[29]=

Screenshot 2016-01-03 14.13.52.png

At last! We' ve got the beautiful transition diagrams that Wolfram has in his book. And we want to apply it to a row with a single cell:

In[30]:= CAMeshGraphics[{CenterList[43]}]
Out[30]=

Screenshot 2016-01-03 14.13.59.png

What does that look like? Well, we once again take our CAEvolveList function from before, but rather than formatting it with Raster, we format it with our CAMeshGraphics:

In[31]:= CAMeshGraphics[CAEvolveList[ElementaryRule[30], CenterList[43], 20]]
Out[31]=

Screenshot 2016-01-03 14.14.26.png

And now we' ve got all the parts of the graphics which appear in the initial diagram of this page. Just to work it out a bit further, let’s write a single function to put all the graphics together, and try it out on rule 110, the rule which Wolfram discovered could effectively simulate any possible program, making it effectively a universal computer:

In[22]:= CAApplicationGraphics[rule_Integer, size_Integer] := Column[
{CAMeshGraphics[{CenterList[size]}],
   CARuleGraphics[ElementaryRule[rule]],
   CAMeshGraphics[
CAEvolveList[ElementaryRule[rule], CenterList[size],
   Floor[size/2] - 1]]},
Center]

In[23]:= CAApplicationGraphics[110, 43]
Out[23]=


Screenshot 2016-01-03 14.14.47.png

It doesn' t come out quite the way it did in Photoshop, but we' re getting close. Further learning of the rules of Mathematica graphics will probably help me, but that's neither here nor there. We've got a set of tools for displaying diagrams, which we can craft into what we need.

Which happens to be a non-standard number system unfolding itself into hyperbolic space, God help me.

Wish me luck.

-the Centaur

P.S. While I' m going to do a standard blogpost on this, I' m also going to try creating a Mathematica Computable Document Format (.cdf) for your perusal. Wish me luck again - it's my first one of these things.

P.P.S. I think it' s worthwhile to point out that while the tools I just built help visualize the application of a rule in the small …

In[24]:= CAApplicationGraphics[105, 53]
Out[24]=

Screenshot 2016-01-03 14.14.58.png

... the tools Wolfram built help visualize rules in the very, very large:

In[25]:= Show[CAGraphics[CAEvolveList[ElementaryRule[105], CenterList[10003], 5000]]]

Out[25]=

rule-105-a-lot.png

That's 10,000 times bigger - 100 times bigger in each direction - and Mathematica executes and displays it flawlessly.

Testing a Time Delayed Post

centaur 0

conservancy.jpg \

Will be AFK for much of tomorrow, so I’m going to take a shot at having a post previously written come up automatically. Stay tuned …

-the Centaur