Jim's Blog Ramblings about novels, comics, programming, and other geek topics


XNA Game Development

Google AdSense

Well, I'm back trying to make my XNA game again. It feels like forever ago, when XNA was just in beta and I was messing around with it. And it feels like even more forever ago, that I was working in C++ trying to get my game finished.

Today, I don't get much free time to devote to my hobby of game development. So I've got to make the most of the time that I can spend. Between work and life, I do squeeze in a few hours, but I've yet to finish a game.


User interface design for an ad-hoc database query form

Google AdSense

That's a mouth full to say and even harder to explain.

It feels like that as long as I've been doing web development, the most important and complicated item of the web projects has been making an ad-hoc query form that is flexible and user-friendly enough for end-users, but provide them with everything they want to do (or everything think they want to do).

It is easy to design a form that allows users to query specific fields of the database, but it's oftentimes harder to give users more options and keep the complexity low enough that they don't end up writing complicated SQL syntax.

The problem lies in when users want to change the query form from a simple SQL statement into a more complex statement by using logical operators (AND, OR, NOT, etc.).

My examples below will use three (3) database fields: CarModel (varchar), CarColor (varchar), and HasGPS (bit/boolean). These database fields are for readability and are not intended to be implemented as such.



Here's a few thoughts, links, and gripes that I've had while doing my taxes this year.

America is a land of taxation that was founded to avoid taxation.  ~Laurence J. Peter


I've never understood why stock brokers don't include the purchase date and cost basis on the 1099-B forms. Every year, I need to go back through my transaction list to determine exactly when I purchase a stock in order to determine short/long gain/losses. What's even worse, is when I purchase more stock and one transaction might be short and another transaction might be long terms.

A fine is a tax for doing something wrong.  A tax is a fine for doing something right.

Claim your property taxes

I have an impound account for my home loan. I know this isn't the best way of managing your money (since you don't earn interest on the money throughout the year). However, it is the easiest and I don't need to worry about writing two large checks at the end (Nov) and beginning (Jan) of each year.

Just in case you forget how much you are paying in property tax, you can view your bill online.

  • San Diego Property Tax
    Retrieve and review your property tax bill including an itemized assessments, fees, bonds, etc.

People try to live within their income so they can afford to pay taxes to a government that can't live within its income.  ~Robert Half

Claim your CA VLF

I can't remember, but I think I received my tax statement for my CA VLF last year after I filed. Luckily, there's an online form from the California Department of Motor Vehicles (CA DMV) that you can use to calculate how much you paid last year.



Mouse in a maze programming challenge

Nick Gravelyn has posted a programming challenge for beginner programmers. While I'm certain that I don't qualify for it, I went ahead and submitted my solution.

He presents the classic Mouse in a maze challenge. Instead of finding the way out off the maze, this time the mouse needs to find the cheese in the maze. He provides the abstract Mouse class that submitter should use as their base class.

It's been a while since I've done this homework project challenge, so I took a crack at it to work on my logic skills and see how good my memory was from those Introduction to C++ courses.

I used a Stack to keep track of my trail so I can backtrack and a copy of the maze to mark which cells I had visited, so I don't revisit cells. I also implemented a shortcut using Nick's IsMouseByCheese function. So if the mouse is near the cheese, then it will only move 1 square away in all directions looking for the cheese. Otherwise, the mouse might be within 1 square of the cheese/goal, but keep going right by it.

My Related Posts: , ,

Developers are Clone Troopers and Project Managers are … Storm Troopers

Max Pool of {CodeSqueeze} writes an interesting article titled "Why Managers Are Like Clumsy Storm Troopers".

Anytime software development or project management can be related to Star Wars themes, it makes the inner-geek in me want to spread the news...

... developers are like Clone Troopers. They are quick, disciplined, and deadly in their specialty.

Managers are elite forces in their own galaxy (far, far away); however, when they attempt to reenter the development trenches they look like the clumsy 2nd generation Storm Troopers.

When managers spend to much time in the meeting room (aptly named Death Star Room), developers turn into much weaker forms of their previous self.

For those who aren't aptly versed in Star Wars. The Clone Troopers were the military troops in Star Wars episode 1, 2,  and 3 (the new movies). The ones that fought alongside Anakin and Yoda and were great at shooting and killing stuff. These were the clones produced in Star Wars episode 1 by cloning Jango Fett.

The Storm Troopers are the later military forces found in Star Wars episode 4, 5, and 6 (the old movies). These are the Storm Troopers that Luke Skywalker fought against and they were really awful at shooting and killing anything.

