Candace

Candace literally burned with rage. She gritted her teeth against the alien charge of the fire in her veins. She continued pulling in heat from the world around her. Atmospheric moisture condensed and froze into icicles on the chilled ceiling of Vault 5, only to melt again as the flames crawled up her arms, licking hungrily at the dripping water, recoiling with puffs of steam when the two met.

She closed her eyes and howled, the very picture of white-knuckled fury fighting to be free. The flames danced around her head like a spectral crown.

“Enough,” she thought. Fists became palms and, one beside the other, smacked flat against the solid steel of the door. Candace screamed as she loosed her gathered energy into this one spot. The metal glowed, warped, and bubbled in succession as it careened past its melting point and bits of water trapped in the alloy exploded under the pressure. The white-hot steel ran in rivulets and dribbled on the floor, hissing at the sharp temperature change.

Candace tore the door apart; it warped and oozed like warm taffy. When it was large enough, she pulled her way through it, bits of molten steel running down her arms and dripping on the cold metal floor outside Vault 5. She gathered her thoughts, trying to ignore the stinging tracks the ice made as it spread over her skin in the wake of the fleeing inferno. She caught her breath and let her body temperature rebound.

After months of isolation in Vault 5, where they had incubated in her the very power that had now set her free, her only thoughts were of the manner, and the order, of her vengeance.

</job>

On Wednesday, I lost my job. Why is not terribly important. Whatever reasons they may have managed to invent, I know the real reason is because they brought me on to do a job that their own corporate inertia prevented from ever getting presented to me, and when they realized they weren’t going to do it after all (again), they decided to just cut their losses.

I get it. That’s the way of old-school business.

As distraught as I am to be without stable income, it remains the case that a door never closes without a window opening. This particular window affords me an opportunity to delve into Android app development in earnest. I bet you’ll have guessed what my first foray is going to be by the time you get to the next paragraph, due to the interstitial image.

eight-sided die

I’m going to make a virtual dice bag, a D&D dice roller that doesn’t suck. Android badly needs one of these. I took pictures of each side of each of the common D&D dice (70 images in total, woo) and am going through the process of cleaning, shrinking, and cropping them to a state where they are useful. The dice app will feature saveable and nameable dice sets complete with modifiers, multipliers, totals, a roll history, accelerometer -triggered rolls (with a button for those who prefer not to shake their phone around like a crazy person), 2D physics (most likely via JBox2D), vibrations on collisions, sound effects, and, of course, a slick UI.

I’m going to spend some time developing Android apps and putting them on the Market. Registering to deploy apps on the Market costs a one-time fee of $25 and all subsequent app sales have a 30% payment processing fee. I’m going to spend some time trying to make money at this.

Here goes nothing!

What’s wrong with Windows

Yesterday, I received in the mail a Bluetooth dongle, which I intended to use to imbue my workstation with the power to use my Bluetooth headphones. It seemed like a reasonable enough proposition. My first thought was, of course, “I should try it with my desktop at home first!”

So I did.

At home, I run Ubuntu. The install procedure went like this:

  1. Plug in Bluetooth dongle.

That’s it. I plugged in the dongle, and the little Bluetooth logo showed up in the indicator area. I was immediately able to pair my phone and headphones and, after switching to the Bluetooth headphones in sound preferences, I was quickly listening to the amazing sounds of ArcAttack in high definition wireless audio. Bliss.

Today, when I left for work, I brought the dongle with me, intending to use it with my workstation. Sadly, at work, I would meet my nemesis, the least usable, least friendly, least secure operating system on the face of the Earth.

Windows.

