Rock,Paper,Azure

I started playing Rock,Paper,Azure today – a great code contest sponsored by Microsoft. I ran into some trouble with their out-of-the-box bits (more on that later) but I had some fun once I got a successful deployment going.

First, the problems. I could not get the local emulator working. Rather, I can get the Oct 2012 Azure Toolkit emulator running on my local Win7 machine,. but the RPA emulator solution does not work. I got this weird exception:

That no one at Microsoft can figure out. After about 3-4 hours of changes, I gave up and decided to just use the Azure site to test my Bots (is the plural of Bot “Botts” or “Bots”?).

Second, the logistics. It was pretty painless setting up an Azure account for this context. All I had to do was to follow the instructions on their website and I got almost all of the way there. The one omission from their directions is that once you have your cloud service running,

you need to upload the BotLab so you can test your bots before entering them into the contest. There are not any instructions on the RPA site. What you need to do is onmce your provision your site, you click on its name to navigate to the upload page:

You then need to click on the Upload A New Production Deployment. You then click on “From Local” for the package and configuration files that you created when you followed this RPA step.

Once the files are loaded, Azure spins for a couple of minutes and then you get your lab that you can navigate to and upload your bots.

I then loaded up a “Brick Only” Bot to my BotLab:

and then pushed it to the actual contest site:

Third, the code.

So now that I can upload to my lab and push to the contest, I thought about how to make a better Bot. Instead of diving right into the code, I set up a new solution with a single project that had a single class. I added the necessary references and coded up a Rock-only Bot with an associated unit test:

Another interesting thing is that the API that comes with the download does not include any implementations of the interfaces. So for the BigBangBotTests, I need a instantiation of IPlayer you so I can keep track of you.NumberOfDecisions. I thought, what a great place to use a Mocking Framework. Since I am using VS2010, I decided to use MOQ to stub the IPlayer.

So to be safe, I should implement a test for moves 1-5 to make sure that dynamite only comes back. But I am not safe. What about moves 6+? For a mocking framework, I need to implement the Random method or just increment the mocked property. The later seems easier, so that is where I started. I first injected the Stub only returning NumberOfDecisions = 1 and I got red:

I then removed all of the individual runs and put the setup in the for..each loop: