Share via


Enter the Rock Paper Azure Challenge On A Mac

Last week, I announced the Rock Paper Azure Grand Tournament with $5000 at stake for first prize. The Rock Paper Azure Challenge is a coding contest in which you develop a “bot” to play the game of Rock Paper Scissors against other contestants’ bots.  The RPA Challenge also gives you an opportunity to learn more about Windows Azure and how to deploy an application to it.

The contest bots can be coded using the C#, Visual Basic, or F# languages of the .NET Framework. Reading that, you might conclude you need a Windows machine running Visual Studio to enter the contest.  However, it IS possible to code your bot AND enter the contest from a Mac (or even Linux) using Mono and the MonoDevelop IDE.

I stepped through this process using C# and Mono on a Mac and decided I’d document it here.

The main steps of the contest are documented on the “Get Started” page of the Rock Paper Azure website. To enter the contest on a Mac, you will follow the same basic steps, except instead of using Visual Studio, you will use MonoDevelop. 

Step 1: Get Your Windows Azure Account

This step is the same regardless of your OS.  If you have an existing Windows Azure account (such as the free access included in MSDN subscriptions), go ahead and use that.  If not, register for your free, 30-day Windows Azure account. Visit WindowsAzurePass.com and be sure to use Promo Code PLAYRPA.

Note: Registering for a free trial through WindowsAzurePass.com may take up to 24-48 hours to complete.

Step 2: Get Mono and the MonoDevelop IDE

Mono is an open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET.  It runs on the Mac OS, Linux, and others.  MonoDevelop is an open Source IDE that lets you develop Mono applications.

Get Mono here: https://www.go-mono.com/mono-downloads/download.html (I grabbed the 2.6.7 release for Mac OS.)

Get MonoDevelop here: https://monodevelop.com/Download (I grabbed the 2.4.2 release for the Mac OS.)

MonoDownload

I found the installation process for both of these to be rather straight forward (assuming you know your way around Mac OS installation packages).

Step 3: Deploy the Bot Lab

Part of the client download for the Rock Paper Azure Challenge is a “Bot Lab”.  The “Bot Lab” is an ASP.NET MVC website that includes an implementation of the game server logic that lets you test different bots against each other. It is effectively a ‘test harness’ for your bot code.

As part of the challenge, contestants are required to deploy the “Bot Lab” website to Windows Azure. The Bot Lab solution was created with the Windows Azure tools for Visual Studio to enable packaging for the cloud. It is designed to be run locally on Windows in the Windows Azure developer emulator or in the cloud on Windows Azure itself.

On Windows, building the solution in Visual Studio will produce a package (.cspkg) file containing the contents of the application. The .cspkg file is what you upload to the Windows Azure Management portal to deploy.

Unfortunately, there are no Windows Azure tools or developer emulator for the Mac OS or Linux. Therefore, you will not be able to run the Bot Lab solution locally on the Mac using the MonoDevelop IDE.  Instead, we have provided a pre-compiled Bot Lab package file (.cspkg) on the contest website. You can download it and then deploy it directly to Windows Azure to run it and test you bot code.

On bottom of the “About The Challenge” page, you will find the download link:

DownloadCSPKG

Here is a direct link to download the pre-compiled Bot Lab .cspkg & .cscfg files.

Once you have unzipped the files, you can proceed to the Windows Azure Management portal and deploy the pre-compiled Bot Lab files as described in step 4 on the “Getting Started” page of the contest site.

UploadPackageFull

Once you have deployed the Bot Lab to Windows Azure, you can proceed with coding your bot in the MonoDevelop IDE and then testing it in the Windows Azure-hosted Bot Lab.

Step 4: Code Your Bot

Download the Rock Paper Azure client bits from the “Getting Started” page of the contest website.

GetTheRPABits

After extracting the RPAClient.zip file, you will find two directories with Visual Studio solution files (.sln) in them: “BotLab” and “MyBot”.  You can ignore the “Bot Lab” solution as you already deployed the pre-compiled Bot Lab in the last step.  The “MyBot.sln” contains the project in which you will write you bot code.

RPAClientFolder

Open the MyBot solution in the MonoDevelop IDE by double-clicking the “MyBot.sln” file in the Finder window. 

Note: As you can see in the image above, there are subfolders for C#, VB, and F# bot projects.  It is possible to install F# and use with Mono.  However, it is not installed by default.  Therefore, MonoDevelop will display an error indicating that it is not able to open the F# project.  You can safely ignore this error message as MonoDevelop will open the C# and VB bot projects.

FSharpError

Once the solution is open, you should see the following:

MyBotSolution

There is currently a dependency issue in the Visual Basic project that prevents it from compiling in Mono. I haven’t had time to troubleshoot or determine if this issue is resolvable. I’m assuming that if you’re using Mono & a Mac to play Rock Paper Azure, you’re likely a C# coder anyway.  You need to remove the VB project from the solution by right-clicking (two-finger clicking? Smile) the “MyBotVB” project and selecting “Delete” as shown below:

RemoveVB

You will be further prompted whether to delete the project files from the disk, or just the solution. Choose “Remove” to keep the files on the disk.

VBRemove

At this point, you can open the MyBot.cs file in the C# project and code your bot! Be sure to see the brief screen cast in step 3 of the “Getting Started” page for some tips that will get you started.

Once you have coded your bot, build it by selecting “Build All” from the “Build” menu in MonoDevelop.  As you can see in the screenshot below, I’ve added some logic to track the points at stake in each hand by monitoring when there has been a tie on the previous hands.

BuildCSharpBot

Building the solution will produce the CSharpBot.dll assembly file in the Debug folder of the MyBot solution folder. This is the assembly you will upload to test in the Bot Lab and then later, enter into the contest.  You can view this in Mac Finder as such:

CSharpBotDLL

The name of the assembly file will be the name of your bot when loaded into the Bot Lab.  If you wish to change the name from the default “CSharpBot.dll”, you can either rename the file on the file system, or change the MyBot project properties in the MonoDevelop IDE.  This comes in handy if you are coding and testing multiple different bots to see how they perform against each other.

To change the name of the assembly produced in MonoDevelop, right-click (two-finger click Smile) the MyCSharpBot project in MonoDevelop and select “Options” .

ProjectOptions

In the Project Options window, select the “Output” page on the left, then set the value of Assembly Name as you wish. Now, when you build the solution, your bot’s assembly will have the name you entered here.

MonoConfigOptions

Step 5: Upload your bot and enter the contest

So, you’ve coded your bot.  Now it is time to upload it to your Bot Lab for testing, and finally to enter it in the Rock Paper Azure Challenge!

Open your Windows Azure-hosted Bot Lab by visiting the URL you gave it when deploying earlier. (For example: https:// <yourURL> .cloudapp.net)   If you forgot your Bot Lab’s URL, you can return to the Windows Azure Management portal and launch it from there.

To test your bot, follow the regular steps in “How do I test a ‘bot’ in the Bot Lab?” on the Rock Paper Azure FAQ page.

Here’s a screen shot of my Mono coded bot loaded into the Bot Lab:

MonoBotInBotLab

To enter your bot into the Rock Paper Azure Challenge, follow the regular steps in “How do I enter my bot into the Rock Paper Azure Challenge?” on the Rock Paper Azure FAQ page.

And that’s all there is to it! Hope to see more folks in the July 13, 2011 Grand Tournament!