Here’s how my install went at work:

  1. Plug in the Bluetooth dongle.
  2. Go through the Add new Hardware wizard.
  3. Be totally unsurprised when it fails to automatically install the driver.
  4. Start searching online.
  5. Find a tool that purports to automatically install Bluetooth drivers.
  6. Download and run aforementioned tool.
  7. Yay! It crashed! Some kind of “System Restore not available” error that makes no sense.
  8. Resume searching online.
  9. Find someone who has blogged instructions on how to hack the XP SP2 Bluetooth stack into Windows 2k3 Server, download their packages, follow the instructions.
  10. Manually edit the update.inf file to trick Windows into installing it in the wrong version of the OS (despite the fact that the drivers work just fine if you manage to shoehorn them in there.)
  11. Failing that, EDIT THE REGISTRY to trick the installer into thinking it’s on the right version of Windows.
  12. Finally manage to install the BT stack, supposedly.
  13. Repair the registry hack and restart the computer.
  14. Oh look, it still doesn’t work.
  15. Give up.

The bottom line? Windows is unusable. Nothing works the way it ought to. Linux gets all kinds of bad press for being “unfriendly” and having “hardware problems”, and yet Linux supports more hardware devices than any other operating system and most of the major distros (e.g. Fedora, Ubuntu, SUSE)… just work.

Oh, and if you end up in some crazy voodoo realm on Windows, you have zero help. The OS has little to no diagnostic support and the tools that do exist form a rat’s nest of junk with different interfaces that can’t interoperate and are completely undocumented.

If you wind up needing to do deep magic on Linux, there are like five tools you need to know: lspci, lsusb, make, aptitude/yum/rpm/emerge/etc. (depending on distro), and, you know, Google.

I should make flowcharts comparing the process.

Linux:

  1. Plug in the device.
  2. If it doesn’t work automatically, lsusb and search the package manager for appropriate drivers.
  3. If none are found, Google the USB ID and follow the instructions.
  4. If none of this works, file a bug with the driver maintainers. Hey, some stuff just isn’t supported. That’s life.

Windows:

  1. Plug in the device.
  2. If it doesn’t work automatically, and it came with install media, try that, although the driver provided on the disc will be crappy and out of date anyway.
  3. Failing that, Google for voodoo to solve the problem.
  4. If the voodoo fails, consider actual voodoo.
  5. If the dark arts don’t help, give up.

Note: Mac instructions are generally similar to Linux instructions, although occasionally that “if the hardware came with install media…” clause will apply there as well.

I dunno, what do you think?

Das doofe Fischlied

This remarkably silly song demonstrates how case and gender affect article, attributive adjective, and noun suffixes in German.

Das doofe Fischlied

Der guter Mann, Ein guter Mann
Der guter Mann, Ein guter Mann

Schlag den guten Mann nicht!
Schlag einen guten Mann nicht!
Schlag den guten Mann nicht!

Der guter Mann, Ein guter Mann
Der guter Mann, Ein guter Mann

Schlag den guten Mann nicht!

Gib’ dem guten Mann einen Fisch!
Gib’ einem guten Mann einen Fisch!

Das schöne Haus, Ein schönes Haus
Das schöne Haus, Ein schönes Haus

Schlag das schöne Haus nicht!
Schlag ein schönes Haus nicht!
Schlag das schöne Haus nicht!

Das schöne Haus, Ein schönes Haus
Das schöne Haus, Ein schönes Haus

Schlag das schöne Haus nicht!

Gib’ dem schönen Haus einen Tisch!
Gib’ einem schönen Haus einen Tisch!

Die kleine Maus, Eine kleine Maus
Die kleine Maus, Eine kleine Maus

Schlag die kleine Maus nicht!
Schlag eine kleine Maus nicht!
Schlag die kleine Maus nicht!

Die kleine Maus, Eine kleine Maus
Die kleine Maus, Eine kleine Maus

Schlag die kleine Maus nicht!

Gib’ der kleiner Maus einen Fisch!
Gib’ einer kleiner Maus einen Fisch!

Die gute Freunde, Meine gute Freunde
Die gute Freunde, Meine gute Freunde

Schlag den guten Freunde nicht!
Schlag meinen guten Freunde nicht!
Schlag den guten Freunde nicht!

Die gute Freunde, Meine gute Freunde
Die gute Freunde, Meine gute Freunde

Schlag den guten Freunde nicht!

Gib’ den guten Freunden einen Fisch!
Gib’ meinen guten Freunden einen Fisch!

This song really helped me learn the somewhat messy attributive adjective suffixes. It gives you a handy way to practice them. (One pattern from here that never escaped me is that of the nominative and accusative forms of neuter: “There’s always exactly one ‘s’,” meaning that das is followed by schöne but ein is followed by schönes.)

Solving the Rubik’s Cube? There’s an app for that.

image

I’ve long been enamored of robotic Rubik’s Cube solvers. There are many of these out there (most built of Legos) that typically feature everything necessary to complete the solution autonomously. These pieces are as follows:

  1. Read the cube pattern (generally by taking a picture of each side of the cube and analyzing it).
  2. Generate an efficient solution.
  3. Execute each step mechanically.

Recently it struck me that a sufficiently hackable mobile phone could be used to provide everything from the camera to the control via USB or Bluetooth. “That would be a fun application to write,” I thought, for my Android phone, a Google Nexus One. Alas, I haven’t the funds, knowledge, or time necessary to build the robotic component of that.

My dreams dwindled a bit.

But then I thought of something else, something so incredibly obvious that I figured it had to already exist. Some searching around, however, revealed nothing of the sort, so I’m going to announce the idea here:

ARCS, the Augmented Reality Cube Solver.

See, generally augmented reality works when you have markers to track, as otherwise you’re basically limited to geolocational stuff and have to collect all kinds of information to make it work. With visual tags, the problem is much simpler, and a Rubik’s Cube already has 54 visual tags on it: the color-coded stickers.

By detecting the stickers and tracking movement, the application could not only orient the cube in 3D space, but also read each face’s state as the user turns the cube before the camera. Once the entire cube state had been recorded, the application could generate a solution and (here’s the really cool part) overlay the solution step-by-step on the image of the cube itself! Imagine 3D arrows flowing along the layers of the cube, indicating which to turn. As the cube is solved, the application recognizes the new state and shows the next step. If at any time the cube diverges from the expected next state, the app can figure out what the user did wrong and show a correction step.

Now that OpenCV has been successfully implemented on Android, I think this is well within the range of possibility. I don’t know if I could do it myself, but I know someone could, and I think it would be a fantastic app.

Got any other cool augmented reality or general Android app ideas? Sound off in the comments!

Infinite Whiteboard

infinite whiteboard logo

Infinite Whiteboard is the unassuming title I’m applying to this project of mine. The goal is to create a project planning tool that does what it says on the box. It’s a whiteboard on which the user can simply start drawing objects anywhere. Image files can be uploaded and dropped onto the board, vector drawings can be annotated with notes, chunks of the board can be clipped and saved to doodles, links can be made from one area to another. Imagine a whiteboard that you can zoom, pan, save, annotate, and search, and you have the Infinite Whiteboard project.

I’ve mentioned this before. It’s what I want Cogspace to be. While WordPress is great for what it is intended for, it falls somewhat short as a freeform idea foundry, so that’s what I want to create.

Data & Dice

The need for truly random data is quite common, but as any engineer can tell you, true random data is hard to come by. Computers are incapable of generating truly random data. Although some systems do a pretty good job of it, e.g. by collecting entropy from chaotic processes like keyboard and mouse usage, disk access, error corrections, etc., even these methods often fall short of cryptographic randomness.

There is, however, one class of number generator that is rather easy to come by and is about as close to truly random as one can come without using quantum events like radioactive decay. That device is the humble die.

Dice have been used for thousands of years to provide entropy for games, and they can also be used to provide entropy for computational needs. One particular task I often have is to generate a PIN for Second Life scripts to be used for security. This PIN is in the space of all 32-bit integers, meaning it is in the domain [-2^{32} \cdots 2^{32}-1].

