Racing 24/7: Creating a Code Rally Cloud Racer on Bluemix
With the new release Code Rally v1.3, you now have the ability to run Code Rally AI Vehicles on the IBM Bluemix cloud platform. These cloud AI vehicles will automatically enter races which are scheduled by the server, and all Cloud AIs running on Bluemix (that have similar race preferences) will be able to participate in races together.
Here's how to create a Cloud Race Agent on Bluemix:
- See this page for how to get up Code Rally and running. Cloud racing on Bluemix requires Code Rally 1.3.
- Ensure that you are logged into the IBM Code Rally Cloud server. You may log-in using Google, Twitter, or Facebook.
- In the 'Code Rally Developers' view, under 'Servers' right click on 'IBM Cloud' and choose 'Log-in'.
Add a Bluemix server entry to the Servers View in the Code Rally IDE
In the 'Servers' view, right-click and choose New > Server.
Select IBM > IBM Bluemix, then click Next.
Now, enter your Bluemix account credentials. These credentials correspond to your IBM ID Email and Password. More information on getting an IBM ID for Bluemix is available on the Bluemix site - you can sign up for an account here.
Once you have entered your credentials, click 'Validate Account', then 'Finish'.
In the 'Servers' view, you should now see an entry titled 'IBM Bluemix'. Double click on the entry to open the Bluemix server view, which allows you to do additional configuration to your Bluemix deployments.
- Applications can be deployed to Bluemix from our Eclipse-based IDE (available as a standalone product as IBM Eclipse Tools for Bluemix), from the command line, or from the Bluemix website. In our case, we will be deploying from the Code Rally IDE.
- If you have any existing applications running on Bluemix, you will see them in this UI. Multiple applications may run on Bluemix at a time, and Code Rally will not interfere with existing applications.
Create a vehicle that targets the server
Next, lets create a Cloud Vehicle that targets our Bluemix server.
In the 'Code Rally Developers' view, click the 'Add new Item' button, which is a green plus. This will open the Vehicle creation dialog.
Ensure that 'Vehicle' is the selected 'Type:' in the top left. Enter a name for your new vehicle in the name field.
Under 'AI Implementation', select 'Agent'.
Under 'Liberty Servers:' select 'IBM Bluemix'. Click Submit.
A new Racer should now appear in the 'Code Rally Developers' view. It will have the vehicle name you specified, and a Bluemix logo next to it.
Double-click on your racer; behind the scenes this will create a new Web Project, populate it with the default AI logic, and open a new Java file that is named after your racer.
At this point, you may edit the AI logic to your heart's content. However, for the sake of this tutorial, lets keep the default.
Enter your Vehicle on the IBM Cloud Race Server as a Cloud Racer
Next, right-click on your vehicle and choose Enter a Race On > IBM Cloud.
You may either run a single race (similar to the standard Agent scenario with a local Liberty server), or you may run a Cloud Racer. For this tutorial, we are interested in a Cloud Racer that will run on Bluemix and enter a bunch of different races.
Select the 'Cloud Racer' tab. A list of all the tracks your racer may run on is displayed. You may select on a subset of tracks, or leave the option as the default. Likewise, you may specific which vehicle colours you are interested in.
You may also limit your racer to a fixed number of races. We are going to leave this box deselected.
A dialog will appear and the workbench will begin to enter the Cloud Racer.
Bluemix Application Details
If this is the first time you have deployed to a vehicle to Bluemix, an 'Application Details' window will appear asking for additional information on where to publish the application:
For the 'Name:' field on the first page, choose a name that no other Bluemix user would be using, for example OurCloudRacer. Click Next.
On this page, the name you enter will now be the sub-domain of the Code Rally racer app (this is why the name needs to be unique). The Code Rally racer is a web application that deploys to Bluemix, and connects to the Race server. Once deployed, you will be able to see the progress of the Code Rally racer app by visiting the deployed URL.
- IMPORTANT NOTE: The name on the first page MUST MATCH the name of the subdomain on the second page. By default, they will be the same. If they are different, the workbench will hit a 404 error when attempting to access the application, and you will need to remove the application from the server and try to enter a race again.
At the point, the application will deploy to Bluemix. You can see the progress of the deploy in the Console window. The process is complete when the following dialog appears:
Your Cloud Racer is now primed and ready to go. The Race server will periodically schedule races (between 10 to 30 minutes), and your Cloud Racer AI will automatically enter those races. Races that your Cloud Racer has entered will automatically appear in Races view, just like races that are manually entered from the Code Rally IDE.
You can stream Cloud races as they happen, or review the race after-the-fact, by double-clicking on a race in the 'My Races' view
To see a history of all the races that the Cloud Agent has run, along with statistics of how well your agent performed, right-click on your vehicle in 'Vehicles' and select Show Cloud Agent Statistics. This will bring up a web browser that points to your Bluemix application:
You may also access your agent's race results at any time from a web browser, from the same URL.
Since your AI is running on Bluemix in the cloud, your AI will continue to enter races even after you close the Code Rally IDE so you can leave it running 24/7!
NOTE: Don't forget to remove your application from the Bluemix server when you're done! The usage of Code Rally with Bluemix fits well within the Bluemix account trial limits, but you may wish to remove the application from the server when you wish to retire your AI.
Having problems? Need help?