Archive for the ‘Karthik's’ Category

The Hill Titan Cometh

Sunday, March 18th, 2012

What happens if you force an overburdened camel to trudge through waist high water for days on end? It decides it has had enough, apparently:

A humpy ride

A humpy ride

Watching this unfold made me realize that in a way, this was all I’ve ever wanted from a video game. It’s the fulfillment of the promise of a fully realized virtual world. It’s emergence: “The rise of complex systems and the revelation of patterns from a multiplicity of simple interactions.”

Welcome to Dwarf Fortress, and let us tell you a story. “Us” refers to Dwarf Fortress–the dwarven life & death simulator–and me, because we created this story together.

Welcome to Mabduganam Febontak, the Ashen Blind Arrow Arm.

"Ashen Blind Arrow Arm" is oddly fitting for this story

"Ashen Blind Arrow Arm" is oddly fitting for this story

What you’re seeing is the residential wing of the fortress. There is no easy way for me to show you the fortress because it extends for several leagues into the earth, past forges and smelting grounds, unexplored caverns and metal ore veins all the way into rivers of magma. But today’s story concerns the surface, the hills and the wilderness that lie beyond the maw of my dwarven city.

It concerns the arrival of the Hill Titan Erthok.

The austere look is what gets me

The austere look is what gets me

He is big, he is tough and he is on fire. No mere dragon this one–all dragons do is breathe fire and swoop. This thing is an infernal beast, an encaged inferno, bringing destruction in his wake, scorching the very land he treads on and leaving behind smoke, ash and cinders. He is a frickin’ force of nature, setting the entire valley on fire in seconds.

The inferno looks like an inferno when playing, I assure you

The inferno looks like an inferno when playing, I assure you

(more…)

The Illegal Prime

Monday, August 9th, 2010

Hello, reader. An offering, for your perusal:

It’s unbelievable today, but there was a time when the government classed crypto as a munition and made it illegal for anyone to export or use it on national security grounds. Get that? We used to have illegal math in this country.

The National Security Agency were the real movers behind the ban. They had a crypto standard that they said was strong enough for bankers and their customers to use, but not so strong that the mafia would be able to keep its books secret from them. The standard, DES-56, was said to be practically unbreakable. Then one of EFF’s millionaire co-founders built a $250,000 DES-56 cracker that could break the cipher in two hours.

Still the NSA argued that it should be able to keep American citizens from possessing secrets it couldn’t pry into. Then EFF dealt its death-blow. In 1995, they represented a Berkeley mathematics grad student called Dan Bernstein in court. Bernstein had written a crypto tutorial that contained computer code that could be used to make a cipher stronger than DES-56. Millions of times stronger. As far as the NSA was concerned, that made his article into a weapon, and therefore unpublishable.

Well, it may be hard to get a judge to understand crypto and what it means, but it turned out that the average Appeals Court judge isn’t real enthusiastic about telling grad students what kind of articles they’re allowed to write. The crypto wars ended with a victory for the good guys when the 9th Circuit Appellate Division Court ruled that code was a form of expression protected under the First Amendment — “Congress shall make no law abridging the freedom of speech.” If you’ve ever bought something on the Internet, or sent a secret message, or checked your bank-balance, you used crypto that EFF legalized. Good thing, too: the NSA just isn’t that smart. Anything they know how to crack, you can be sure that terrorists and mobsters can get around too.

From the amazing (and edifying!) Little Brother, by Cory Doctorow. But no, this little burst of text isn’t about this (scary) modern day dystopian novel, or the EFF, or crypto, or security. It’s about a 1401 digit prime number that showed up in my feeds, via Everything2, a mystery in a puzzle in a mystery. It’s about Unix, and about peeling back layers. This prime number is illegal. I’m going to paste it anyway, then tell you why:

48565078965739782930984189469428613770744208735135792401965207366869
85134010472374469687974399261175109737777010274475280490588313840375
49709987909653955227011712157025974666993240226834596619606034851742
49773584685188556745702571254749996482194184655710084119086259716947
97079915200486670997592359606132072597379799361886063169144735883002
45336972781813914797955513399949394882899846917836100182597890103160
19618350343448956870538452085380458424156548248893338047475871128339
59896852232544608408971119771276941207958624405471613210050064598201
76961771809478113622002723448272249323259547234688002927776497906148
12984042834572014634896854716908235473783566197218622496943162271666
39390554302415647329248552489912257394665486271404821171381243882177
17602984125524464744505583462814488335631902725319590439283873764073
91689125792405501562088978716337599910788708490815909754801928576845
19885963053238234905580920329996032344711407760198471635311617130785
76084862236370283570104961259568184678596533310077017991614674472549
27283348691600064758591746278121269007351830924153010630289329566584
36620008004767789679843820907976198594936463093805863367214696959750
27968771205724996666980561453382074120315933770309949152746918356593
76210222006812679827344576093802030447912277498091795593838712100058
87666892584487004707725524970604446521271304043211826101035911864766
62963858495087448497373476861420880529443

What is it for?

When written in base 16 (hexadecimal), this 1401 digit prime number found by Phil Carmody forms a gzip file of the C-source code that decrypts the DVD Movie encryption scheme (DeCSS). This prime number is illegal in every country that the DMCA applies.

Wow.

If you’re like me, you’re firing up a terminal right now to unfurl the layers one after another, driven by burning curiosity to see what the seed contains. If you’re not… well, aren’t you a little curious? Of course your are.

Let’s get on a Unix shell and start peeling.


Getting the number

If you select all of the digits in the number above using your mouse, you’ll pull in a lot of newline (and/or carriage return) characters, even if you try copying the HTML source. If you’re going to deal with HTML source anyway, let’s make this easy on ourselves.

I read about it on Everything2, and you can use this URL to access the number from there, or you could use the URL to this page itself.

Now we pull down the HTML so we can easily parse the number:

$ curl -s http://rightshift.info/?p=463

That should spew out the HTML containing this number. If ‘curl’ is not your thing, try wget to save to a file, or use the browser itself, and replace the above by ‘cat your filename’.

Next, let’s find this block of text. It’s preformatted with either a <blockquote> or <pre> tag, so we use that in a regular expression. There may be more than one preformatted section in the page, so we use a dirty hack in the pattern matching: Let’s put in the first few digits of the number in the pattern so the other blockquotes don’t match.

$ curl -s http://rightshift.info/?p=463 | awk '/(<pre>|<blockquote>).*4856.+(<\/pre>|<\/blockquote>)/ {print}'

We could have used grep instead of awk, but we’ll get to that in a moment. If the command works, you should see the illegal prime on screen with a bunch of <br> and other tags mixed in. Let’s get rid of those, shall we?

$ curl -s http://rightshift.info/?p=463 | awk '/(<pre>|<blockquote>).*4856.+(<\/pre>|<\/blockquote>)/ {gsub(/[^[:digit:]]/,""); print}'

The gsub performs a global substitution on any character that is not a digit , /[^[:digit:]]/. This should print just the number on the screen. Things will get very unwieldy soon, so we’ll store this number (actually a string) into a variable. In Bash, the only way to do this is:

