Wednesday, May 30, 2012

FDG 2012 Day 1

I am in Raleigh, NC, for the Foundations of Digital Games conference. This is my first time at this conference and my first time in Raleigh. Both have been great so far. Despite having been working in the "games" sphere for the last few years, this was my first time at an explicitly games-related conference. I have been presenting my work at general conferences like CCSC:MW or at conferences with other domain focuses like SIGCSE and DESRIST.

I arrived yesterday late afternoon and, since I was in no rush and had done my research, I took the bus from the airport to downtown. It was $2 well spent, and a nice way to get a look around the city. A few people have reacted with incredulity about my having taken the bus, but it was a good learning opportunity.

Let me zoom in on that a bit for you:

In English, you are "elderly," not "a person of advanced age," though in Spanish, you are "una persona de edad avanzada"—certainly not viejo! Yet, in English, you are not "disabled," you are "a person with disabilities," while in Spanish, you are simply "incapacitada." Language is fascinating!

I found the hotel, dropped off my bags, and went exploring downtown. I ended up outside a restaurant called "Mecca," which from the name I assumed would be some kind of Mediterranean place. Turns out it was more of an American diner, but the staff were helpful and the cheeseburger was great. I asked about local beers and had one of these:


Very nice indeed, and it's made right in Raleigh.

After walking around downtown, I explored the hotel to see the spaces we'd be in today. There were workshops yesterday and their signs were still up. As I walked around, I noticed that one of the rooms was open for a reception, which I had never even noticed on the schedule. I had a free glass of cabernet and met some nice gentlemen from Portugal and the Netherlands before retiring to my room for the night.

During the welcoming address, the conference chair pointed out that the proceedings were hiding inside the pens in our conference bags. Let's take a look...

Ooh, handsome. So, if I twist the right side, I should get a writing implement...

See the difference? When I twist the bottom side of the pen, I get a writing nib the size of a tsetse fly. Additionally, when I exert any pressure on that nib—for example, as one might apply when writing—it scuttles back into its protective shell. Convenient! I shall never have to worry about this pen running out of ink! I can only hope that mine is broken. Anyway, you can still unscrew (and unscrew and unscrew) the back to reveal the USB connector and get your proceedings from there.
I guess when you're done, you screw it all back together again so that... your pen doesn't get lonely? I'm sure there's a lesson here about ideas vs. execution. Memo to myself: USB sticks alone are sufficient.

The morning keynote address was worth the price of admission. The speaker was Jonas Linderoth, who presented an overview of his ecological approach to game analysis. He has a doctorate in pedagogy, and he is clearly and explicitly dubious of unsubstantiated claims regarding games and learning. Specifically, he is looking at well-studied educational principles such as transfer and their absence amid the cries about games' potential for transforming education. He nailed several points that have been bothering me for the last few years, and I'm eager to read his research. I believe he said he is working on a book that presents his theory, and if so, I'll be first in line. Regular readers will know that I love Koster's Theory of Fun, but I've been aching for something more research-based.

After the keynote was the first paper session, which had four papers. I really think four is too many to digest, as an attendee. Four papers is especially too many when half the presenters are reading bullet points off of PowerPoint slides. Attention everyone with doctoral students: Step 1, learn to deliver good presentations. Step 2, teach your students. Step 3, make them practice. Step 4, only after completing the other steps, allow them to present at conferences. 

But I digress. The content was mostly interesting. Enjoyable research overall, despite some bad infographics and conclusions far exceeding actual results. These are the kinds of things I hammer when I am a reviewer; perhaps I shall volunteer to review for this conference next year.

Lunch was a gyro from the place right next to the hotel because it was raining. It was quite good.

I gave my talk in the afternoon, based on the entity system architecture of Morgan's Raid. I finished my prepared remarks with time to spare so there would be plenty of time for discussion. There were some good technical questions, but I am most excited about the people who asked about the environment: the students, the curriculum, the objectives. To me, this is a good sign that people are excited about the idea of studio learning environments and giving students authentic learning experiences through game development. After the formal presentation slot, one of the other presenters asked me about grading, and I had to pause for moment to remember how I graded them at all. I'm glad he asked, because that reminds me that I need to come up with a better way for this Fall.

