This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on http://www.jameschambers.com/.

Sunday, March 6, 2011

Who’s Smarter Now, Mr. Computer?

The New York Times have posted the game Rock-Paper-Scissors – You vs. the Computer in the wake of the big Watson computer win over the human Jeopardy contestants.  They reduce AI to “building on simple rules and statistical averages” and present a game of chance, with some big claims.

They have two versions of the game, one that has to learn as it plays, the other that has some experience in the mix.

Picking an Opponent

I’m no rookie, I have been known to dominate the RPS scene at my office and I know how to stare down an opponent.  Oh, wait…shoot.  I start with the sure-fire winner, the one you should put your money on.

The Veteran Presence

So here’s their idea…after several rounds of play their computer will use statistical analysis to figure out your strategy, backed by 200,000 previous rounds of play. They don’t define the 200,000 rounds – as in, were they human played, were they 200,000 different people, if nationality or race or education played in – but for some reason that’s enough data to “exploit a person’s tendencies”, and yet, I have my doubts.

I decided to play 40 rounds.  If there was anything akin to AI in the pot, this thing should at least win one third of its games.

Here’s where I was a few moves in:

image

While it made some ground up towards the end, I was able to hold it off of any streak and the closest it got was within two.

image

After that, I teetered on +2-3 points and as high at +4-5 points, and ended up +4 over the computer, thus solidly proving that, minimally, if we’re going to partner a game of chance with technology called “AI”, we have a long way to go.

image

There was no stopping me by some ‘simple rules’ engine. ;o)

I want to point something important out about this statistic: for the one who is winning more that the opponent and the tie, they are beating the odds.  I am a combined +10 on 40 rounds here at the end of the game, meaning that not only am I beating an expert player, but I’m beating the tie-chance handily as well.

Bring in the Rookie

Finally, I tried out the “dumb” version, the rookie alter-ego that must first learn the rules and doesn’t get the benefit of 200,000 other players’ moves in a database.  I decided to give it an extra 5 moves as a chance to learn some of the rules before getting into the play.

image

What? Shocker?! How could it be that with 5 more moves against an (arguably) weaker opponent I could have fewer wins?!

Oh right…it a freeking game of chance. Unless you put on your idiot cap and play the same hand each time, this is a game of odds and they are 1/3, 1/3, 1/3 as to what I’ll play next.  Period.  Just because 200,000 other people picked R-R-P-S-S-R before me doesn’t mean that I’ll play P instead of R on my next move.

This is not a prediction, even when backed by hundreds of thousands of records, not any more than a lady in a tent with a lit glass ball.  Over time I will win 33%, lose 33% and tie 33%.  It’s no different than a coin toss, with one more side to the coin.

The only learning that this ‘AI’ does is around the rules of the game.  To that end, there’s only really six (counting ties), and it seems to know when it’s learned them all, suggesting a bias in the first place.

Okay, Yeah, But…

There’s more going on. I know it does some pattern matching and what not, but that doesn’t mean it’s AI.

After playing these games I walked through it’s demonstration about how it thinks.  It uses some good buzz words making it sound like it’s thinking, but really, this is just straightforward math equations muxed with some simple filtering that any first year CompSci student should be able to figure out. 

No magic here, folks, move along.

Conclusion

The programmers at the New York Times have created a good gimmick that will fool most of the general population into believing that they have created some form of artificial intelligence that, when it mates with Watson, is ready to techno-freak the humans into submission. 

Hey, it may even be an impressive chunk of code, but it does not represent any of the modern complexities that some impressive minds (like those at IBM) have solved.

I could likely to write a version just as capable by picking randomly the answer.

Better yet, I’m going to write a traffic light color prediction engine. 

Look out, Matrix, we’re all about to take the blue pill. Or was that the red?

Saturday, March 5, 2011

This update improves the experience of updating your phone in the future.

Well, it’s arrived, my phone’s hit the list for updating.  I got the notification on my phone and plugged it into my laptop to start the process.  My update was delayed as I was on the brick list; I have a Samsung Focus.

image

First Things First

Before I was able to apply the update, Windows Phone 7 required an update to Zune. 

image

This process took about four minutes, including the download.

image

Updating the Phone

After the Zune update was complete the software shut down but did not restart on its own.  I left my phone plugged in, but was not prompted to update.

When I restarted Zune I had to go into Settings->Update where I was able to launch the update process.

image

The only thing different this time around was that the warning had been updated to note that telephony would be disabled.

image

The estimate was 20 minutes for the entire process and I was on step 6 of 9 in about 15 seconds, so I was optimistic.

image

When the reboot was complete the updates were pushed to the phone and the computer installed new device drivers. One more reboot, the updates completed installation, and the phone was as good as gold!

image