The easiest way I have found to do this is using four eight-sided (octohedral) dice, commonly used for Dungeons & Dragons, in which they are referred to as “d8″. The d8 I have are, as are most, number from 1 to 8, so I just treat 8 as 0 and use the other digits as they are, meaning each d8 gives me one octal digit. Four of these then give me twelve bits, which is three nibbles, so if I roll these 4d8 three times, I’ll get 36 bits, giving me the 32 bits I need plus four extra, which I just cut off the end.

In order to guarantee good random rolls, I keep the dice in a clear plastic tub (previously used for almonds) and just give it a good shake, then hold it at an angle so the dice line up along one of the bottom edges, then read them off left-to-right. Here’s an example:

Roll 1 Roll 2 Roll 3
0 3 4 1 0 1 4 7 1 1 1 2
0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 1 0 1 0
0 E 1 0 6 7 2 4 A

Note that the last four bits are discarded, meaning onle the two most significant bits of the second-to-last d8 only count, and the entire last bit doesn’t count. The output value, in this case 0x0E106724, represents a full 32 bits of random data. I also use this method to generate chat channels, which are typically kept negative to prevent client eavesdropping. In these cases, I just force the most significant bit to 1, since that will guarantee a negative number.

That’s all there is to it! I have also seen 16-sided dice, which would generate 4 bits of data, so you could just roll 8d16 (or 4d16 twice (or 2d16 four times (or 1d16 eight times))) to generate the 32-bit integer, but d16 are an awful lot harder to find than d8.

If you’re stuck with six-sided dice, you can get two bits out of them by assigning 6 to 00 and re-rolling on 4 or 5. This would require twice as many dice (or rolls) as using d8, and could also be done with d4 (where 4 would be 0 and all other values would be their normal values). This does not skew results as the chance of landing on each of the valid sides is equal (1/6). d6 would be less efficient than d4, though, since 1/3 of rolls would be invalid (4 or 5). The reason there’s no way to make use of 4 or 5 is it would introduce skew, e.g. using the values directly would mean 6 and 7 would never be possible, and trying to do something like use the 1/3 bit of entropy provided by the extra faces would be more work than it would be worth, and I’m not certain it’s probabalistically even either.

Stay tuned for more random crap!

(pun very much intended)

On the Busting of Moves

Growing up, I spent many a weekend in the Family Fun Zone, a local arcade known for its apparently custom-built massive Ghostbusters game and convenient proximity to Shakey’s. Most of my fondest memories involve the familiar cadence of tokens vanishing into loud, imposing arcade cabinets and hasty trips to the aforementioned eatery to beg Dad for more fiat. I still get that fluttery feeling of potential when I trade paper for coin to pry repast from a mechanical vendor. Those percussive plinks – one, two, three, four – may well have been my primary mathematical educator. What value has a five-dollar bill beyond its facility to conversion to twenty tokens? I haven’t a clue.

There were many familiar haunts in those days: Golden Axe was a favorite, as were the fast classics. Pac-Man. Dig-Dug. Donkey Kong. Centipede. Being the youngest person in the pinball aisle seemed a badge of honor. It was an homage to the true progenitors of the medium. I’m going to go play the pinball games, I’d think. Why? Out of reverence.

Every trip concluded with at least a few rounds of air hockey. Dad almost always won, but over time, my brother became the true master of compressed air and plastic pucks. The sound of the puck entering the goal slot is as satisfying a sensory memory as the plinking of tokens in the change machines, those dutiful money-changers of the realm of the arcade, converting your hard-earned greenbacks into worthless metal slugs. One-way foreign exchange. No cash value. But as long as Arcadia stood, those embossed metal rounds were good as gold.

One game above all others captured me deeply, though – deeper even than the Western-themed side-scrolling shooter in the Shakey’s that formed a sort of cathartic ritual after the post-gaming Bunch of Lunch – and that game was Puzzle Bobble, a.k.a. Bust-a-Move.