The young man presenting after me was the lead developer of Gear2D, a component-based game engine. I challenged him a bit on the problem of creating an engine rather than a game. As I told him, the best advice I heard (on I think, back when I checked it daily) was, "When you think you want to make a game engine, make a game instead. Then make another game. Then make another game. The stuff you used all three times is your game engine." He took this criticism well, and talked about some of the ongoing work to build applications atop Gear2D. Later I found out he's an undergraduate, so props to him for writing a paper, having it accepted, and coming all the way from Brazil to listen to my comments. Seriously, nicely done.

At a conference where I don't know anybody, I love presenting early in the conference. During the rest of the conference, I met several people who were at my session and their colleagues. If I didn't have such a refined sense of morals, I'd start lying about having to leave every conference early just so I could be put early in the schedule.

There was a panel on Twitter as a platform for game development. Each of the panelists had interesting things to say, but there were hardly any questions from the audience. I admit curiosity about Twitter, but I don't use it. There were some interesting word/language games described, but as the panelists admitted, they weren't really dependent on Twitter's unique ecosystem, and some have been translated to generic text interfaces. I understand that there is a culture around Twitter involving retweets and followers, an unspoken etiquette that one must understand or be doomed to the lower echelons of twitterati. It seemed that the games that reflected this yielded the most interesting game design ideas, because they involved serious real-world risks.

David Molyneaux from Microsoft Research spoke about Kinect Fusion, an incredible application of Kinect hardware with advanced image processing to do real-time 3D reconstruction of scenes. It was mindblowing. Fortunately, you can search YouTube for "Kinect Fusion" and find a lot of the highlights. Seriously, check it out.

A special session was added for Leslie Redd, Valve's Director of Educational Programs (or whatever you want to call her in a company with no titles). They're working a "Steam for Schools" as a way to get Portal 2 Puzzle Maker into schools. A few teachers are designing lesson plans and curricula for math and physics based on beta testing. You can get a sense of it from the video about the Evergreen School field trip to Valve. More information is available at It's great to see Valve reaching out to help schools, and Redd admitted that their biggest hurdles were not technical but rather dealing with administrators and, even moreso, IT departments.

At this point, I considered finding some of my newly-made friends to see if they wanted to get dinner, but a quick self-evaluation made me realize I was completely exhausted and needing my introvert time. So, I went exploring the city again, this time stopping at Dickey's BBQ. One bite in, and I knew I needed to capture the moment.

Amazing pork BBQ sandwich, accented with an authentic Carolina-style, vinegar-based BBQ sauce. On the right is the Dickey's sauce, which is a more conventional tomato-based sauce. Also good, but the Carolina-style really hit home, perhaps because it was reminiscent of Chiavetta's. The fried okra were perfectly seasoned, with a black pepper kick. The Brunswick stew was out of this world. Bad Penny was good enough for a repeat as well... especially since the other choices were Bud and Bud Lite.

Afterwards I did some more walking and discovered a nice park and a few more eateries I'd love to try. Then I remembered that I wouldn't have time for them. Next time, Raleigh. Also, after Dickey's, I probably should not eat again for a few days.

When I returned to the hotel, I saw a group of four of the nicest gents I'd met at the conference, and in fact, one had just left a message for me to see if I wanted to join them for dinner. So very kind of them, but at this point, I was stuffed, exhausted, and really wanted to write down my thoughts from the day. So, in case one of you is reading this, thanks again, and next time I will surely take you up on it.

Sometimes my family will travel with me to conferences, but this time I am traveling alone. One of my favorite parts of traveling by myself is that, usually, my wife will sneak little notes into my bag. This is really nice, and you, dear reader, should do this for your own spouse or significant other. However, this was the first conference where I also had notes from my son:

What a guy! I suspect my wife put him up to it, but that doesn't take away from the warm fuzzies it brings me.

Tomorrow's another full day. No promises on whether I'll have the energy for another comprehensive post, but I really wanted to capture my first impressions of the conference. In case I don't have a follow-up, I'll take the opportunity now to post a public "thank you" to all the conference organizers.

Friday, May 25, 2012

Reflecting on the last 14 years

I spent seven years in graduate school.
I have been in Muncie for seven years.

I started graduate school at the University at Buffalo in Fall, 1998.
I became an assistant professor at Ball State University in Fall, 2005.

In Buffalo, I spent two years on my masters degree and five on my doctorate.
In Muncie, I was promoted to associate professor in five years and secured tenure in two more.

In Buffalo, I wrote about a dozen songs and a few research papers.
In Muncie, I've written many research papers but only one song.

