<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Magic Pantry &#187; Programming</title>
	<atom:link href="http://kranzky.rockethands.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://kranzky.rockethands.com</link>
	<description>the wonderful world of lloyd kranzky</description>
	<lastBuildDate>Mon, 14 Feb 2011 14:47:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>TTM: Time To MegaHAL</title>
		<link>http://kranzky.rockethands.com/2011/02/14/ttm-time-to-megahal/</link>
		<comments>http://kranzky.rockethands.com/2011/02/14/ttm-time-to-megahal/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 14:47:17 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[MegaHAL]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=505</guid>
		<description><![CDATA[It seems that my Time To MegaHAL, or TTM, is about six weeks. I&#8217;ll explain. What generally happens is this: I start a new job, and meet a whole new bunch of people. After about six weeks, someone suddenly mentions &#8220;hey, you&#8217;re that MegaHAL guy&#8221;! It happened just today. My new boss, at a job [...]]]></description>
			<content:encoded><![CDATA[<p>It seems that my Time To MegaHAL, or TTM, is about six weeks.</p>
<p>I&#8217;ll explain. What generally happens is this:</p>
<ol>
<li>I start a new job, and meet a whole new bunch of people.</li>
<li>After about six weeks, someone suddenly mentions &#8220;hey, you&#8217;re that MegaHAL guy&#8221;!</li>
</ol>
<p>It happened just today. My new boss, at a job I started six weeks ago, suddenly made the connection when a good friend of his published an <a href="http://teichman.org/blog/2011/02/cobe.html" target="_blank">interesting post about cobe</a>, an optimised and much improved reverse-engineered rewrite of MegaHAL, written in Python and using SQLite as a storage back-end. A nice piece of work, although I&#8217;m a bit ashamed that someone had to wade through my 16-year-old vanilla C code to try to figure our what the bloody hell is going on :)</p>
<p>Of course, this will probably help to knock me out of my summertime hiatus. Things have been quite on the blogging front lately, what with moving into our new house just prior to Christmas and starting a new job first thing in the New Year. Now that our new place is looking more like a home and less like a cardboard box wholesaler, it&#8217;s time to sit back, take stock and figure out what&#8217;s next.</p>
<p>For me, that&#8217;s as follows:</p>
<ul>
<li>Send out a final &#8220;Occasional Jason&#8221; missive to my mailing list, winding up my six-month sabbatical.</li>
<li>Work on a commercial version of the well-received <a href="http://rockethands.com/lazybones" target="_blank">Professor Lazybones and the Cellular Automata Game Engine</a>.</li>
<li>Release <a href="http://kranzky.rockethands.com/2010/11/06/megahal/">MegaHAL.10</a>.</li>
<li>Get <a href="http://www.laggydash.com/">LaggyDash</a>, my Global Game Jam entry, to some level of completeness.</li>
</ul>
<p>Although, really, the first item on the list should really be &#8220;get more sleep, and exercise&#8221;.</p>
<p>Exciting times!</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2011/02/14/ttm-time-to-megahal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MegaHAL</title>
		<link>http://kranzky.rockethands.com/2010/11/06/megahal/</link>
		<comments>http://kranzky.rockethands.com/2010/11/06/megahal/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 13:50:00 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=491</guid>
		<description><![CDATA[One of my sabbatical projects is MegaHAL.10, an entirely new version of the mildly popular chatterbot that I wrote and put online fifteen years ago. I&#8217;ve been writing it in Google&#8217;s Go programming language, and I recently started getting some exciting results. MegaHAL.10 generates sentences using a second-order Markov model. That means they tend to [...]]]></description>
			<content:encoded><![CDATA[<p>One of my sabbatical projects is MegaHAL.10, an entirely new version of the mildly popular chatterbot that I wrote and put online fifteen years ago. I&#8217;ve been writing it in Google&#8217;s Go programming language, and I recently started getting some exciting results.</p>
<p>MegaHAL.10 generates sentences using a second-order Markov model. That means they tend to be random walks; you start out with a blank slate, and you never know where you&#8217;ll end up. The only guarantee is that any sequence of three symbols will have previously been observed by the model.</p>
<p>These kinds of random generations may be quite amusing, but they&#8217;re not too useful when you&#8217;re trying to simulate a conversation, which requires that each generation adheres to the current context. What would be much better is if you could force the model to generate a sentence that has the desired Markovian properties, but which contains pre-determined keywords.</p>
<p>With the original MegaHAL I did this by starting at the keyword and using two Markov models to generate the sentence, one proceeding from the keywords forwards to the end of the sentence, and the other going in the opposite direction. That was a bit of a hack, and could only guarantee that the sentence contains a single keyword.</p>
<p>For MegaHAL.10 I&#8217;ve been experimenting with other strategies, including a Fractal slot-filling model and a family of Markov models, each of which generates towards a specified target symbol. Both of these took a template sentence as input, which specified the keywords and their order, and both suffered from several problems, such as the fact that it may be impossible to complete the template, and that the local grammaticalness condition may need to be violated to make the keywords join up.</p>
<p>Recently I had a brainwave: what if we generated with the standard Markov model, but weighted the generations based on another model that specified the <em>distance</em> to the desired keyword. We could then generate a directed random walk, similar to an A* pathfinding algorithm. We may not be able to guarantee that the resulting sentence contains the keywords we want, but chances are it will contain at least a few.</p>
<p>Some bugs still need to be ironed out (and some wrinkles squished), but my tests so far indicate that this method may be the missing link. I trained MegaHAL.10 on the entire collection of Sherlock Holmes stories, and then I asked it to generate a random sentence, specifying these ten keywords in advance:</p>
<p style="padding-left: 30px;">adventure foot wild scandal street twenty death finger villain rock</p>
<p>This is the sentence I got (I&#8217;ve highlighted the keywords):</p>
<p style="padding-left: 30px;">&#8220;<strong>Twenty</strong> had changed their position, and the <strong>street</strong> by the <strong>death</strong> of the <strong>adventure</strong> of the <strong>ROCK</strong> OF GIBRALTAR. From the dead scientist.  His <strong>wild</strong> flight to escape from her <strong>finger</strong> into the garden.  Perhaps the <strong>villain</strong> was able to take counsel how far we can hardly put my <strong>foot</strong> over the case of this question. I saw that a very remarkable man, that was this William doing there is to avoid <strong>scandal</strong>.&#8221;</p>
<p>To me that&#8217;s completely amazing. &#8220;Give me a sentence containing these ten words&#8221;, I said, &#8220;making sure that each sequence of three words in your sentence appears somewhere in the collected Sherlock Holmes stories.&#8221; And MegaHAL.10 delivered.</p>
<p>Just to prove it wasn&#8217;t a fluke, here are a few more, using the same keywords:</p>
<p style="padding-left: 30px;">&#8220;<strong>Twenty</strong> or thirty, I have seen <strong>death</strong> in the <strong>street</strong> by a strong family resemblance about misdeeds, and if you know now and so I dipped my <strong>finger</strong> on the ledge above the other hand had dropped his mask of his <strong>foot</strong> than might at any time before he was <strong>wild</strong>, wayward, and to our young companion looked at the young diplomatist&#8217;s window. There was this dark business which had been in the young lady.&#8221;</p>
<p style="padding-left: 30px;">&#8220;<strong>Villain</strong>! Scoundrel!&#8221; cried the old quarters. At the <strong>foot</strong> of the <strong>death</strong> of the <strong>street</strong>. Holmes looked eagerly round for it was <strong>twenty</strong> before her in the dead scientist.  His wild eyes, stained cheeks and He put a triumphant conclusion.</p>
<p style="padding-left: 30px;">&#8220;<strong>Death</strong> from some little distance down the <strong>street</strong> by a very simple chain: 1. You had a wild thrill as this was at the <strong>foot</strong> of the <strong>rock</strong> on each side of the <strong>adventure</strong> as a great <strong>scandal</strong> threatened to raise a <strong>scandal</strong> may well be cleared along those lines. Mr.  Douglas has spent a large coil from under the three strips. No <strong>finger</strong> impressions&#8211;no! Well, he is not here as I was at the other night.&#8221;</p>
<p>I&#8217;m planning to spend next week improving this algorithm, fixing various bugs, and optimising for memory and speed. I&#8217;ll then set to work creating a web version of MegaHAL.10, which will hopefully be going live before the end of the month.</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/11/06/megahal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Go</title>
		<link>http://kranzky.rockethands.com/2010/10/05/go/</link>
		<comments>http://kranzky.rockethands.com/2010/10/05/go/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 04:55:54 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=476</guid>
		<description><![CDATA[Yesterday I posted the following on Twitter: Why is the #golang community so much more holier-than-thou than the #ruby community? Harumph to all sanctimonious hackers. This got a concerned response from someone who works at Google as a &#8220;Go Gopher&#8221;, whatever that means. It also made me feel like a dirty troll, which wasn&#8217;t my [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I posted the following on Twitter:</p>
<blockquote><p>Why is the <a href="http://twitter.com/#search/%23golang" target="_blank">#golang</a> community so much more holier-than-thou than the <a href="http://twitter.com/#search/%23ruby" target="_blank">#ruby</a> community? Harumph to all sanctimonious hackers.</p></blockquote>
<p>This got a concerned response from someone who works at Google as a &#8220;Go Gopher&#8221;, whatever that means. It also made me feel like a dirty troll, which wasn&#8217;t my intention at all: I was just venting after a frustrating day.</p>
<p>When Google&#8217;s Go Programming Language was announced late last year I was fascinated. I loved the decisions they&#8217;d made regarding code formatting (the language enforces a particular standard, making debates about the right way of formatting code a moot point), dependency management (it&#8217;s a compile-time error to include something that you don&#8217;t use; streamlining your dependencies to speed up builds in C++ is a nightmare by comparison), and language features (defer, iota, interfaces and goroutines are all very cool). I read through the documentation, watched the videos and toyed around with the language a bit, but I didn&#8217;t dive in and get my hands (really) dirty straight away.</p>
<p>Recently, I&#8217;ve started working in earnest on the back-end for MegaHAL.10, an online chatterbot that can learn to talk in any language by example. That project has a few requirements that make Go an ideal language for the server-side code, including:</p>
<ol>
<li>The need to be fast, and to manipulate a lot of data in memory. This makes C or C++ an obvious choice, and discounts languages such as Ruby or Python. Go is a lot closer to C++ in terms of efficiency, so it&#8217;s a candidate for the implementation language.</li>
<li>The need to work with all human languages, meaning it&#8217;s important that the chatterbot engine supports UTF-8 end-to-end. All strings in Go are UTF-8 by design, whereas it&#8217;s fiddly to properly support UTF-8 in C++.</li>
<li>The server will need to handle many simultaneous requests, and the concept of goroutines is ideally suited to satisfying this requirement.</li>
</ol>
<p>So I started coding things up, and eventually ran into some problems that I couldn&#8217;t answer by reading through the provided documentation.</p>
<p>For example, consider the provided documentation for the sort package. The description is a brief &#8220;the sort package provides primitives for sorting arrays and user-defined collections&#8221;. Just what I need! Unfortunately, the documentation for the Sort method is no more than its specification, &#8220;<code>func Sort(data Interface)</code>&#8220;. That is all.</p>
<p>You can click through to see the implementation of Sort, revealing that it just calls through to quickSort. Great! I&#8217;ll look at the documentation for that. Unfortunately, there is none; quickSort is private (because it starts with a lowercase character), meaning that it doesn&#8217;t appear in the documentation at all, although its implementation is right there in the source.</p>
<p>So they&#8217;re hiding stuff from you in the docs, while at the same time recommending that you treat the source as documentation.</p>
<p>Now, this is a contrived example. I didn&#8217;t really need to look up documentation for Sort, but I did have several problems of this category with other packages and functions that I wanted to use. What I&#8217;m trying to illustrate here is how difficult they&#8217;ve made it for a newcomer to the language to get acquainted with things. Contrast this, for example, with the documentation for sort in Ruby:</p>
<blockquote>
<div class="method-heading"><a class="method-signature" href="http://ruby-doc.org/core/classes/Array.src/M002185.html" target="Code"> <span class="method-name">array.sort                   → an_array</p>
<p>array.sort {| a,b | block }  → an_array</span></a></div>
<div class="method-description">
<p>Returns a <a href="http://ruby-doc.org/core/classes/Array.html#M002150">new</a> array created by sorting <em>self</em>. Comparisons for the <a href="http://ruby-doc.org/core/classes/Array.html#M002185">sort</a> will be done using the <tt>&lt;=&gt;</tt> operator or using an optional code block. The block implements a comparison between <em>a</em> and <em>b</em>, returning -1, 0, or +1. See also <tt><a href="http://ruby-doc.org/core/classes/Enumerable.html#M003120">Enumerable#sort_by</a></tt>.</p>
<pre>   a = [ "d", "a", "e", "c", "b" ]
   a.sort                    #=&gt; ["a", "b", "c", "d", "e"]
   a.sort {|x,y| y &lt;=&gt; x }   #=&gt; ["e", "d", "c", "b", "a"]</pre>
</div>
</blockquote>
<p>It&#8217;s succinct and easy to understand, with clear examples and cross references to related functions. Exactly what you need to dive in and get started on something.</p>
<p>I&#8217;ve just finished working on <a href="http://www.faqoverflow.com/" target="_blank">FAQoverflow</a>, a fun little project that was implemented in two weeks using Ruby, and I rarely needed to look outside of the provided documentation when writing a fairly complicated API spider. When I did, I found the community polite, welcoming and useful. Consider, for example, this question to ruby-talk, made soon after the first version of Ruby was released in the west:</p>
<blockquote>
<pre>Ok,  I'm having trouble with an extremely simple class.
Here's my example:

class ABC
    def initialize( _v )
        @v = _v
    end
end

a = ABC ( 50 )
print a.v            # produced an ERROR

How would I access the variable "v" ?</pre>
</blockquote>
<p>This got an immediate reply from Matz, the creator of the language:</p>
<blockquote>
<pre>Example:

class ABC
    def initialize( _v )
        @v = _v
    end
    attr_accesser :v
end

a = ABC ( 50 )
print a.v
a.v = 25
print a.v</pre>
</blockquote>
<p>Now, that&#8217;s really helpful! Here&#8217; by contrast, is the first question I ever saw on golang-nuts (when searching to find out how the ternary operator worked):</p>
<blockquote><p>How can you call your self a C-like language and NOT have the <strong style="color: black; background-color: #ffff66;">ternary</strong></p>
<p><strong style="color: black; background-color: #a0ffff;">operator</strong>? But seriously, why isn&#8217;t it in Go? This could be a deal-</p>
<p>breaker for me, as it&#8217;s often more succinct and clear to use a <strong style="color: black; background-color: #ffff66;">ternary</strong></p>
<p><strong style="color: black; background-color: #a0ffff;">operator</strong> than an if/else, *especially* if you require curly braces</p>
<p>even for single-line blocks.</p></blockquote>
<p>And here&#8217;s the first answer:</p>
<blockquote><p>Then &#8220;go&#8221; write your own language or use a language that makes use of</p>
<p>your precious <strong style="color: black; background-color: #ffff66;">ternary </strong><strong style="color: black; background-color: #a0ffff;">operator</strong>.</p></blockquote>
<p>Ouch! That answered my question, but it certainly rubbed me the wrong way.</p>
<p>When you&#8217;re deeply focused on writing code, and jump to a browser to do a quick search, and the first thing you hit is a mean-spirited reply to a reasonable question, then it breaks your stride and leaves you with a foul taste in your mouth.</p>
<p>Of course, if this just happened a few times it wouldn&#8217;t be a problem. What concerned me is that throughout the day, whenever I searched for an answer to a question I had about Go, I <em>always</em> got a mean-spirited answer to a fair question. Sure, I admit I might have had an unlucky streak, and I admit that I usually read the first reply to each question due to my familiarity with Stack Overflow, whereby the first reply tends to be the best. But I just don&#8217;t encounter that with the Ruby community. And it was enough to make me stop looking to the forums for answers, which is a shame.</p>
<p>Some more examples of less-than-useful answers (paraphrased) that I encountered on the day I was working with Go:</p>
<ol>
<li>Q: &#8220;Having optional arguments to functions would be useful.&#8221;
<p>A: &#8220;In the rare instances you need them, make wrapper functions and give them unique names.&#8221;</p>
<p>Coming from Python and Ruby, I&#8217;d have to say that optional arguments, or arguments with sensible defaults, are far from a rarity, and are often extremely useful. And, no, I don&#8217;t believe that it&#8217;s good practice to create eight differently-named wrappers for a function that you&#8217;d like to have three optional arguments.</li>
<li>Q: &#8220;Why does strconv have functions to parse int and int64 but not int32?&#8221;
<p>A: &#8220;Because making a function for every possible integer type is tedious and clutters the interface.&#8221;</p>
<p>Clutters the interface? Really? Do you mean that the generated documentation gets a bit longer, meaning you have to scroll through it? Do you mean that you really shouldn&#8217;t need to specifically convert int8 and int32 from their string representation, ever? Or that if you do you should write that functionality yourself?</li>
<li>Q: &#8220;I was following the tutorial on the website, and it said&#8230; (a simple misunderstanding)?&#8221;
<p>A: &#8221; I don&#8217;t get the point.&#8221;</p>
<p>Thanks for sharing, but why not correct the obvious misunderstanding or be more specific about what it is that you don&#8217;t get?</li>
<li>Q: &#8220;The library code is &#8230; hard to learn from. I&#8217;d rather see short example programs.&#8221;
<p>A: &#8220;Rule one of problem solving: break it down into smaller problems, see rule zero.&#8221;</p>
<p>Right, so rather than provide short, concise usage examples in the documentation, you want me to dive into the source and spend time understanding the implementation of the functions I want to use?</li>
<li>Q: &#8220;I&#8217;m sure this is totally obvious, but I can&#8217;t seem to find it anywhere in the docs&#8230;&#8221;
<p>A: &#8220;One way to get answers to questions is to search the golang-nuts mailing list.&#8221;</p>
<p>Hmmm&#8230; dare I ask any questions at all?</li>
</ol>
<p>Now, yes, perhaps I&#8217;m being harsh. But when you&#8217;re struggling with something unfamiliar and new, it&#8217;s a godsend to find a superb resources such as <a href="http://www.ruby-doc.org/docs/ProgrammingRuby/" target="_blank">Programming Ruby</a> or <a href="http://www.rubyist.net/~slagell/ruby/" target="_blank">The Ruby User&#8217;s Guide</a> or <a href="http://mislav.uniqpath.com/poignant-guide/book/chapter-2.html" target="_blank">why&#8217;s (poignant) guide to Ruby</a> or the <a href="http://www.ruby-doc.org/stdlib/" target="_blank">Standard Library Documentation</a>, and these resources exist because the community cared enough to want to help newbies to understand why <em>they</em> fell in love with the language. Guess what? It <em>works</em>.</p>
<p>I just don&#8217;t get that feeling with the Go community at all. At the moment, it feels defensive and argumentative. Now, it may well be that Go is suited to a different class of problems than Ruby, and that the language is therefore going to be niche, appealing to systems programmers  only, and that it&#8217;s still immature and not really suited to production code. Fine. My problem is that it sure wasn&#8217;t marketed that way. The Go team claim that their language is an expressive, concise, clean,         and efficient language designed to make programmers more productive. Sounds good to me! Now if only I could learn to use it as such without banging my head against defensive, unhelpful, critical answers on golang-nuts.</p>
<p>So, Go Community, where should I be looking?</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/10/05/go/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Procedural Adventures</title>
		<link>http://kranzky.rockethands.com/2010/09/20/procedural-adventures/</link>
		<comments>http://kranzky.rockethands.com/2010/09/20/procedural-adventures/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 08:00:17 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=446</guid>
		<description><![CDATA[Apart from text adventures, I love point-and-click adventure games (of the Monkey Island ilk), and the more modern Japanese interpretations of this genre (such as Hotel Dusk and Another Code). These latter games tend to be more focused on telling a story, and the interface offered to the player is subsequently stripped down (with less [...]]]></description>
			<content:encoded><![CDATA[<p>Apart from text adventures, I love point-and-click adventure games (of the <em>Monkey Island</em> ilk), and the more modern Japanese interpretations of this genre (such as <em>Hotel Dusk</em> and <em>Another Code</em>). These latter games tend to be more focused on telling a story, and the interface offered to the player is subsequently stripped down (with less emphasis on navigating the environment and using objects on everything to see what might happen).</p>
<div id="attachment_462" class="wp-caption aligncenter" style="width: 310px"><a href="http://kranzky.rockethands.com/wp-content/uploads/2010/09/LA-Noires-Cover-Story-Unveiling-Revealed.jpg"><img class="size-medium wp-image-462" title="LA-Noires-Cover-Story-Unveiling-Revealed" src="http://kranzky.rockethands.com/wp-content/uploads/2010/09/LA-Noires-Cover-Story-Unveiling-Revealed-300x178.jpg" alt="L.A. Noire" width="300" height="178" /></a><p class="wp-caption-text">Sandbox + narrative? Image by GameInformer.</p></div>
<p>On the other hand, I&#8217;d love to see a sandbox adventure game, which places the player in a vast world that they are free to explore. Such a game would render the usual approach of playing an adventure game (go everywhere, examine everything, pick up everything, talk to everyone) impractical. It would be interesting to see what would happen if you were free to explore an enormous environment in which a story could be told based upon what you do, not in spite of it.</p>
<p>Strangely enough, I once worked on such a game. When I worked on <a href="http://www.rockstargames.com/lanoire/" target="_blank">L.A. Noire</a> I was particularly interested in the problem of bringing story to the player in large sandbox environments, and of procedurally generating a massive population of NPCs who went about their daily business in realistic ways. I would love to write a text adventure game that used some of these techniques to produce an experience truly different to anything else out there.</p>
<p>Yes, I&#8217;m the kind of guy that just hung out and watched a shopkeeper go about his business in Shenmue for the entire day-night cycle, and who tails pedestrians in GTAIV to see where they go. I love that kind of stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/09/20/procedural-adventures/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FAQoverflow</title>
		<link>http://kranzky.rockethands.com/2010/09/06/faqoverflow/</link>
		<comments>http://kranzky.rockethands.com/2010/09/06/faqoverflow/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 05:00:27 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[Happiness]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=399</guid>
		<description><![CDATA[StackOverflow is a Q&#38;A website for professional programmers. Joel Spolsky and Jeff Atwood developed the concept as a direct competitor to Expert Sex Cha&#8230; errr, Experts Exchange, and I now find that answers on StackOverflow are often in the top few results when I search Google for geeky, programmer-type stuff. They&#8217;re doing some good things; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://stackoverflow.com/" target="_blank">StackOverflow</a> is a Q&amp;A website for professional programmers. <a href="http://www.joelonsoftware.com/" target="_blank">Joel Spolsky</a> and <a href="http://www.codinghorror.com/" target="_blank">Jeff Atwood</a> developed the concept as a direct competitor to Expert Sex Cha&#8230; errr, <a href="http://www.experts-exchange.com/" target="_blank">Experts Exchange</a>, and I now find that answers on StackOverflow are often in the top few results when I search Google for geeky, programmer-type stuff. They&#8217;re doing some good things; I liked the <a href="http://blog.stackoverflow.com/category/podcasts/" target="_blank">podcasts</a> they recorded while the site was being developed, and I&#8217;m excited that all user-contributed content is <a href="http://creativecommons.org/licenses/by-sa/2.5/" target="_blank">cc-wiki</a> licensed, allowing it to be shared and remixed.</p>
<div id="attachment_400" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.codinghorror.com/blog/2008/09/stack-overflow-none-of-us-is-as-dumb-as-all-of-us.html"><img class="size-full wp-image-400" title="stack_overflow" src="http://kranzky.rockethands.com/wp-content/uploads/2010/09/6a0120a85dcdae970b012877705432970c.jpg" alt="Stack Overflow" width="600" height="503" /></a><p class="wp-caption-text">Stack Overflow. Image by Jeff Atwood.</p></div>
<p>Joel and Jeff reused the Q&amp;A Engine they developed for StackOverflow to power a couple of related websites, <a href="http://serverfault.com/" target="_self">ServerFault</a> and <a href="http://superuser.com/" target="_blank">SuperUser</a>, and then attempted to monetise the whole shebang by offering <a href="http://stackexchange.com/" target="_blank">StackExchange</a>, providing hosted Q&amp;A websites on any topic to whomever was prepared to pay a steep monthly hosting fee. That didn&#8217;t work out so well.</p>
<p>Not ones to give up, Joel and Jeff tried Plan B, visiting a whole bunch of VCs in a whirlwind tour, raising US$6m in two weeks. They then returned to the drawing-board, coming up with <a href="http://area51.stackexchange.com/" target="_blank">StackExchance2.0</a>, which is totally free, and whereby new Q&amp;A sites are born via a community proposal process, which is how the USENET newsgroups of yore were created. It seems to be going swimmingly, and there are now about a dozen new Q&amp;A websites in open beta on topics that include <a href="http://cooking.stackexchange.com/" target="_blank">Cooking</a>, <a href="http://bicycles.stackexchange.com/" target="_blank">Bicycles</a>, <a href="http://diy.stackexchange.com/" target="_blank">Home Improvement</a> and <a href="http://money.stackexchange.com/" target="_blank">Personal Finance</a>.</p>
<p>Many of the questions and answers across all of the websites in the StackExchange family are interesting to browse. As a StackOverflow user, I&#8217;ve been creating accounts on all of the new sites as they go into open beta, but, unless you&#8217;re really motivated to ask questions or write answers (and they do their darndest to motivate you, with XBLA-style achievements, points and leaderboards), you&#8217;ll find it difficult just to browse the sites for enjoyment.</p>
<p>Late last week I discovered two things that I hope will change that.</p>
<ol>
<li>They&#8217;ve released a <a href="http://blog.stackoverflow.com/2010/05/stack-exchange-api-public-beta-starts/" target="_blank">public API</a> that&#8217;s super clean and powerful. It&#8217;s easy to browse if you have the JSONview Firefox extension, and really easy to access from script.</li>
<li>Amazon have, finally, implemented <a href="http://aws.amazon.com/about-aws/whats-new/2010/08/05/cloudfront-adds-default-root-object-capability/" target="_blank">default root object capability</a> for <a href="http://aws.amazon.com/cloudfront/" target="_blank">CloudFront</a>, making it possible to serve a static website entirely from <a href="http://aws.amazon.com/s3/">S3</a>.</li>
</ol>
<p>I&#8217;m currently writing a Ruby script that will spider all of the StackExchange Q&amp;A websites, with the intention of finding the 100 best question-answer pairs for each site (as determined by a metric that takes into account many things, such as the brevity of the question and answer, the number of upvotes the question received, and the difference between the upvotes received by the first and second answers). These question-answer pairs will be grouped into ten buckets, based on the tags associated with the questions. All of this will then drive a new website, <a href="http://www.faqoverflow.com/" target="_blank">FAQoverflow</a>, which purports to contain &#8220;great answers to questions about everything&#8221;. The site will be easy to browse (even on your iPhone), using styling inspired by <a href="http://lab.arc90.com/experiments/readability/" target="_blank">Readability</a>. And there&#8217;ll be PDF and eBook editions of the FAQ available for download. It&#8217;ll all be built automagically via a script that publishes a new edition every week or so, and will be user-supported (I&#8217;ll ask for donations from the community to pay the minimal hosting bill).</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/09/06/faqoverflow/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Solving Puzzles, circa 199*</title>
		<link>http://kranzky.rockethands.com/2010/07/22/solving-puzzles-circa-199/</link>
		<comments>http://kranzky.rockethands.com/2010/07/22/solving-puzzles-circa-199/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 09:51:49 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[History]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=267</guid>
		<description><![CDATA[I had absolutely no sleep at all last night, which is why I spent today in a stupor, content with reading news and pottering about rather than Doing Something Challenging. This explains why I started doing some vanity searches this afternoon, digging up an old web-page of mine from the mid-1990&#8242;s. Yes, it used TABLEs [...]]]></description>
			<content:encoded><![CDATA[<p>I had absolutely no sleep at all last night, which is why I spent today in a stupor, content with reading news and pottering about rather than Doing Something Challenging.</p>
<p>This explains why I started doing some vanity searches this afternoon, digging up an old web-page of mine from the mid-1990&#8242;s. Yes, it used TABLEs for formatting (back then, it was common to UPPERCASE your HTML). Yes, it included a count of page views at the bottom of each and every page. And, yes, it even included a link to my &#8220;hotlinks&#8221; which I could access when using &#8220;Netscape&#8221; from home, over my swanky 14.4 dialup connection (presumably when I could drag myself away from playing with my PlayStation).</p>
<p>One of my old web pages was about number problems. I used to have fun writing programs to solve puzzles such as these by brute force:</p>
<blockquote><p>Which numbers satisfy the following property&#8230; the sum of the individual digits of the number raised to the power of that digit is equal to the number itself?  For the purpose of this problem, we define 0^0=0.</p>
<p>For example, the number 3435 is known to have this property, since 3^3 + 4^4 + 3^3 + 5^5 = 3435.</p>
<p>This problem proved rather easy to solve.  We know that no numbers above 10*9^9 (about 4e9) can have this property, simply because the sum will always be less than the original number.  Therefore we can solve the problem by brute force, using unsigned 32-bit integers.</p>
<p>I wrote such a program, and it took a few hours to execute on our SGI Onyx computer.  The solution set is { 0, 1, 3435, 438579088 }.</p></blockquote>
<p>And here&#8217;s my program:</p>
<pre class="brush:cpp">#include &lt;stdio.h&gt;

typedef unsigned long INT;

int main(int argc, char **argv)
{
	INT number;
	INT sum;
	INT num;
	INT power[]={0,1,4,27,256,3125,46656,823543,16777216,387420489};

	for(number=0; number&lt;4e9; ++number)
    {
		sum=0;
		num=number;

		do {
			if((sum+=power[num%10])&gt;number) break;
		} while(num/=10);

		if(number==sum) printf("%d\n", number);
	}

	return(0);
}</pre>
<p>It&#8217;s almost unbelievable that such a program used to take &#8220;a few hours&#8221; to run on a machine that was, at the time, a veritable power horse. Today I compiled and ran it on my grungy lappy. It burned one core for a few minutes to find the same solution. All the while, my computer remained snappy, and I actually became impatient waiting for the answer. What have we become? Why aren&#8217;t we doing more, now that we all carry around supercomputers with us?</p>
<p>Funny thing is, my website was averaging 1800 hits per day back in the mid-90&#8242;s. This blog, by comparison, barely manages 10. Well, phooey.</p>
<h2>Update: Optimisations</h2>
<p>On my desktop at work, this same program ran in 150 seconds, using a  quarter of the total processing power of the machine. That’s something  like 26 million numbers checked every second. That would have seemed  like magic 13 years ago, when the Onyx was checking half a million  numbers each second.</p>
<p>Beetlefeet asked about the optimisations mentioned in my  comment below. Each optimisation sped up processing by a factor of 10 or so.  I’ve re-run them on my desktop. The first completes in 45 seconds, and  the second completes in around 5 seconds, so they still count for  something!</p>
<p>The first optimisation, by David Conrad, worked by keeping a running total of the  current value, modifying it each time around the loop based on how the  digits in the number changed. It printed the result whenever the number  equalled this running total. Here’s the code:</p>
<pre class="brush:cpp">#include &lt;stdio.h&gt;

int digit[10] = {0,0,0,0,0,0,0,0,0,0};
long diff[10] = {-387420489,1,3,23,229,2869,43531,776887,15953673,370643273};

int main(void)
{
    unsigned long x = 0, val = 0;
    int i;
    while (x &lt; 4e9) {
        if (x == val) printf("%lu\n", x);
        i = 0;
        digit[i] = digit[i] == 9? 0 : digit[i]+1;
        val += diff[digit[i]];
        while (digit[i] == 0) {
            i++;
            digit[i] = digit[i] == 9? 0 : digit[i]+1;
            val += diff[digit[i]];
        }
        x++;
    }
    return 0;
}</pre>
<p>The second optimisation, by Geoff Bailey (AKA Fred the Wonder Worm), was really clever; it maintained a running  total too, but worked by looping over 10 variables, one that represented  each digit. Here’s the code:</p>
<pre class="brush:cpp">#include &lt;stdio.h&gt;

typedef unsigned long   ulong;

long diffs[] = {
    1, 3, 23, 229, 2869, 43531, 776887, 15953673, 370643273, -387420489
};

main()
{
    ulong       sum, n;
    int         i0,i1,i2,i3,i4,i5,i6,i7,i8,i9;

    sum = 0;
    n = 0;

#define LOOP(var, lim, code)	\
    for (var = 0; var &lt; lim; sum += diffs[var++])	code

    LOOP(i9, 4,
    LOOP(i8, 10,
    LOOP(i7, 10,
    LOOP(i6, 10,
    LOOP(i5, 10,
    LOOP(i4, 10,
    LOOP(i3, 10,
    LOOP(i2, 10,
    LOOP(i1, 10,
    LOOP(i0, 10,
    {
        if (n == sum)
            printf("%lu\n", n);
        n++;
    }
    ))))))))))
    return 0;
}</pre>
<p>I guess that optimisation and obfuscation are closely related  (although you don’t always get faster code by making it harder to  understand).</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/07/22/solving-puzzles-circa-199/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Great Productivity Experiment</title>
		<link>http://kranzky.rockethands.com/2010/05/31/the-great-productivity-experiment/</link>
		<comments>http://kranzky.rockethands.com/2010/05/31/the-great-productivity-experiment/#comments</comments>
		<pubDate>Mon, 31 May 2010 02:53:13 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Happiness]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=250</guid>
		<description><![CDATA[2010 was to be my year of &#8220;no unfinished project&#8221;. I tried really hard to work 10 hours a week on &#8220;Postal Worker&#8221;, but slotting in two hours of development time between 9am and 1am each weeknight resulted in burnout (we have a new baby in the house, and I just couldn&#8217;t continue to burn [...]]]></description>
			<content:encoded><![CDATA[<p>2010 was to be my year of &#8220;no unfinished project&#8221;. I tried really hard to work 10 hours a week on &#8220;Postal Worker&#8221;, but slotting in two hours of development time between 9am and 1am each weeknight resulted in burnout (we have a new baby in the house, and I just couldn&#8217;t continue to burn the candle at both ends). Rather than fail, I&#8217;ve decided to quit my job and spend the rest of 2010 working on personal projects, including Postal Worker, so expect to see a whole lot more bloggage going on around here. And, if you&#8217;d like details, <a href="http://us1.campaign-archive.com/?u=bf7356f5a082577d7ce1b5056&amp;id=3f86659be1" target="_blank">here&#8217;s the first group email</a> I sent out to friends and family (you can subscribe to the list from this blog; there should be a signup over there on the right).</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/05/31/the-great-productivity-experiment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postal Worker Pause!</title>
		<link>http://kranzky.rockethands.com/2010/02/01/postal-worker-pause/</link>
		<comments>http://kranzky.rockethands.com/2010/02/01/postal-worker-pause/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 13:00:28 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[GGJ]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=158</guid>
		<description><![CDATA[I plan to take a bit of time off to (a) recover from the fantastic Global Game Jam that was held over the weekend and (b) check out some of the other Global Game Jam games. Big props to Simon Wittber for organising such a great event, and well done to all who took part! [...]]]></description>
			<content:encoded><![CDATA[<p>I plan to take a bit of time off to (a) recover from the fantastic Global Game Jam that was held over the weekend and (b) check out some of the other Global Game Jam games. Big props to <a href="http://entitycrisis.blogspot.com/">Simon Wittber</a> for organising such a great event, and well done to all who took part!</p>
<p>I went into GGJ with the intention of developing a Flash game, even though I&#8217;d never done that before, and didn&#8217;t know my ActionScript from my Objective C. It was a long haul; I worked around 40 hours in a single weekend (the equivalent of a normal working week), and I did all of the design and implementation myself (although <a href="http://www.pricklypixel.com/">Pazu</a> and <a href="http://www.facepocalypse.com/">Sizzle</a> helped with graphics, and I used some other freely available assets).</p>
<p>So, without further ado, I humbly request that you <a href="http://rockethands.com/BogusQuest">check out and vote for Bogus Quest</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2010/02/01/postal-worker-pause/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HDMI</title>
		<link>http://kranzky.rockethands.com/2009/04/30/hdmi/</link>
		<comments>http://kranzky.rockethands.com/2009/04/30/hdmi/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 15:45:42 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=94</guid>
		<description><![CDATA[I&#8217;m in the market for a small-ish computer monitor with integrated speakers and HDMI input, to sit on my desk and make it easier to do XBLA development, by having the XBOX right there, ready to go, at all times. Looks like it&#8217;ll be around $250 for a 22&#8243; 16:9 jobbie, which is a bit [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the market for a small-ish computer monitor with integrated speakers and HDMI input, to sit on my desk and make it easier to do XBLA development, by having the XBOX right there, ready to go, at all times. Looks like it&#8217;ll be around $250 for a 22&#8243; 16:9 jobbie, which is a bit on the large side. Hopefully I&#8217;ll pick me up something tomozza, so I can have it for the weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2009/04/30/hdmi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gamejam</title>
		<link>http://kranzky.rockethands.com/2009/04/28/gamejam/</link>
		<comments>http://kranzky.rockethands.com/2009/04/28/gamejam/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 14:13:19 +0000</pubDate>
		<dc:creator>Lloyd Kranzky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://kranzky.rockethands.com/?p=90</guid>
		<description><![CDATA[A new gamejam starts on Friday.  Tonight a mixer event was held in anticipation, during which hotdogs were consumed and the theme was announced: A journey is best measured in friends, rather than miles. In addition, each game needs to incorporate, somehow, at least one of these three keywords: Sheep Scorched Reflection Thinking!]]></description>
			<content:encoded><![CDATA[<p>A new gamejam starts on Friday.  Tonight a mixer event was held in anticipation, during which hotdogs were consumed and the theme was announced:</p>
<blockquote><p>A journey is best measured in friends, rather than miles.</p></blockquote>
<p>In addition, each game needs to incorporate, somehow, at least one of these three keywords:</p>
<ul>
<li> Sheep</li>
<li>Scorched</li>
<li> Reflection</li>
</ul>
<p>Thinking!</p>
]]></content:encoded>
			<wfw:commentRss>http://kranzky.rockethands.com/2009/04/28/gamejam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

