My name is James Dean Palmer and I teach as an associate professor at Northern Arizona University where I work as part of the computer science (CS) program. My research interests include domain specific computer languages, visualization, web-based architectures, and CS pedagogy.

Thursday, September 26, 2013

Writing portable code with Adobe Air's GameInput

One of Adobe Air's relatively new features is the GameInput class, which provides game controller support for Flash and AS3 games.  In general I like GameInput's simplicity - if the left analog stick moves a bit then GameInput sends an event with id "AXIS_0" and a value between -1 and 1 that corresponds to how far it moved from center.

But how do I know AXIS_0 corresponds to horizontal movement on the left stick and not the right stick?  In fact, it might not - that depends on several things including the system platform, driver, controller and version of Air.  Despite its simple interface, actually using GameInput in a portable way is a complex affair.  Zeh Fernando started a laudable project [1, 2, 3] to map out all the combinations of control labels like AXIS_3 or BUTTON_7 to the physical controls with which they correspond on different platforms and controllers. The result is a growing spreadsheet of configurations developers need to consider when using GameInput.

My approach to writing portable code has been to use Zeh's spreadsheet to write AS3 "profiles" or "maps" that transform the GameInput events into what I call Gamepad events.  Gamepad events have constant labels like LSTICK_X, LSTICK_Y, or A_UP that correspond to a "model" controller.  This simplifies game control significantly while sacrificing only a bit of flexibility in addressing controls unique to a specific controller.

If you are interested in my work on Gamepad, you can check it out on Bitbucket:

https://bitbucket.org/jdpalmer/gamepad

Comments, bug reports, or contributions are welcome.

Friday, November 11, 2011

Move One Space

I have been thinking about ways to make math fun for a six year old. When my first son was born I read a book titled Einstein Never Used Flash Cards (ENUFC). As parents its often our inclination to try to fill our kids full of information like little sponges that need to soak up water but ENUFC makes the observation that letting kids play and explore is far more critical in developing problem solving and social skills.

I don't like flash cards.  My own love of learning has stemmed from a keen interest in puzzles and games.  I'm a professor because I like to solve puzzles and I like to teach other people strategies for solving puzzles.  For me, those puzzles tend to be algorithmic, scientific, and even social.

There are lots of puzzles that involve math.  Some of those puzzles are for entertainment and some are real world problems. It's easy to be excited about math when you realize what kinds of puzzles you can unlock with math. But when you have kids, the learning environment you create needs to be age appropriate. It is possible to intimidate your kids with math by giving them puzzles they can't solve. Then they think they aren't good at math and they become less receptive to doing it.

With this in mind, I was trying to think of games that involve math but aren't so complex that they are intimidating for a young math learner. There are some neat games out there but I was also looking for something that would be fun for me to play too - a game that can scale.

I was thinking about the game Cribbage, when I started perverting the rules such that it didn't even resemble Cribbage anymore. I am calling the resulting game Adder Barons.

I have just finished posting my first Adder Barons board. You can download the board and rules and try it out. The board I have posted is just a prototype and there is only one set of treasure numbers. I'm trying to refine the game mechanics and would love to hear from anyone else that gives it a try. I'll be posting my experiments and refinements to the game here, so stay tuned!

Saturday, July 30, 2011

Lions and Tablets

Last summer Eddie found a couple of Serial Wacom Digitize II tablets at NAU's Property Surplus.  I owned one similar to this a long time ago except that it had the ADB interface.  At some point I stopped using Macs and couldn't use it on Linux so I sold it.

But these adapters have a serial interface meaning a usbserial adapter can be used to connect it to modern hardware. Just getting it connected isn't enough - you need drivers.  Two kinds of drivers, really.  First you need usbserial drivers for your adapter and then you need drivers for the tablet itself.  Wacom stopped supporting these long ago.  But the open source project TabletMagic that has breathed new life into these devices by making them available on modern OS X operating systems through a convenient preference pane.  With this in mind, I bought one of these tablets that surplus probably thought were useless for $5 and have been using it for about a year.

That was until Lion.  The latest version of MacOS X doesn't seem to play nicely with the PL2303 usbserial driver that I have.  I also tried an old Belkin usbserial adapter but its in an even worse state.  The only drivers available for the Belkin are from an abandoned opensource project that never released anything but 32 bit drivers (and I never got those working with earlier versions of OS X either).

I was pretty bummed that Lion had done this to me but decided to buy another usbserial adapter (I have a growing collection now).  This time I bought a Keyspan USA-19HS, which is the same brand of adapter that the author of TabletMagic uses.  And of course that one works and as far as I can tell may be one of the few usbserial adapters that works well on OS X Lion.

As an aside, Linux always gets a bad rap for lack of vendor and driver support.  But here's a case where ALL THREE of these adapters work perfectly in Linux and its pretty spotty in both OS X and Windows.  Of course if you want to talk about graphics adapters it's another story I suppose..

Friday, July 29, 2011

Creative Writing with LyX

Some of my own creative writing using LyX settings
that approximate some of Byword's look and feel.
I was recently playing with Byword a new "distraction-less" writing application for OS X.  There are a number of things that I like about Byword.  It has a fullscreen mode that frames the content, beautiful typography, and an easy to use interface that lets you get straight to the writing task at hand.

But its simplicity also leaves me wanting and it has its own share of rough edges.  For example, it has a Rich Text Format (RTF) mode and a Mark Down (MD) mode with oddly different and incompatible capabilities.

After only a few days with Byword I find myself going back to LyX.  If you aren't familiar with LyX I wouldn't be surprised - I often think they should win an award for the most underrated open source project.  LyX is a powerful editor that adopts a What You See Is What You Mean (WYSIWYM) philosophy.  Lyx emphasizes document structure and semantics instead of providing an interactive representation of the document's appearance.  LyX renders documents using LaTeX in order to produce publication quality prints.

At first blush LyX isn't much like Byword but after diving into the preferences I've found it can be made to look and act fairly similar.  The screenshot above was produced with the following settings (you can set these manually through the Preferences dialog or edit the preference file, "~/Library/Application Support/LyX-2.0/preferences"):


\screen_zoom 100
\screen_font_roman "Cochin"
\screen_font_sizes 7 9 10 12 17 20 22 24 26 28
\fullscreen_limit true
\fullscreen_width 600
\set_color "background" "#f2f2f2"
\spellcheck_continuously true

You can then enter full screen mode by clicking the "View > Full Screen" menu item. Knowing the LyX development team (which has been going strong for 15 years) support for the new Lion full screen functionality won't be far behind.

Monday, July 18, 2011

Doctor Omega Review

Doctor Omega (Wikipedia) is the name of a story originally written in 1906 by Arnould Galopin and translated to English and "updated" by Randy Lofficier.

An adventure in a style similar to H. G. Wells, this is the story of Denis Borel and his uncommon meeting with the mysterious Doctor Omega.  Borel has recently retired and settled in a small village in Normandy, France.  He soon becomes curious about a neighbor whose inventions are the cause of explosions and excitation in his newly adopted home.  His neighbor, Doctor Omega, is building a vessel that can traverse time and space with plans to explore Mars' past.

There are a number of similarities with this Doctor and that other Doctor of BBC fame.  This includes a textual likeness between William Hartnel and Omega and a common relationship with a young niece.  Omega is also the name of a time lord in the Doctor Who series but it's obvious that Omega and this one could not be the same. There are also references to a race of people of whom Omega is a member and allusions that he is in fact trapped and unable to use the more powerful vessels that his people have access to.  All of this seems very similar to the newer doctor we know and love but it's hard to know how much of this is the invention of Arnould Galopin and how much has been added for interest by Randy Lofficier.  Quarks, atomic relationships, and science that should have been unknown to Galopin makes it into this tale as part of Lofficier's update.  Thus some of the exciting similarities between this and the Doctor Who series come off as less amazing given how many liberties have been taken with the source material.

While this edition may be more about literary interpretation than literary translation, it's a fun story and well written.  If you like Doctor Who and classic science fiction adventures then you will like Doctor Omega.

HOWTO Make a Tea Latte

Yaya and I were recently in Victoria, British Columbia and discovered a place called Murchie's Tea and Coffee just a short walk from our hotel. The Murchie's tea was consistently excellent and I developed a new appreciation for the "tea latte." In the week after ariving back in Flagstaff, Yaya and I sampled tea lattes from several different coffee houses and found them to be undrinkably bad and categorically different from the experience at Murchie's. But through some experimentation (and some help from the folks at Murchie's) I have come up with a recipe that I think really captures the original drinks. So without further ado..

The Basic Procedure

1. It all starts with tea. Good tea. You will need to brew 3/4 of a cup of strong tea. The tea needs to be strong because the flavor is going to be diluted by the milk. You can get stronger tea by increasing the steeping time or increasing the amount of tea leaves. Most teas have a "sweet spot" in terms of steeping time and water temperature so if you really don't want to mess with the flavor - you need to increase the amount of tea leaves. And while I am usually one of those tea snobs that extols the virtues of the loose leaf brew, good bagged tea has a lot of advantages for this task. If you keep the bag in, it will continue flavoring the milk once it is added and helps avoid a weak tea flavor. This is what Murchie's does in its stores. When I first had a cup, I was kind of shocked - they left the bag in?? But after a lot of experimentation, I think it really does improve the flavor of the latte.

2. Prepare the foam. There's a lot of science behind frothing milk and if you have an espresso machine with a steam wand you are ahead of the game. I'm more interested in doing this on the cheap so I bought a $20 Aerolatte. Milk temperature is most critical for getting a good foam with wands that blend air into the milk. I have found 145 degrees fahrenheit typically works well. Using an instant read thermometer I found 35 seconds in my microwave for 1/2 a cup of milk hits 145 degrees pretty consistently. If the environment is right you can more than double the volume of the milk in around 20 seconds. Simply move the wand around the top of the milk while you pull the air in. For one cup of tea I start with 1/2 a cup of whole milk and if you are going to add syrup, add it to the milk. This helps make the milk taste sweeter and can make up for poor frothing technique. I place it in a two-cup glass measuring cup and usually get it to froth to close to the two cup mark. While you want the vessel to be tall to accomodate the rising foam, a narrow vessel can work against you as you try to get air into the milk. With some experimentation you can also effect the quality of the foam (small bubbles are more desirable than big) but you likely won't get the quality of a commercial quality steamer.

3. Add the frothed milk to the tea. You can experiment with the ratio of milk to tea. One-to-one works well but I tend to like a bit more tea than milk.

4. Present. Sprinkle some cinnamon on top for presentation and nice flavor. What something looks like really says something about how much you care about the tea and psychologist say what food looks like really does effect how it tastes. So make it look good.

How My Local Barista Does It Wrong

While it's pretty simple to make a good tea latte, I've found the local baristas do it differently and while taste is subjective I'm convinced others will agree that some of this represents bad practice and translates to bad lattes.

1. Tea in a can. Several baristas have mixed up tea lattes with incredible alacrity made possible by the fact that there was no tea brewing involved at all. The tea was apparently "on tap" which good tea should never be. A related problem is underbrewing the tea. I saw one barista brew the tea for what had to be 30 seconds. These baristas then try to cover up the bad tea with...

2. A sugar rush. Too much syrup can also ruin the drink. My own feeling is that a tea latte should have a subtle sweetness that starts in the upper milk foam and then transitions to the bottom of the drink. Really one squirt of syrup is enough. A latte shouldn't tast like a flat soda.

3. Frothing the tea. I've also noticed a lot of people like to mix the tea with the milk. I don't know what the theory behind this is but it results in brown foam and a uniformity of flavor that spoils the subtle layers that should exist in the drink.

Now that we have a basic recipe and we know how things can go wrong, we're ready to make a tea latte. But this is only a rough blue print. We can fill in the details to make some really nice drinks.

London Fog

Tea: Try Murchie's Earl Grey Cream (it's a blend of Earl Gray and vanilla flavored tea.) I've also tried Adagio's Earl Gray Bravo and Twinnings' Earl Grey which also taste great but have less vanilla punch.
Syrup: Torani Vanilla

Chai Latte

Tea: Try Murchie's Autumn Chai or Adagio's Masala Chai. If you really like vanilla, you might try Bigelow's Vanilla Chai.
Syrup: Torani Vanilla

Murchie's Medley

Tea: Murchie's Afternoon Tea
Syrup: Torani Vanilla and Torani Caramel

Thursday, June 16, 2011

Puzzle Agent Review

I don't get a lot of time to read or play games for pleasure these days. But I often do have some chunks of free time when I travel that I can use to catch up on games like Puzzle Agent by Telltale Games.

Telltale Games has released episodes in several series that I enjoy (including Monkey Island and Sam & Max). I picked up one of their newer titles, Puzzle Agent, when it was on sale for the iPad around Christmas but only recently had the time to play it.

The atmosphere is similar to a number of northern dramas like Fargo, Twin Peaks or Northern Exposure. It's full of quirky characters in a small town surrounded by vast expanses of snow, ice and forest. The story follows FBI agent Nelson Tethers from the department of Puzzle Research who is tasked with solving a mystery in the small town that is riddled with puzzles. The story is engaging but ends before it really gets started. Though the words "episode one" never appear, I have to imagine this is the intent since almost nothing is resolved before you solve the game. The game itself is short - a few hours at best.

The artwork is consistent and clean. All the dialogue is both bubbled and spoken with full sound effects and music. It's a well produced game. But while it is definitely fun, it is not particularly challenging.. I think I solved every puzzle in one try without using any hints.

It was definitely worth the few dollars I paid for it but I hope Telltale Games commits to making this into a serial with multiple episodes like many of their other games.