In Buffalo, my advisor was a good and patient mentor who was sometimes distracted by his duties as department chair.
In Muncie, my wife has been my constant companion and biggest supporter, although she is sometimes distracted by raising our children.

In Buffalo, I changed apartments four times.
In Muncie, I bought a house.

In Buffalo, I wrote out my lesson plans in binders and tried to give stirring, inspirational lectures.
In Muncie, I pay attention to what my students are doing and how that relates to their learning.

In Buffalo, I bought a book of Peanuts songs and absolutely loved it.
In Muncie, I bought a book of Mr. Rogers songs and absolutely loved it.

In Buffalo, the Computer Science and Engineering department was in Bell Hall.
In Muncie, the Computer Science department is in the Robert Bell Building.

In Buffalo, I bought computer games that came in boxes.
In Muncie, all these purchases are made through Steam, GOG, or indies.

In Buffalo, my friends and I had cookouts at Point Gratiot on Lake Erie.
In Muncie, I try to have my students and collaborators over to the house for a cookout each semester.

In Buffalo, I changed my facial hair every few weeks.
In Muncie, I've worn a beard since a few weeks into my first semester.

In Buffalo, I had a few failed relationships, but these led to my marriage, which makes me very happy.
In Muncie, I had a few failed research directions, but these led to my current scholarship, which makes me happy.

In Buffalo, I ate corn dogs and potted meat from Big Lots.
In Muncie, I go to the Farmer's Market almost every weekend.

In Buffalo, there were lots of Greek restaurants for Sunday brunch.
In Muncie, there are lots of places to get Mexican cuisine.

In Buffalo, most of my best friends were single.
In Muncie, almost all of these friends are now married, most with children.

In Buffalo, I got to meet Neil Innes.
In Muncie, I got to work with Hal Abelson.

In Buffalo, I lived alone for two years before sharing apartments.
In Muncie, it was two years before my wife and I had our first child.

In Buffalo, I had purpose and was working on mastery.
In Muncie, I have autonomy, mastery, and purpose.

In Buffalo, an inspiration student told me, "I'm gonna call you 'PG'!"
In Muncie, my students called me "Doctor G."

In Buffalo, I was affiliated with the Dragon Clan in Legend of the Five Rings.
In Muncie, I am affiliated with the Special Interest Group in Computer Science Education.

In Buffalo, I was a research team of one, and when I occasionally was thrown masters students, I was neither authorized nor prepared to mentor them.
In Muncie, I have worked with several great collaborators, including undergraduate and masters students, and I've become much better at mentoring.

In Buffalo, I would go to Bennigan's for the Wheelhouse burger.
In Muncie, I go to Scotty's for the Backyard BBQ burger.

In Buffalo, I saw my parents about twice a month.
In Muncie, I see my parents about twice a year.

In Buffalo, Duke Nukem Forever was in development the whole time.
In Muncie, Half-Life 2: Episode Three has been in development most of the time.

In Buffalo, all of my work was done in Java.
In Muncie, I have published papers based on work in Java, C#/.NET, and Prolog.

In Buffalo, I had roller blades.
In Muncie, I have a bicycle.

In Buffalo, I read several books by Orson Scott Card.
In Muncie, I have read several books by L. Frank Baum.

In Buffalo, I had to explain that Dunkirk was about an hour away.
In Muncie, I have to explain that Buffalo is not near New York City.

In Buffalo, caffeine came in the form of tea, Dr. Pepper, and chocolate-covered coffee beans.
In Muncie, caffeine comes from tea, coffee, and chocolate-covered coffee beans.

In Buffalo, I spent a lot of time tracking down defects in my own code.
In Muncie, I have converted to test-driven development.

In Buffalo, I walked to campus when I lived close and drove otherwise.
In Muncie, I walk or bike and have never had a parking pass.

In Buffalo, people complained about Adelphia.
In Muncie, people complain about Comcast.

In Buffalo, I had never heard of paw paws.
In Muncie, I cannot find a good fish fry.

In Buffalo, I was an officer with the Computer Science and Engineering Graduate Student Assocation for four years.
In Muncie, I was Undergraduate Program Coordinator for five and a half years.

In Buffalo, I locked my keys in my car twice.
In Muncie, I have locked my keys in my office once.

In Buffalo, I first read Godel, Escher, Bach.
In Muncie, I tried to re-read GEB but couldn't quite make it.