Bust-a-Move is one of those rare games that is so perfectly designed that it can truly stand as a monolith of the industry. It’s trivial to learn, exciting and addictive, and the potential for racking up truly monstrous scores (the theoretical maximum being somewhere around thirty million) affords near-infinite replay value. Whoever AAA is, one would think, their 16,000,000 cannot stand forever! This game continues to be one of my favorite games of all time. The music’s familiarity is right up there with Tetris and Mario Bros.

Fast-forward to modern times, and the arcade has gone the way of deinonychus. That once-powerful fraternity of flashing, blaring audiovisual gods has been deftly deposed by the gaming console trinity, and the somewhat shamanic realm of the personal computer. The plaza-mall which once held, in addition to a fabulous snow cone shop and a Crown Books, that doomed Shakey’s and the Family Fun Zone is now all but vacant. Only the Edwards 10 remains, under new management as a three-dollar theater clinging to life on razor-thin margins, if life it can be called.

Taito’s legendary bubble busting puzzle game is now the property of Square Enix, by whatever sorcery has led to this being the case, and it is a good case for it to be. As it has been in countless other fashions, Bust-a-Move has now been remade on the Android platform, and I could not be happier. Sure, the graphics are a little  different, the music doesn’t speed up as the ceiling falls, and the fact that it’s on a mobile phone instead of a massive cabinet, while convenient, is also somewhat disingenuous to the original experience, but for $4.99, and at this level of polish, I am utterly thrilled. I feel as though I’ve been given the opportunity to enjoy a lifetime of Bust-a-Move for a mere score of tokens, which once I would have squandered in a single Sunday session. Besides, nostalgia is a bargain at any price.

Speaking of which, I wonder where I put that Family Fun Zone token. I located one – who knows how it escaped that vortex – but seem to have misplaced it. A damn shame, too. That token is, to me, like a Japanese occupation peso. Coin of a realm that no longer is, it has no worth, and yet for me, a former citizen of that land, it holds fast to emotional – I’d go so far as to say cultural – significance. It is the currency of my homeland, whose national sport might well be Skee-Ball, and for me, at least, is as priceless as it is worthless.

In close, and, if I may myself so indulge, in verse, let me an anthem propose:

Rest Ye Well, Arcadia

Rest ye well, Arcadia,

Though thy temples fold,

Thy gods dismissed, thy roads untread,

Thy halls vacant and cold,

Rest ye well, Arcadia,

Thy people prosper yet,

And ne’er will they thy memory

Nor thy fair games forget.

Rest ye well, Arcadia,

Thy purpose doth endure.

Although thy sovereignty is past,

Thy legacy is sure.

Strip Iterated Prisoner’s Dilemma

In light of this, I’m going to propose a rule set for strip iterated prisoner’s dilemma.

For those unfamiliar, the Prisoner’s Dilemma is a standard example in game theory. The setup goes thus:

Two prisoners (who acted together) are accused of a crime. Each is given the following deal: Betray the other prisoner, and they can walk free while the other serves 10 years in prison. The catch is that if both betray, both serve 5 years instead of one going free and the other serving 10 years. If they both remain silent (“cooperate” with each other), then they each receive a brief 6-month sentence for the only thing the cops have enough evidence to pin on them.

So to make this a strip game, we just need to change the rules a bit:

  • Alice defects, Bob defects: Each player removes two articles of clothing.
  • Alice defects, Bob cooperates: Bob removes three articles of clothing.
  • Alice cooperates, Bob defects: Alice removes three articles of clothing.
  • Alice cooperates, Bob cooperates: Each player removes one article of clothing.

It’s unfortunate that articles of clothing are such coarse score units. I’m thinking a system whereby players accumulate points and every time they pass n points they have to remove an article of clothing might work better, but hey, it’s Strip Iterated Prisoner’s Dilemma. How polished need it be?

ZEN

ZEN