Total time: 18 minutes, start to finish.

Thursday, March 3, 2011

Windows Phone 7 Wishlist #3

There are two things I am looking forward to in a big way, but not on my wish list (because these will be realized for sure):

  1. The upgrade to HSPA+ in my area, and,
  2. The Windows Phone 7 first update.

I’ll get to my wish list in a moment.

I am stuck on the Edge service network because of my locale. The towers were upgraded months ago, but one of the partners in the carrier network (not mine) have equipment and services and software older than bunk and they can’t flip the switch until everyone’s ready. This is going to happen in days and I can’t wait until I’m pulling down 7Mbps on my phone.

I have a Samsung device and have not yet received the update. I’m not sure if it’s a candidate thing, or a rolling update thing, or even if my carrier is blocking it (I’ve heard all three) but I am looking forward to the pre-update update that is currently in the works, especially as it paves the way for The-Big-One in the next few weeks.

I wondered here if my carrier might be blocking the update, but I don't think that could really be the case. The phone checks for updates, likely directly to a WP7 service, and the device itself is updated through the Zune software on PC.

Here’s My List

  • I would like a way to search my text messages. This is present in mail, so it seems like it’s not too far fetched in texts. I had someone text me the phone number of my friend ‘Mike’, but I couldn’t remember who sent it to me. The text was something like “Hey Mike’s new cell is…” so I should have been able to find it fairly easily.
  • I would like an editor for my alarms and ring tones. Build it into Zune, or make a Windows Live ZuneTone application that you can download and make your own ringtones and alarms. Let me set cues for vibration. Let me shift pitch and even layer multiple audio tracks. Let me share it through Zune or Live or something with my friends.
  • A first-party, no frills sound recorder. The same level of function as the one built in to Windows 7. In fact, I would love it if I could also use the audio jack as a line in to record. I volunteer on a regular basis and work the sound board (or at least help) and I hate lugging around a laptop to record the audio.
  • Because I feel as strongly as I do about this, I’m going to say it again: Canadians want to pay for their content. Please make Zune Pass available in Canada. If this plea doesn’t work, I’m going to track down folks at MIX11 and talk to them in person! ;o)

I have a couple of other items on my list, as mentioned previously:

Extension Methods for Converting ints and bools

I was recently working on a chunk of code where I had three different scenarios for conversion.  With two external libraries (something I couldn’t change) and this not being a big enough project (so not worth a facade) as driving factors I rolled a couple of simple to use extension methods.

The Code

I won’t lollygag here too much.  You need a namespace and static class name that work for your (they’re more-or-less irrelevant in the grander scheme), and a couple of static methods.

namespace ExtensionMethods
{
    public static class Extensions
    {
        public static bool ToBool(this int i)
        {
            return i == 0 ? false : true;
        }

        public static int ToInt(this bool b)
        {
            return b ? 1 : 0;
        }

        public static int ToInt(this bool? b)
        {
            return b.HasValue ? (b.Value ? 1 : 0) : 0;
        }
    }
}

Basically, we’re just using a tertiary operation to decide which value is appropriate to use in each of the contexts.

The third method is there to help out with nullable boolean values.  This was handy in my case, not sure how many people would need this.

Monday, February 28, 2011

Fixing “Unrecognized configuration section userSetting” Errors

Though I have not seen the error “Unrecognized configuration section userSetting” as a standalone exception, it has come up a number of times for me and surfaces as the inner exception on a “Configuration system failed to initialize” exception.

If you’re running into this error and following along, I’m currently using Visual Studio 2010, mostly on .NET 4.0 and I program in c#.  If you’re using a different environment some of the file names or UI might be a bit different, so you’ll have to adjust accordingly.

The exception will be raised in Settings.Designer.cs, on the first attempt to read a value from the application’s configuration.

You can fix the error by navigating to the current directory where the user settings are being saved for your app.  This will be in %system%\users\your_user\AppData\Local\Microsoft\YourApp.vshost.######\version

Delete the user.config file, clean your solution and rebuild all.  This should fix the problem.

If that doesn’t work, you may need to go so far as to shut down Visual Studio, clean out all the %system%\users\your_user\AppData\Local\Microsoft\YourApp directories of any config files and then follow the above steps.

What’s Happening?

When you first add a setting to the application through the UI, the default is to create a user-scoped setting.

image

User settings and Application settings are primarily different on two fronts:

  1. Storage location
  2. Run-time accessibility

User settings are read/write and can be altered at run-time. These are perfect to save things like favorites, window layout, user-specific options, color preferences and the like. These files are stored in a directory created for the application, basically sand-boxed from system-wide access and the only place your app can read/write from for free (elevated privileges aside).