In Buffalo, the Manifesto for Agile Software Development was written, but it didn't really affect me.
In Muncie, the principles of agile software infuse almost all of my work.

In Buffalo, I had to stop using instant messenger so I could be more productive.
In Muncie, I had to start working with my office door closed so I could be more productive.

In Buffalo, I introduced many friends to bubble tea, though some didn't like it.
In Muncie, I introduced many friends to old fashioned cocktails, though some didn't like it.

In Buffalo, I had to cast objects returned by Java's collections API.
In Muncie, I use the generic version of the API.

In Buffalo, I organized L5R tournaments.
In Muncie, I have people over to play board games.

In Buffalo, I went out to Chippewa exactly once.
In Muncie, I've been to The Locker Room exactly once.

In Buffalo, I bought tea at Victoria Teas in Niagara-on-the-Lake.
In Muncie, I buy coffee from Compusion Coffee.

In Buffalo, the extent of my tabletop roleplaying was one game of Rolemaster, one game of D&D 3.5, and one session of system I designed.
In Muncie, the extent of my tabletop roleplaying has been two games of Everyone is John at the VBC.

In Buffalo, I loved to go cross-country skiing with my friends.
In Muncie, I can walk or bike to work year-round.

In Buffalo, I bought Settlers of Catan and Carcassonne.
In Muncie, I am shopping for more storage space to hold my board game collection.

In Buffalo, my favorite course to teach was programming languages.
In Muncie, I have not taught programming languages.

In Buffalo, I would go to Zoar Valley and Goat Island.
In Muncie, I go to Mounds State Park and the Muncie Greenway.

In Buffalo, beer-battered banana peppers were a favorite treat.
In Muncie, deep-fried pickles are a favorite treat.

In Buffalo, I got better at playing acoustic guitar.
In Muncie, I have gotten better at playing bass guitar.

In Buffalo, I was a Presidential Fellow.
In Muncie, I have been a fellow with the Institute for Digital Intermedia Arts and the Virginia Ball Center for Creative Inquiry.

In Buffalo, I watched all of Neon Genesis: Evangelion with my pals.
In Muncie, I watched all the MST3Ks with my wife.

In Buffalo, my friends and I debated the relative merits of Duff's and Anchor Bar's wings.
In Muncie, people don't seem to know that chicken wings are supposed to have bones in them.

In Buffalo, Linux was my operating system of choice, except when playing games.
In Muncie, Linux is my operating system of choice, except when playing games.

In Buffalo, I learned how to understand and apply software design patterns.
In Muncie, I teach others how to understand and apply software design patterns.

In Buffalo, I wore flannel shirts over T-shirts.
In Muncie, I wear sweater-vests.

In Buffalo, I tinkered with game design and development when I needed a break from school work.
In Muncie, I create and teach courses on game design and development.

In Buffalo, I performed at Higher Grounds Coffee House.
In Muncie, I blog.

Wednesday, May 16, 2012

Looking for overt mathematical formalism in all the wrong places (or, Thoughts about game design and the ETS Assessment Games Challenge)

A colleague at the university sent me a link to the ETS Assessment Games Challenge, a game design competition that encourages the use of video games to teach—and assess learning of—mathematics skills. There are two particular learning progressions that they want to see turned into game experiences: equations and expressions and functions and linear functions. Each of the two progressions provides a five-level model for learning, and each level has an explanation of its corresponding skills and misconceptions.

This intrigued me as an interesting context for study during my Summer of professional development. The challenge exhibits several positive traits. I like math, and I like game design, and I like teaching, and I like writing software. Furthermore, there's built-in expert evaluation through the judging format, which is great for a scholarly approach. Thus inspired, I spent a few minutes yesterday looking through my cabinet of board games for inspiration in game mechanics.

In my casual analysis, it seems that there really aren't a lot of games about expressions or about linear functions. Many games can be modeled using them, of course, but there aren't many about them. For example, there are many games where you have to amass resources to purchase items. Let's take Donald X. Vaccarino's Dominion as an example, in which you may wish to buy a province for eight gold. If I have a hand of five cards with gold values, call them c0 through c4, then I could pose the question as to whether this equation is satisifiable:

c0 + c1 + c2 + c3 + c4 ≥ 8

Of course, I'd actually do it this way:

\sum_{i=0}^{4} c_i \ge{} 8
but that's just being pedantic.