(via Arjan's World)

My Related Posts: , ,

Convergence 2008: Kevin Schofield Keynote

Part 2 of my Convergence 2008 blog entries...

Kevin Schofield is the General Manager of Microsoft Research. His keynote mainly focused on data and viewing of data.

... we all live in a data intensive world. We're surrounded by it, it pervades our work lives, it increasingly pervades our personal lives. It's sort of like the Force, .., it surrounds and binds everything, and holds the universe together. And there are definitely some people who are more adept at sort of harnessing it than other people. But I think we'd all really like to be kind of data Jedi Knights, if you will. So I'm going to talk a little bit about technology and how it can help with that.

-- Kevin Schofield

One of the more interesting parts of his keynote was the focus on data presentation. In one case, Mr. Schofield used the 19th century drawing by Charles Joseph Minard as an example of good presentation showing six different dimensions of the data in an easy to read presentation layout (view drawing). It's a pretty famous drawing showing Napoleon's march from Poland to Moscow. The drawing illustrates latitude/longitude, numbers of troop, direction, and temperature.

Data center sensors

Next, he shows a new project where Microsoft are playing sensors in their data centers. This project allows the data center IT teams to monitor heat of the servers in a real-time and over-time trends. This is also linked into the HVAC system, so they can the operation of the individual HVAC units. Combined with a nice little heat map, you can easily see which side of the room is producing more heat and which HVAC units are running at 100%. The sensors also show CPU utilization, disk utilization, rack utilization, etc.

Space Shuttle Challenger

The next set of slides showed how the right data in the wrong presentation format can lead to disastrous results. He used the Space Shuttle Challenger explosion after takeoff in 1986 as the example. In this example, the engineers had presented all of the data needed to make the decision to not launch the space shuttle. However, the diagram was so complicated it even had the statement of "don't use this chart unless somebody gives you an oral explanation" posted on the diagram footer. The engineers couldn't explain or illustrate the problem very effectively to their executives.

While I looked at this diagram, I couldn't see the potential problem. However, once the data was change into a more easier to read format, it became obvious to everyone how the launch would result in O-ring failure.

Spatial memory

Next, he focused on how we, as humans, have a pretty good spatial memory. We can remember everything in our house, but have problems remembering where the most recent document or file is on the computer. Microsoft is experimenting with storing and retrieving data in a 3D manner instead of the usually 2D input.

They showed the results of a survey, where they created a simple 3D (inverted plane) and had subjects bring their own photos and file them in groups/clusters and placed them somewhere. Then three months later (without seeing it), nearly everyone remembered exactly where they put each photograph.

They said that they are also experimenting with filing Internet Explorer bookmarks in a 3D environment.


Most everyone has already seen these charts by Gapminder. They were pretty popular around the Internet a few years ago.

Metadata searching

Next, Mr. Schofield showed off a Microsoft Research tool that looked similar to the Grokker enterprise solution that I experimented with a few years ago. The user interface was very similar to Grokker where it created clusters of related content that you drill down into, in other words an ontology visualization user interface (PDF).

Cholera Epidemic

John Snow was an early 19th century physician living in England during the Cholera epidemic. Back then, they didn't understand much about Cholera nor how it spread.

Working with a local priest, he mapped out the locations of the people who became infected and then added the locations of the city's drinking wells. He discovered that the majority of people who were sick were located close to a single well. At the time, most people thought it was caused by "bad air", but he thought it had something to do with the water.

Microsoft Research Projects

Research Project 1: 3D model of all neural circuitry of the brain

Microsoft is also making some pretty cool 3D data visualizations. One of the projects is to map all of the neural circuitry of the brain. This would allow researches to "fly around" the brain and look at the nervous system in 3D.

Research Project 2: Environmental data repository

The next project demonstrated was the FluxData project.

[The] database consists of over 900 site-years of data from over 170 eddy covariance measurement sites. Major efforts were made over the past year to harmonize, standardize and gap-fill the ‘raw’ 30-minute data records submitted by participants. The database also includes value added products like gross primary productivity, ecosystem respiration, climate and site characteristic information.

Research Project 3: World Wide Telescope

Finally, what I consider the coolest research project demonstrated... The World Wide Telescope project. Basically, it's like Google Earth or Virtual Earth in space. You can fly around to all of the solar systems and galaxies and turn on space imagery and data collected by various astronomery agencies and groups.

Most scientific data will never be directly examined by scientists; rather it will be put into online databases where it will be analyzed and summarized by computer programs. Scientists increasingly see their instruments through online scientific archives and analysis tools, rather than examining the raw data. Today this analysis is primarily driven by scientists asking queries, but scientific archives are becoming active databases that self-organize and recognize interesting and anomalous facts as data arrives. In some fields, data from many different archives can be cross-correlated to produce new insights. Astronomy presents an excellent example of these trends; and, federating Astronomy archives presents interesting challenges for computer scientists.

-- Microsoft Research paper, 2002

It also appears that Google is working towards their own Google Telescope project. Microsoft's telescope will go live in a few weeks and I believe that Google's project is still under development.


Lastly, they showed a video of a game created for kids to teach them how to program. The game allowed the kids to select their character and program reactions. For example, "when [creature] sees [snake] then [run away]". With various levels of reaction programming, the kids were able to watch their creation walk around and interact with it's environment. The game was created for the XBOX and it looked pretty interesting.


My Related Posts: , ,

Convergence 2008: Steve Ballmer Keynote

Last week, I didn't get a chance to blog because I was attending the Microsoft Convergence 2008 conference. This year it was held in Orlando, Florida and the keynote was given by Steve Ballmer, Microsoft Chief Executive Officer.

This was the first keynote that I've seen given by Microsoft. In the past, I've been to many conferences, but mostly web or GIS related.

Mr. Ballmer joked a little about the attempted Yahoo! acquisition and mostly talked about the future of Microsoft and their dedication to the Microsoft Dynamics product lines.

Ron Rittenmeyer, EDS Chief Executive Officer, also made an appearance and announcement stating that they are becoming a strategic partner with CRM.

It's clear to us we see the entire Dynamics thing as definitely an enterprise grade solution. So, we're pretty impressed by that. It's mature. It's really made its mark.

CRM from our standpoint is something we see as our fabric. It's probably not known to a lot of people, but we manage about 26,000 contact agents, contact center agents. We do it in about 26 countries, managing roughly 450 clients, and we do it in 48 languages.

So, I think we understand customer interaction, and we see doing this across applications, implementation, hosting, contact center services, and industry BPO, which we're very big in.

So, from our perspective we think the product is an excellent product, and we think it's mature. I said it's enterprise grade, and we really do believe that. It's flexible, it's scalable, it's user friendly, and most important to us it's really easy to implement.

-- Ron Rittenmeyer on Microsoft CRM

Overall, this first keynote was nice and the Cirque De Soli like acrobats was an interesting show. However, I think I enjoyed Kevin Schofield, General Manager of Microsoft Research, keynote on the final day much more. I'll post some comments on this session soon. There's a few neat things coming out of Microsoft Research and one of them should go live within the next couple of weeks.


How to load a Google SketchUp model into a XNA game

For casual 3D modelers, Google SketchUp is a good alternative to more complicated and robust software such as Blender and Maya.

For developers who prefer to get decent looking models up and spend their time writing code, then SketchUp could be used to assist in visualizing their concept.

You can use the free version of Google SketchUp to export to the Microsoft DirectX .X format by using a custom built plug-in. I'll describe the steps below, but if you are just looking for the plug-in then it can be found at:

The script was created by r1kdou (of XNA forums). You can view his original post here.

Installation & Setup

First, install Google SketchUp, install the above plug-in (just copy it to the <Google SketchUp install directory>/plugins folder).

Finding & Loading the Model

Next create your own or find a model via Google SketchUp warehouse. There's tons of free models built by users and you've bound to find at least one or two you can use.

Here's a good looking model that I'll be using:

Sketchup Model Example

Export To DirectX

Next, export the model to .X format by choosing the "Export DirectX" menu choice in the "Plugins" menu.

Loading the Model into your XNA Game

Finally, copy the .x file to your "Content" folder, and include it in your project using the default "X File - XNA Framework" content importer and "Model - XNA Processor" content processor.

Don't forget to include any texture files that the model requires. If you don't know which textures are in use, you can open the .X file using Notepad and see the TextureFilename values (listed at the top of the .X file).

Place the textures in the same directory as the .X file, but you don't need to add the texture images to your XNA project. Also, make sure your image dimensions are all resized to a power of 2 (2, 8, 16, 32, 64, 128, 256, etc.).

You will get a compile error if you are missing texture files or an image size is not a power of 2.

Viewing the Model in your XNA Game

Assuming, you have your camera and basic game already coded, you can now just load the model using the ContentManager.Load<Model>("modelName") function.

Here's a screen capture of the above model loaded into my current game framework. You may recognize the terrain and skydome from the XNA Generated Geometry sample.

XNA Game using SketchUp Model

You can also use Google SketchUp for designing entire levels. I'm unsure of the speed involved in loading a level of that size, but hopefully (one day), I'll test that out when my game makes a little more progress.


How to use nested repeater controls with relational data

Oftentimes, you may need to nest repeater controls with relational data. There's an easy way of doing this, but you'll need to define your relationships and write a small function to retrieve the related/child data records.

Database Relations

In this example, we'll use three (3) tables defined below.

Nested Repeater Database Diagram Example

This is a simple relational database and does not follow any naming or key standards. So don't name your primary keys and define your relationships like this in real databases, if you can avoid it.

ASP.NET Design View

Next, let's add some simple HTML code. This will write out the user's name and then create two ordered lists containing the user's favorite foods and movies.

In the code below, the repUserList is the top-most repeater control. Within that repeater control are the two repeater controls of repFavMovieList and repFavFoodList. The two nested repeater controls will query the dataset and retrieve only the records related to the record being displayed in it's parent (repUserList) repeater control.

<asp:Repeater ID="repUserList" runat="server">
          <asp:Repeater runat="server" ID="repFavFoodList" 
          DataSource='<%# GetChildRelation(Container.DataItem, "User_FavFoods")%>'>
               <HeaderTemplate><h2>Favorite Foods</h2><ol></HeaderTemplate>
                   <li> <%#Eval("FoodName")%> </li>

          <asp:Repeater runat="server" ID="repFavMovieList" 
          DataSource='<%# GetChildRelation(Container.DataItem, "User_FavMovies")%>'>
                <HeaderTemplate><h2>Favorite Movies</h2><ol></HeaderTemplate>
                   <li> <%#Eval("MovieName")%> </li>


Populating the DataSet (Code Behind)

First populate your DataSet by using any means necessary. There are numerous ways of populating a DataSet, so I'm going to skip this part since there's just too many different techniques.

The DataSet variable name used in the example code is "dsUserData." There will be three (3) DataTables within the dsUserData DataSet. These DataTables will be "User", "UserFood", and "UserMovie" (to match our relational diagram above).


Defining Relationships (Code Behind)

Second, define your relationships between the DataTables of the DataSet. When defining the relationship, note the first parameter - the relationship name. We will use this name later when we access the related data.

dsUserData.Relations[0].Nested = true;
dsUserData.Relations[1].Nested = true;


Data Binding (Code Behind)

Next, we'll set the DataSource of the top level repeater to our top-most/parent table. Finally, we'll call DataBind to bind the DataSource to the control.

this.repUserList.DataSource = dsUserData.Tables["User"];


GetChildRelation function (Code Behind)

The GetChildRelation function is called from the HTML design view and returns a DataView used as the DataSource of the child repeaters. The function requires the parent record and name of the relationship as parameters.

protected DataView GetChildRelation(Object dataItem, string relation)
   DataRowView drv = dataItem as DataRowView;
   if (drv != null)
      return drv.CreateChildView(relation);
      return null;

You could enhance this function by adding a validation check for the relation name to make sure it exists before attempting to retrieve the view. 


Nested Repeater HTML Output Example



Gary Gygax (1938-2008)

Most people will probably not know about Gary Gygax, but his influences have been instrumental in the gaming and fantasy industry for over the last thirty years or so.

If you've ever played a role playing game, such as World of Warcraft, Mass Effect, Final Fantasy, or Star Wars: Knights of the Old Republic, then you've experienced some of his legacy.

Along with Dave Arneson, they created and pioneered role playing games by publishing the game Dungeons & Dragons. Later, he co-founded Tactical Studies Rules (TSR) which published Advanced Dungeons & Dragons (and later purchased by Wizards of the Coast and then Hasbro who now owns the rights to the gaming system). An estimated 20 million people worldwide have played dungeons and dragons.

Games give you a chance to excel, and if you're playing in good company you don't even mind if you lose because you had the enjoyment of the company during the course of the game.

-- Gary Gygax, Aug. 15, 2004

Mr. Gygax was ranked #18 on "GameSpy's 30 Most Influential People in Gaming" (tied with J.R.R. Tolkien). He was so popular that he even has a strain of bacteria named after him ("Arthronema gygaxiana sp nov UTCC393"). He was also ranked as the #1 Nerd by Sync Magazine.

He has also written several novels including a Greyhawk series, several game system books, and a few essays and articles for gaming magazines.

I believe that Gary Gygax done for fantasy gaming the same thing that J.R.R. Tolkien did for fantasy novels. Sure, there were fantasy novels before Tolkien, but his writings continue to inspire and influence all fantasy related creations. In the same way, Gary Gygax's gaming system wasn't the first for fantasy genre, but it has inspired and influenced nearly every role playing game (even outside of fantasy genre) since it's creation.