Application settings are read only at run-time and can only be altered by changing the XML file and relaunching the application, or by some creative XML file management (and then a reload on your configuration data).  These files are stored in the app directory in app.config and also contain the default settings for users who have not yet launched the app (these are the settings that will be defaulted in for the new users).

I have hit the “Configuration system failed to initialize”Configuration system failed to initialize error a couple of times, and it always seems to be the User scope default biting me in the arse.

Basically, I create a setting, plug along for a while, then go back to add another setting and realize that I had left it in user scope.  I switch the first setting to application scope and keep plugging away.  Somewhere between then and the next time the application tries to access that property, the exception is thrown and doesn’t give you much detail at the surface level.

Figuring out the Files You Need to Delete

I said you can likely delete the user.config files without much regard.  Truth is if you’re into testing something settings-related that can be a real inconvenience.

I will drill into the inner exception to find the problem file; it’s only two deep, so it’s easy to find the path of the file in question if you’re willing to dig. 

Trust me, folks, your debugger is your best friend.

Friday, February 25, 2011

Windows Phone 7 - What if?

Nice. Looks like Microsoft is starting to ramp up the ooh-la-la with their advertising. Combined with the web-based ads with the head-to-head comparisons, the new Windows Phone 7 commercials are starting to look a little more playful.



Yeah. My phone does that. :)

Monday, February 14, 2011

An Azure Deployment Primer

From the Developer & Evangelism Labs: Introduction to Windows Azure

This post is a summary of the notes I took while working through the Introduction to Windows Azure lab in the January 2011 Platform Training Kit.  I ran into a couple of road bumps and bruises along the way and thought I’d share.

The Platform Training Kit – The download for the kit

The sample is a guestbook that lets you write your name, a message and post a photo.  A background service resizes the photo and the thumbnail is linked to the full size image.

The lab walks you through setting up the relevant bits of the application locally, then walks you through deploying it the application to the cloud.  I found it to be a good balance of hand-holding and explanation, but you may find many questions left unanswered. The Microsoft Platform Evangelism team has certainly lowered the bar for folks to get in over their head! Thankfully there are 26 other labs to help quench your thirst.

When you get it up and running, here’s what the end product looks like:

image

Well…that’s what it looks like if you post a picture of the snow on my roof with a name of MisterJames! 

Snags, Detours and Road Bumps

Documentation Gap

Following the lab from the first step and trying to use the project through all of the exercises has its pitfalls. First of all if you make a mistake, that carries through the whole way.  Secondly, when preparing for and throughout exercise 3 (deployment) there isn’t much clarity around the implications of misnaming your hosted service or storage account.  There are also rules around naming (they have to be DNS suitable names) but this isn’t clear through the docs.  Worse, the error you get when you make an account naming mistake is not very leading: One of the request inputs is out of range.  I was getting this error when making a call to CreateTablesFromModel, and nothing really pointed me back to the name.

You can, however, opt to jump in with the files provided for the lab.  At each step of the exercise the team has provided us with an updated, accurate solution to continue from.

This is good, as in step 3 it assumes you’re using that and doesn’t give clear instructions on the updates required in the service configuration file.  The nodes and values required are in the provided solution.

Error Loop on Deployment

After I completed the lab I started playing around with config files and some simple changes to the app.  In that process I managed to botch a deployment package (the configuration bits).  Unfortunately, I didn’t realize that until I had already deployed the package as an upgrade to the first version.  The instances were stuck in some updating/starting/waiting/resetting cycle that took over 40 minutes to work itself out. The result was an error state, which until reaching I was unable to stop and update the service.

A Missing Warning

I just want to add another voice to the mix here: remember to stop and delete your project as you don’t want to be incurring charges or burning up valuable compute cycles.

Time Expectations

This is a lab that is scheduled to take approximately 60 minutes.  In addition to the coding bits I took two phone calls, answered a few IMs and emails and was wrapped up on the code/deployment side of things inside 55 minutes. I did muscle through it pretty quickly, though, as I’ve done several of these labs and know the style. 

If you aren’t patterned to recognizing the parts you should and shouldn’t need to read, this lab could take up to 75 minutes to complete.  One other note: I already had my Azure account up and running, so I was able to skip that part of the task.

After plugging through the juicy bits, I then had to wait for the succession of updates, host starts, role starts and what not.  This easily pushed me over the allotted 60 minutes.

image

For all of these services to finish their progression to their final states took about 20 minutes, at which point we end up here:

image

Conclusion

Set aside a two-hour slice of time and you should be able to move casually through the lab, start to finish. The Introduction to Windows Azure does a great job of touching on many of the concepts you’ll be working with when you get into cloud development.  You will be left with questions around deployment and configuration, but this start is good exposure and the walkthrough doesn’t leave out any important steps.

Don’t forget to delete the services created in the lab!