When I play Dominion, however, I don't put it this way. It's a word problem—Do I have enough gold to afford a province?—and the sum happens in my head without formal representation. Playing games with my five-year-old son, know that he can do simple two-value sums (on a good day), but the notation doesn't seem to offer him any help in the game. My point is that you could apply this formal notation as part of the game of Dominion, but it's not necessary, and so from a game design perspective, it should not be there.

There are lots of games where algebraic thinking is quite useful as well. I had the chance to play Bernd Brunnhofer's Stone Age last weekend, an excellent Euro-style worker placement game. During the game, you collect four different kinds of resources. One way to earn points is to use these to purchase building tiles, many of which have costs like "spend four resources of four different types." In the game, they represent this with a custom syntax. (Sorry for the poor image quality.)

Once again, I could represent it more formally, where ri is the number of resources spent of type i.

Solve for all ri. Hey, I'm learning equations and first-order logic! Well... not really. It's just another case where I can model it as a mathematical formalism, but it doesn't gain me anything when the complexity of "spend four resources of four different types" fits neatly in my head. One might argue, then, that we have to raise the complexity to something that doesn't fit in the head, so that the mathematical formalism is necessary for managing complexity, but I fear that this will very quickly then become digital homework.

As I turned my eye towards games with specific equality relationships, rather than inequalities, I came up with only two good examples. David Sirlin's Flash Duel (although the pertinent part is actually Reiner Knizia's En Garde) and Cribbage. (Whoah... Cribbage has a Board Game Geek Entry?! And it was designed by Sir John Suckling in 1630?! I love the Internet!) Let's take Cribbage as an example, specifically the play portion. Here, players alternate playing cards and adding them to a running total. If you can make the total 15 or 31, you score two points. When my opponent leads with a card, my first question is "Is there a card that would make the total 15?" Let's say she played a 7. Then, unlike the cases above, I feel like this is rather cleanly represented as

7 + x = 15

Solve for x, and I know that if I have an eight, I should play it. Novice players will think only one step ahead, but as you gain skill at the game, you learn to foresee what your opponent might have. For example, you never lead with a five, because:

5 + x = 15

Here, x=10, and there are more tens in the deck (counting Jack, Queen, and King as ten) than anything else. There's yet more strategy to the play as it relates to the show, but we'll leave that as an exercise to the reader.

Playing Flash Duel is similar, and even more explicitly mathematical. If my pawn is on space 14 and my opponent's pawn is on space 8, then I think, "14-8=6, and so if I have two cards in my hand whose sum is six, then I can pull off a dashing strike." When I play with my five-year-old son, he occasionally says, "Can I do some math on this one?" This means that I put my finger on his space while he moves his pawn as if he were playing cards from his hand, to determine whether he can pull off an attack or not.

I've been playing cribbage for as long as I can remember. It's one of my family's favorite games. In fact, one of my most prized possessions is the board my father made for me upon my college graduation.

Do I enjoy math because I learned cribbage, or would I have loved math without it? That's a great question that's impossible to answer. A real research question can be made out of this, though: would a child learn equations better by overlaying them onto a cribbage game interface? That is, if one took cribbage as-is and displayed formal notation as I did above, would one learn the concept of variables and equality faster than if one did it by lectures and worksheets? I think that's a great question, but it is undeniably a research question, not the kind of thing one should bank a game design on.

There's no denying the mathematical nature of board games and video games, and I don't doubt for a moment that players learn mathematical thinking by playing these games. The ETS Assessment Game Challenge is clearly directed at more traditional assessments of mathematical reasoning, as expressed through conventional notation. It seems that there are two ways one could move forward with this. The first is to design a game where the math notation is overt, where the explicit mathematical representation is a necessary part of the game. This is an interesting design challenge. The other way to move forward is to design an assessment that can get at the tacit knowledge students get by playing games, to show that a student has learned the idea of equality, for example, without having need of traditional formal representation. This is a high-risk proposition, as transfer would be difficult to show (a research problem) and you'd also have to convince the judging board that your design actually matches their solicitation.

I don't know how much further I will personally pursue the competition. It certainly got me thinking, and I am eager to see what comes out of it whether I have an entry or not. Writing this essay has given me the opportunity to articulate some of my thoughts about the competition, and maybe it will be useful to you, dear reader, in your own attempts to create game-based-learning activities. In the meantime, if you know of any games that use mathematical notation as an integral part of gameplay, I'd love to hear about them in the comments.

Found one! Number Scrabble
and another! Equate
(Actually, my wife found both. Thanks!)

Monday, May 14, 2012

EEClone PlayN Tech Demo

A little over a week ago, I came across PlayN, a library from Google that allows you to write applications in Java and have them compiled into Java applications, HTML+Javascript Web applications, Flash, Android, and iOS. I had been looking for libraries for HTML5 game development. I've been an advocate for GWT for years despite not having done anything serious with it, and now here's a related library that lets me leverage my Java skills and—at least in theory—produces browser-friendly, plugin-free games.

I decided to use my old EEClone case study as an example. EEClone was a study in design patterns and game development. In the intervening six years, I've gained considerable interest in a few tools and techniques, including test-driven development, entity system architectures, and clean code. I decided to invest the first week of the Summer on an integration of these ideas.

You can see the result of my week's worth of effort online. It's more of a technology demo than a game. Use the arrow keys to move around and space to explode. Lives are not tracked and collisions with obstacles are not processed, nor is there a fancy title screen or scoreboard. Also, in the absence of any optimization, performance degrades over time. With those caveats, I would call it a rousing success.

There is a good tutorial for getting started with PlayN on the project wiki. One of the first things you encounter when tinkering with PlayN is Maven, which I had heard of but not previously used. It took some time to understand what it was actually doing, but once I got over that learning curve, I was blown away by the power of this tool. There's a discussion on the PlayN google group in which some folks are upset about Maven's complexity. It's true that I had some Maven-related headaches, but now that I see what it's doing, it's hard to conceive of another portable, platform-neutral way of managing the incredible complexity of the task.

I tried to do the whole project from within Eclipse, but even after updating the Maven indexes, I could not find the most current (1.2) PlayN files. When I followed the command-line instructions, it worked fine. I am still uncertain why Eclipse's Maven Repositories view shows that the 1.2 files are available and yet the newest archetype I can create from is 1.0.3.

I ported the core of the Morgan's Raid entity system implementation into EEClone-PlayN project. Each of the components and systems were created using test-driven development and Clean Code principles, using JUnit for unit testing (of course) and Mockito for mocking. I had previously only used EasyMock for mocking in Java, but after reading some recommendations for Mockito, I figured I'd give it a try. I am quite pleased with the balance between expressiveness and terseness of the API. For example, here's a test:

public void testExplosionCreatedNotification() {
    ExplosionFactory.Listener listener = mock(ExplosionFactory.Listener.class);
    factory.createExplosion(0, 0);

The listener is mocked, and after creating the explosion, we verify that the explosionCreated method was indeed called, where verify is a static method on Mockito. That's about as tight as it could be.

Here's an example of what makes Maven amazing. I wanted to use Mockito, but only during testing. Previously, I would have downloaded the jar, copied it into my project folder, and updated my build path, thus having access to Mockito. Then, I would be careful to only use it in my unit tests and then exclude it from exportation in my ant build scripts. With Maven, I just dropped into my pom.xml configuration file and added these few lines:


Seriously, that's all I had to do, and Maven took care of downloading the library and putting it in the right place.

A similar trick was all I had to do to incorporate Guava. Looking for something unrelated, I came across Guava's EventBus, which looks great. Sadly, it's not gwt-compatible, and so I stuck with my Holub-style publisher/distributor architecture for implementing the Observer design pattern. One of the benefits of this approach is that it avoids concurrent modification exceptions, such as when processing an event results in a modification of the listener list itself.

When I got to the point that I wanted to track framerate, I decided to use the TriplePlay library. This comes from the good people at Three Rings. I know them from Puzzle Pirates, but many of my students are more familiar with Spiral Knights. Three Rings is the largest Java game development shop I know of, and they should be applauded for their community contributions. In addition to TriplePlay, a library to ease PlayN development, they have contributed much of their core engine in open source licenses. I ended up using TriplePlay to handle the FPS/UPS labels as well as the explosion animations. If you pick up PlayN, I'll strongly recommend TriplePlay's animation support. It defaults to a layer-oriented approach. I used a single immediate mode layer for rendering, but I could still use TriplePlay since you can plug in your own interpolation value wrappers. For those who are curious, I did experiment with PlayN's ImageLayer system that is featured in the GettingStarted and demos, but then I came across Lilli Thompson's Cross Platform Games with PlayN presentation slides, and it seemed that immediate mode would work best for my purposes.

I spent about a day trying to incorporate dependency injection into EEClone-PlayN via Gin and Guice, partially based on a question on StackOverflow that implied someone else had got it working. It seems to me that dependency injection would be a convenient way to pass entity managers around to different systems, if nothing else. I never did get this to work, though, and I think it was a bit of a pipe dream. I have been eager to use Guice for DI in a Java project, but because it won't work with GWT, it would have had to be pulled out completely from my game logic anyway. At that point, the benefits just weren't worth it to me.

PlayN is designed so you can quickly and easily debug your program interactively in Java, which worked great. Then, when you want to make sure the HTML+Javascript version is working, you do the much-lengthier GWT compile and test it in the browser. This worked well, except for those cases where I inadvertantly incorporated a non-GWT class in Java, where it was happily included and then only rejected when I attempted GWT compilation (for example, Guava's EventBus).

This morning, I revised the architecture to use the state pattern, as in the original EEClone. I decided to put a moratorium on new features—essentially making this a tech demo rather than a game—and so there are only two states: playing and exploding. Pressing spacebar triggers the transition from playing to exploding, and the end of the explosion chain triggers the return. When I first put this pattern into place, there was no discernible impact on performance. However, when I refactored common code into an abstract state class, the Java version of the program began to slow down. Interestingly, the HTML version did not, although my GWT compilation time nearly tripled. I did not rigorously analyze this situation, but I suspect that the aggressive inlining and optimization from the GWT compiler eliminated the indirection caused by following a Clean Code approach, especially removing all code redundancies and keeping methods to a maximum of four lines.

Once I was reasonably content with the source code, feature set, and stability, I packaged the application using Maven. This produced a war file, which frankly, I did not know what to do with. I was not interested in hosting this tech demo on Google App Engine, and I don't have an application server freely and easily accessible to me. However, EEClone-PlayN does not do any persistence or network communication, so it turns out I could just unpack it into my server space and it worked. Well, it almost worked. The first time I uploaded it, the screen flickered to black erratically. In fact, it would be more appropriate to say it flickered from black to the game, as it was more black than not. On closer inspection, I realized that the FPS/UPS labels were missing. This inspired me to open up the console in Chromium, where I found stack traces from TriplePlay instructing me that the application had to be compiled without disabling class metadata in order for its CSS support to work. Another post on stackoverflow prompted me to stick the following code into my HTML pom.xml file, after the artifactId of the org.codehaus.mojo plugin:


Re-compile, re-upload, re-extract, and that's the version you see now online.

One of the observations I made while working on this was how the entity system architecture and TDD work well together to produce modular code. A few times when I was working on user-facing elements—which are notoriously difficult to develop via TDD—I found myself taking too large of steps. This resulted in a lot of badly-written code and wasted time. Pulling back and thinking about the system in smaller pieces allowed me to write unit tests with very quick turnaround. Mockito certainly facilitated modular design as well, as I was able to insert dependencies with one-off mock objects. Of course, I knew all these things going into the project, but it felt great to experience them again first-hand. I've spent the last ten months with my head in Unity3D game development, where the tools make it very easy to slap together systems, but we never found any good solutions for serious software development concerns such as distributed version control, object mocking, or continuous integration.

I want to take a moment to point out what may already be obvious to the reader. I wrote a game in Java using best practices such as test-driven development, design patterns, and Clean Code. I used professional tools of the trade, such as Mockito, Maven, Eclipse, and Guava. The resulting tech demo runs in HTML and Javascript in any modern browser without requiring plugins. It has great performance without investing any time in optimization. This is awesome. Thank you, PlayN developers!

Working on EEClone-PlayN was a great way to spend the first week of the Summer. After months of project management, it was great to get my hands dirty, to play with some of my favorite libraries while checking out some new ones. I have a half-written blog post about why I'm doing this at all. Suffice it to say, this Summer I'm knocking a few monkeys off my back while investing in personal and professional growth. Stay tuned for more!

Tuesday, May 8, 2012

Games, Fun, and Learning talk is now online

The Games, Fun, and Learning talk I gave in April for the Emerging Media Initiative can now be found online. Here's the URL:

I just watched it, and I think it turned out pretty good. Special thanks to Josh, Ryan, and Nick for their excellent cameo appearance. The accompanying blog post provides links to many books and articles, including a clarification that Chris Crawford's first book was The Art of Computer Game Design

Sorry that it requires Silverlight; I had no control over that.