$ prime=$(curl -s http://rightshift.info/?p=463 | awk '/(<pre>|<blockquote>).*4856.+(<\/pre>|<\/blockquote>)/ \
{gsub(/[^[:digit:]]/,""); print}')

Note the ‘\’ followed by a newline, splitting the command onto two lines. If you were typing this, you don’t need to include either.


Converting it to hex

To see $prime in hex, we use bc, the handy command line calculator:

$ echo "obase=16; $prime" | bc

This should print out the number in Hex. Here are the first few bytes:

1F8B0808196C9A3A00036373732D6465736372616D626C652E6300ED56CD8E9B3010\
BEF314F412E140241B304B95984B1F618F164859205D2B4BB64AA65B56BB79F70EE1\
2736F1A1552F6DB51...

Oops. bc considered it appropriate to put end of line markers, \ splitting the text across multiple lines. Let’s get rid of them, using tr, the text replacement utility:

$ echo "obase=16; $prime" | bc | tr -d '\\\n'

There are three \’s in the text we’re deleting because one of them’s part of ‘\n’, one of them is a literal backslash that’s escaped by the shell, and the third one’s there to keep the second one from being escaped. Phew.

As a check, here’s what the gzip specification says about the header to any gzip file:

The first two bytes have the fixed values ID1 = 31 (0×1f, 037), ID2 = 139 (0×8b, 213), to identify the file as being in gzip format.

1F8B, indeed. We’re almost there.


Dumping it into a binary file

The above stream can’t be unzipped! This sure bewildered for a few minutes. I suppose this is what happens when your mental model of the computer’s storage structure is as badly broken as mine.

Of course it can’t be unzipped. It’s an ascii stream of hex characters; still an ascii stream! We need to dump the above hex code into a binary file.

How do we do that? Sure, you can write some code in C to do it. (Scan as hex and use putchar().)
But you know what they say about Unix: If you need to do it, it’s been done. Hmm. Let’s search for a bit:

$ apropos --and hex dump
hd (1)               - ASCII, decimal, hexadecimal, octal dump
hexdump (1)          - ASCII, decimal, hexadecimal, octal dump
xxd (1)              - make a hexdump or do the reverse.

Slowly I realize how true this adage is. Enter xxd. Some thinking reveals that we need to do a reverse hex dump. A hex dump is where the contents of a binary file are printed out as a stream of ascii-encoded hex characters, we’re trying to do the opposite. After reading the man page, we construct the reverse hex dump:

$ echo "obase=16; $prime" | bc | tr -d '\\\n' | xxd -r -p

If all goes well, we shoud see a stream of unprintable characters (no, not that type) desperately trying to print themselves on the screen.


On to the source

The rest is trivial. We have the gzipped stream pouring through ‘xxd‘, so let’s redirect that:

$ echo "obase=16; $prime" | bc | tr -d '\\\n' | xxd -r -p | zcat

And that’s it. If ‘zcat‘ doesn’t work, for some reason, try ‘gunzip -c‘.

The illegal source code hidden in the illegal prime should be floating on your screen now.

What, you thought I’d put it here? It’s illegal.

Probably more illegal than printing the number, anyway. If you skipped to the end hoping to glance at the code, here’s an unreadable composite command for you, instead. (Again, note the line breaking ‘\’ after awk’s first argument, added to keep this webpage from breaking.) Hide your eyes, they who fear line noise:

$ curl -s http://rightshift.info/?p=463 | awk '/(<pre>|<blockquote>).*4856.*(<\/pre>|<\/blockquote>)/ \
{gsub(/[^[:digit:]]/,""); print "obase=16;" $0}' | bc | tr -d '\\\n' | xxd -r -p | zcat

Or, you know, you could just read the code on Wikipedia. I didn’t. I don’t know anything about crypto, but I expected a certain kind of joy in deciphering this simple code, something I could actually hope to do. I wasn’t disappointed.

The wormhole

Now, the DMCA isn’t at odds with the opening excerpt: It’s all right to write code that does absolutely anything, and it may be all right to distribute it, but it’s illegal (by the DMCA) to use it to break copy-protection measures.

Except for one little thing, though. There is still illegal math.

A request, then: Someone explain that C source to me!


Further reading:

  • Little Brother, as described by Cory Doctorow: “This book is meant to be part of the conversation about what an information society means: does it mean total control, or unheard-of liberty? It’s not just a noun, it’s a verb, it’s something you do.”
    This book is licensed under Creative Commons, and is free to download. It’s also a cracker of a novel.

  • Regular expressions are awesome. I cannot stress this enough. If you want to see a whimsical but fantastic use of regexes, try this.

  • Phil Carmody’s Titanic Primes. See for yourself.

  • The gzip specification: Just to see what goes into making a standard. Why did they pick 1F8B as the gzip header, for instance?

  • The Unix utilities awk, bc, tr and curl. The entire GNU coreutils pack is awesome, more functionality than you can ever need in a terse, powerful set of commands.

  • Hex Dump Code Golf, a game played by the Stack Overflow community where the objective is to write a reverse hex dump in the language of your choice in the fewest chars possible. Perl won.

Scaling (I)

Tuesday, January 12th, 2010

There are presumably many clever, interesting and useful tools and ideas in science and math modeling. The concept of scaling, though, is the most powerful one I’ve seen in that it makes very nontrivial predictions with just small helpings of information.

Let’s start at the top. To scale an object means to multiply its every linear dimension by the same factor. It’s what you would expect: a geometric shrinking or enlarging, like under a microscope1.

Now, attributes of this object scale in different ways. If every linear dimension of the object is multiplied by a factor n, then the surface area and volume of the object go up by factors of n^2 and n^3 respectively. Depending on how we physically accomplish the scaling, either the mass of the object scales as n^3 or its density scales as 1/n^3. (Stretching the original object preserves the mass but lowers the density by the above factor; creating a scaled-up replica retains the density but increases the mass by the above factor.)2

Forces scale in different ways:

1. Let’s say you have two hot metal plates identical in shape with a ratio of surface areas of n^2. The force of gravity on the larger of the scaled objects is n^3 times that on the smaller one.

2. If the two metal plates were tenderly rested on the surface of water, the force of surface tension on the larger one would be n times that on the smaller one, because surface tension is proportional to the length in contact with the liquid. This explains why you can’t float a steel knitting rod on the surface of water, but you can float a steel pin. The surface tension holding the steel pin up is smaller by a factor of about 10, but the pin is lighter by a factor of about 1000.

3. The force you need to break the larger plate by tugging along its length is n^2 times that needed to break the smaller one in the same way.

4. If you were to pull these plates through molasses, the forces of drag on the plates due to the molasses do not scale in an elementary way- but to a first approximation, the drag force is proportional to the surface area. This means the drag is higher on the larger plate by a factor of (approximately) n^2.

And rates of processes scale too. The bigger one would lose heat that much faster. This does not mean that it cools faster! If they are at the same temperature to begin with, the larger plate would lose heat at a rate n^2 higher than the smaller one, because this rate is proportional to its surface area. The amount of heat it needs to lose for its temperature to go down by a degree, however, is n^3 times higher than the amount the smaller plate does, because this quantity is proportional to its mass. This means it takes the larger plate about n^3/n^2 = n times longer to cool down by the same degree.

The above scaling relations hold because of the simple physics that applies. Actually, when the physics gets complicated, scaling rules still hold; it’s just that geometric similarity is not a fruitful pursuit anymore. There are more abstract ways of using scales to work with the system- a bit more on this towards the end.

This is where things get really interesting. Everything, including living things, are subject to the above rules, and we can make some remarkable observations about the design of insects and animals:

The ant is known to carry several times its own weight. Why can’t we do this?

First, let’s see how an ant would fare if it were about the size of a human. Much of the ant is strong tubes filled with mushy insides. (Insects have exoskeletons, like the ants’ chitin.) If you were to breed a six foot tall ant, the weight of the ant would scale as 10^9, and the load bearing cross-section of the chitin in its legs would go up by a factor of 10^6.

This means the stress in its legs would go up by a factor of 10^9/10^6 = 1000. The super-ant would break its legs just by standing!3

How about load-bearing capacity? The forces its muscles could exert would scale as the square of the linear dimension. (The force a muscle can exert is proportional to its cross sectional area). In this case, the square of (2 m/ 2 mm), which is about 10^6. A regular ant can lift at least twenty times its own weight; if the super-ant were to try this, the stress on its muscles would be 10^9/10^6 = 1000 times that of the regular ant.4 Its muscles would rip.

Not so super now, eh?

Conversely, it follows that since you can stand on our legs without collapsing, you will be at least as strong as the ant when you’re shrunk to its size. You can do the calculations; the general idea is that the capacity of a muscle-driven creature to bear it’s own body weight (or any multiple of it) goes as 1/length of the creature.

The scaling rules tell us that everything will be different when we’re shrunk by a factor of a thousand. From the example of the floating steel pin above, it follows that you should be able to walk on water, so long as it’s relatively calm. You don’t need a pitcher to carry around water; you can hold it in your hand like you would a football. It would take no effort at all to drink it- the super-powerful capillary effect would force it down your throat if you brought your mouth close to it. And yeah, you can hold your own against insects. You would be the iron man (or woman) of the insect world.

It’s not all rosy, though. From the cooling example above, it follows that your body would cool a factor of 1000 faster. (Surface area/Body mass = 1/1000) You would probably die of hypothermia unless you were consuming food all the time. Not only can you lift many times your body weight, you’d have to eat many times your body weight in a day!5

On the other hand, if you were scaled up by a factor of 80 (say) you would suffer the same fate as the super-ant. Your legs can only bear a load 5-6 times more than they already do when you run or jump- and the stress in your bones would be a factor of 80 higher even when mega-you were just standing still! Your knees would buckle and shatter, smashing every bone in your body as you hit the ground. Your muscles will have torn, and the hydrostatic pressure of the blood in your body acting over a height of 100 m would have forced it down your arteries before rupturing them and causing hemorrhaging. For the same reasons whales do, however, you would survive rather well in the water!

While we’re being squeamish:

As J.B.S. Haldane put it in his classic essay, “On Being the Right Size,” “You can drop a mouse down a thousand-yard mine shaft; and, on arriving on the bottom, it gets a slight shock and walks away….A rat is killed, a man broken, a horse splashes.” Haldane was being quite literal.

These facts were known to our ancestors, who used this aspect of scaling to gruesome effect—a common strategy during medieval sieges was to take a carcass of a horse, let it ripen for a few days in the sun, and then catapult it over the walls of the besieged town. On impact, the carcass would indeed splash, spreading contagion throughout the city.6

Wow!

The above is an extract from a wonderful article about scaling in biology that goes into much greater detail of hypothetical changes of scale- highly recommended!

This short foray into design in biology tells us two things: Evolution is, like physics, imagination in a straightjacket. Worse, it’s a straightjacket within other straightjackets, with additional constraints and intense competition to boot. Nature is the mother of all optimization engines! Second, biological design is very parsimonious; the body of an ant is strong enough to carry the crazy amounts of food its colony needs, but no stronger than it need be.7

There is so much scope for some hard science fiction here. In fact, a consideration of the physics of scaling is one of the things distinguishing hard and soft science fiction.8

The above was just one window into the concept of scaling- we saw how the properties of real world objects varied in interesting ways at different sizes. A different set of observations can be made by looking at the same object at different scales: it leads us to all kinds of interesting ideas, like fractals and universality. Perhaps the most amazing use of scaling is a technique that involves looking not at an object (real-world or abstract), but at a mathematical model for a system at different scales. This process, called the renormalization group, is touted as the most impressive use of abstraction in science. It is quite hard to segue into these other uses of scaling here; they’re fodder for Scaling II!


Footnotes:

1. Strictly speaking, a traditional microscope does not scale an object geometrically, because of the nonuniform optical properties of the lenses. I don’t know of any system of lenses that magnifies correctly along the viewer’s line of sight- the depth- of the inspected object.

2. Of course, the above are special cases. You can vary the mass (and thus the density) by whatever factor you want so long as you’re scaling it up in your head. We’re talking about magnifying the size while retaining as much of the material’s inner structure as possible: so if we wanted to scale up a clay pyramid, we would use the same kind of clay to construct a bigger pyramid, and its mass would scale like its volume does, as the cube of the linear dimension.

3. If you are trying to imagine this, pick up a thin tube of plastic- or a straw, and push on both ends of it. It kinks and buckles; this is the usual mode of failure for a slender beam or tube, like the ant’s chitinous appendages.

4. This is essentially the same calculation as in the paragraph before it.

5. This tells us something apparently paradoxical: The larger you are, the lesser you ought to eat! While this sounds like good health advice, it is of course an incomplete picture. We don’t burn all our energy as heat, we spend a large chunk of it in locomotion, a lot in circulating blood and nutrients around (and in other body maintenance tasks) and a fair bit in thinking.

6. Talk about biological warfare!

7. Because of the way natural selection works, it’s not really surprising that this is the case. If the ant couldn’t carry several times its own weight, there would be no ant colonies and no ants as we know them, right? It’s the antropic principle at work.

8. The other physics most works of sci-fi violate are, of course, conservation laws, like that of momentum and energy. There are workarounds, mind you. (PDF)

Format:Text

Saturday, October 17th, 2009


The following is an essay I wrote elaborating upon the power of plain text as a digital medium. I love text based data formats; I work with plain text for nearly everything. I love working at a shell- GUIs frustrate me. I am not an authority on the subjects of GUIs and data formats—I am an end user. Paul Graham says in his inspiring
essay on essays:

An essay is something you write to try to figure something out.

Figure out what? You don’t know yet. And so you can’t begin with a thesis, because you don’t have one, and may never have one. An essay doesn’t begin with a statement, but with a question.

And that explains (in retrospect) why I sat down one evening and hammered out a few thousand words about text, of all things. I was trying to figure out why I liked text so.

He continues:

…if you want to write essays, you need two ingredients: a few topics you’ve thought about a lot, and some ability to ferret out the unexpected.

I certainly pass the first requirement, not so much the second! As a technical discourse, this essay will often be in error, and go nowhere on the whole. Read as a whimsical opinion piece about my fascination with all things plain text, however, it makes a smidgen more sense.

(more…)

Blink, Morse

Sunday, June 7th, 2009

In the novel *Cryptonomicon*, one of the lead characters finds himself implicated in a (comical) drug bust, and is placed in a jail cell under the watchful (electronic) eyes of hi-tech eavesdroppers. It’s a scene out of a spy novel (although *Cryptonomicon* isn’t quite that), minus the secret agents, plus one savvy Unix sysadmin. He’s given his laptop, to boot.

The rest of this lead-up contains spoilers, so skip to the image if you’re the ear-cupping-and-yelling kind.

The conspirators don’t pull punches; they’re replicating the prisoner’s laptop screen in an adjacent cell with a Van Eck phreaking setup- so everything he sees, they see. Or do they?

Food, bedding, and a computer- it sounds far too pleasant a way to imprison an inveterate hacker, so he proceeds, ostensibly, to hand over the information they need, carrying out some phony cryptanalysis in the process. And then he conjures a little script, writing out small pieces of code to a file at intermittent intervals. When executed, this script reads out text files (the Real Thing) by flashing the LEDs on his keyboard in morse.

CC-licensed keyboard images are hard to find.

Wow. Using intractably complex technology to simulate simple tasks is a fascinating idea, if only because it goes against design. It’s the joy of complete control over a programmable machine- articulated amazingly well in this extract (from Cory Doctorow’s Little Brother):

If you’ve never programmed a computer, you should. There’s nothing like it in the whole world. When you program a computer, it does *exactly* what you tell it to do. It’s like designing a machine — any machine, like a car, like a faucet, like a gas-hinge for a door — using math and instructions. It’s awesome in the truest sense: it can fill you with awe.

Flashing text in Morse off a keyboard LED is the sort of thing I can’t read without wanting to do myself. So I did.*

Internet, meet Morseblink. Assuming even that you’re not digging for gold in the Philippines with several governments seeking your hard drive for forgotten world war II treasures, it’s still perfect for those someone-over-shoulder moments- or minutes- when you’re trying to give the impression of being at work and want to continue catching up on your feeds.

If you know Morse, that is. At least it gives that oft-ignored scroll-lock LED something to do, the poor thing. (Alternatively, you could relegate that annoying system beep to scroll-lock by having it flash instead.It’s an old idea)

It’s fully customizable, if your binary encoding of choice happens to be different. Alternatively, you could use it to practice your Morse, which is all I’ve found it useful for (yet).

You can download it here (written in Perl 5.8, should run on all *nix systems).

Below the cut: Some usage tips and a refresher on the Morse code.

(more…)

“Why are you producing so few red blood cells today?”

Tuesday, April 14th, 2009

An interesting note from six months ago that I never got around to posting. ’tis a bit vague, but then so is the source. Besides, I like to think that nebulousness has its share of merits- trickster makes this world, after all.

***

A while ago, it was thought that the trick to making a machine play chess well was to extend how far down the branching network of possible moves it could examine. Irrespective of how far they can look ahead, though, skilled human chess players can confidently confound (or at least match) most chess programs of today.

Why?

I found a fascinating account of this puzzler involving AI and human thinking in (where else?) GEB. Apparently, the reason for this was known from the 1940s; If you’ve ever played chess- or play regularly but with skill befitting a two year old, you’ll come to appreciate the reason immensely.

Chess novices and chess masters perceive a chess situation in completely different terms. The results of the Dutch psychologist Adriaan de Groot’s study (from the 1940’s) imply that chess masters perceive the distribution of pieces in chunks. (Here’s a more recent description.)

There is a higher-level description of the board than the straightforward “white pawn on K5, black rook on Q6″ type of description, and the master somehow produces such a mental image of the board. This was proven by the high speed with which a master could reproduce an actual position taken from a game, compared with the novice’s plodding reconstruction of the position, after both of them had five second glances at the board. Highly revealing was the fact that masters’ mistakes involved placing whole groups of pieces in the wrong place, which left the game strategically almost the same, but to a novice’s eyes, not at all the same. The clincher was to do the same experiment but with pieces randomly assigned to the squares on the board, instead of copied from actual games. The masters were found to be simply no better than the novices in reconstructing such random boards.

The conclusion is that in normal chess play, certain types of situation recur- certain patterns- and it is on these high-level patterns that the master is sensitive. He thinks on a different level from the novice; his set of concepts is different. Nearly everyone is surprised to find out that in actual play, a master rarely looks ahead any further than a novice does- and moreover, a master usually examines only a handful of possible moves! The trick is that his mode of perceiving the board is like a filter: he literally does not see bad moves when he looks at a chess situation- no more than chess amateurs see illegal moves when they look at a chess situation. Anyone who has played even a little chess has organized his perception so that diagonal rook-moves, forward capture by pawns, and so forth, are never brought to mind. Similarly, master-level players have built up higher levels of organization in the way they see the board; consequently, to them, bad moves are as unlikely as illegal moves are, to most people. This might be called implicit pruning of the giant branching tree of possibilities. By contrast, explicit pruning would involve thinking of a move, and after superficial examination, deciding not to pursue examining it any further.

If you pause to think about this, it comes across as an utterly spellbinding revelation.

(more…)

CUDA

Monday, June 23rd, 2008

I have two primary uses for personal computers.

By uses, I don’t refer to tasks that involve using a hammer where an orthopaedists’ tongs will suffice; Most modern desktops are far too overpowered for (relative to those below) simple tasks like web surfing and listening to music. (With two primary exceptions: The PC must not run Windows Vista or Firefox 2.0!)

By uses, I mean tasks that tax the machine to its limits, give it a nosebleed while ensuring you’re getting all you can from your hardware. In no specific order, they are (i) Gaming and (ii) Simulation (or equivalently, scientific computation). There’s also media encoding and the like, but the above are most relevant to my case.

These activities (appropriately reserved for vacation and study months) are unfortunately at odds with each other, even though they’re both “computation intensive”. Both involve loads of floating point operations; although I’m sure they have more in common than just that. But simulations have traditionally been CPU intensive activities, while graphics computations are handled almost exclusively by dedicated processors (GPUs) on graphics cards. Physics computations in games are handled by the CPU (or dedicated physics cards), but the GPU is still in charge of pushing pixels to the screen, receiving a major workout in the process.

In short,

  • The GPU is “idling” when you’re not doing something graphics intensive, including times when (for instance) you’re running CFD code that has your CPU running at “full load”. It’s also drawing less power.
  • Your GPU is running hot when you’re playing the latest graphics intensive title, although your CPU might not be at full load.

A scheme of arrangements that is less then satisfactory when you consider this image doing the rounds of the Internet (Released by Nvidia):

gpu_die.jpg

That is a shot of the Nvidia GeForce GTX 280 (the latest in their series of GPUs as of June ‘08) next to a modern Intel dual core processor. The “Penryn” dual core processor has just over 410 million transistors; the GTX 280 has 1.4 billion! Larger transistor count doesn’t translate directly to better performance, though- the two are dissimilar in their architecture, purpose and degree of accessibility to the average user. But the latest GPU is, without a doubt, the most advanced piece of hardware you can buy off a shelf right now. And the most powerful piece of hardware in your PC is also the most esoteric, the most specific and the most underutilized.

Which, if I may digress briefly, reminds me of the years I spent pining for a capable graphics card so I could play computer games all day. What kept me from splurging on one of these monsters (GPUs have  outstripped the CPU in transistor count for years now) was that they were too exclusive, too special-purpose to warrant pawning your soul for. And pawn your soul you must, for these things don’t come cheap. Well, that and the fact that I was and am incumbent.

All this is set to change now.

(more…)

“Have Game?”

Friday, April 4th, 2008

warshotsc.jpg

[Scroll to the bottom if the references are, um, alien]

It was three in the afternoon, and I was embroiled in an interstellar conflict of epic magnitude. No, really. Mengsk had ordered me to protect the Zerg from the Protoss expeditionary force so he could let them loose against the confederacy. (Why, of all the nerve!) Raynor had his doubts about Mengsk’s intentions, and I’d seen the whole opera go down six years ago- so I knew how things were going to turn out. So here I was, locking down dragoons upfront with my ghosts and bringing the marines wraiths in to finish the job while sneaking my cabal of siege tanks into the Protoss economy. Resources were limited, it was as much a crystal hunt as it was a Protoss purge- when the Mengsk machinations were abruptly interrupted by a cackling knock at my door.

The astute reader will have realized that I was deeply embroiled in a wargame of sorts, albeit a wargame with succinctly alien phraseology. Being interrupted in the middle of a Starcraft session is quite like having a member of the audience at a fencing bout walk up to you and land a swift kick at the back of your knees; sending you careening headfirst into the opponent’s pointy rapier. I paused the game and cleared my head, ensuring that I’d muttered everything apropos before I opened the door. My unwelcome guest was a grinning lad, dark and stocky with expectant eyes that shone fiercely in the glare of the afternoon sun.

“Have Game?”, he asked.

(more…)

Who do you know?

Monday, March 10th, 2008

So my college batch embarks on a most distressing adventure, one of creating an yearbook with expository information on everyone in the two hundred thirty strong ensemble. The venture is distressing because the few volunteers who’re organizing the data collection, formatting and printing process have had little time to sleep in the past few weeks.

The yearbook itself is likely to prove a nostalgic trigger for the part of our noggins that engages in such frippery, but at the moment, it comes across as a self-proclamation along the lines of “We are so awesome!”; a process of collective unrestricted self-aggrandizement. But this is besides the point.

The prime feature of the yearbook is a section dedicated to a description of each person by his/her peers, listing out why their world would have been markedly incomplete without the company of said individual. These were collected through comments on Orkut, and because everyone is uninhibitedly mopey on Orkut, some rather unlikely testimonials poured out, and poured out freely. The result was a large amount of objective data on one social community conveniently hoarded at one location online, a treasure trove for people looking to study social interaction quantitatively.

This is where I step in.

Below the fold: some surprisingly incoherent trends, a few non-funny disclaimers, and a categorical surrender by me to the statistics gods that be. And graphs! Because everything is more authentic with graphs.
(more…)

The IF thing: resources

Sunday, March 2nd, 2008

This is a short addendum to the post I wrote earlier detailing why you should play Interactive Fiction. (Humour the evangelist, go read!)

So how do you go about playing experiencing IF?

Pick up the phone booth and die is a starkly minimalist (even by IF standards) foot-in-mouth piece of non-sequitur that takes about a minute to play through; try it now.

Emily Short, one of the revered exponents of IF, has extensive guides on everything from how to play to how to write your own games (more on this later).

IF comes in packets called ’story files’, available at several places on the Internet. Baf’s guide documents the most comprehensive collection online. Several story files were linked to in The IF thing, but if you’ve never played IF before, try Dreamhold for the real deal.

You’ll need an interpreter to play them. You would have to install several interpreters to play IF written in different programming languages- fortunately, it’s simpler than that. There’s the kitchen-sink-and-then-some Spatterlight for the Mac OS X, and Gargoyle for Windows and Linux (Source).

Alternatively, Linux users can install frotz and t23run from your repositories, which will let you play most Interactive Fiction from the terminal. There’s something to be said for the benefits of being able to play IF at your machine over SSH; especially since those around you will think you’re working.

Many text adventures can also be played in your browser, if you wish to be spared the hassle of installation.

Other tidbits:

  • There are two IF competitions of note held every year, with dozens of entries that anyone can submit- the IF Comp and the XYZZY awards. The winners of these competitions are among the best text adventures ever written, you can’t go wrong playing them. Also, all the entries in these competitions are available for download in one bundle.
  • Andrew Plotkin, Adam Cadre and Emily Short are among the most well known IF authors- they’ve been writing for ages now, and their websites make for an illuminating (and sometimes amusing) read.