I’m Tom – project lead for the Code Rally game. The whole Code Rally team and I are really excited to be bringing Code Rally v1.3 to you in the coming weeks. I'd like to take the opportunity to talk about the new functionality we have added in v1.3 and how the different types of artifical intelligence (AI) in the game.
I’ll start by looking at the original 2 AI types that we launched with back in December 2012 (the Intermediate and Advanced AIs) before looking at the Agent AI we added in v1.2 and enhanced in v1.3.
The intermediate AI is the most basic AI that you can create. You select a combination of the pre-written behaviours that we use in our random bot generator. You don’t see any code for these AIs as it only exists on the race server.It's there so that people without any coding skills at all can participate in playing the game, and can race their developer friends’ advanced AIs.
The advanced AI is where users need to be able to code.A single Java file contains the behaviour you want an AI to have in response to a range of events in the game (such as the race starting, an opponent’s car getting close to your own etc). The options you have in this AI file are very restricted; you are limited to one Java file and you have no debug, console, or system out.
The reason for these restrictions is that when you enter a race with this AI you are uploading the Java file to the race server. The server then scans your code to make sure you’re not trying to break the restrictions that we have to prevent hacking/cheating. If the server scan does not detect code we want to block, it then compiles the code locally and puts it into a race thread. It is because we are compiling and executing your code on our server that we have these restrictions in place.
In Code Rally v1.2 we were able to add the Agent AI type. This gives you the ability to run on your own computer an AI that is racing in a simulated race on another machine. This was done by turning the one file AI that we had for Advanced AIs into an entire web application.When you create an Agent AI in the game you need to provide it with a WebSphere Application Server Liberty Profile beta runtime that will host your AI.
Why did we design the AI to run as a web application?Here are the benefits we get from doing it this way:
· This separation of the AI from the race simulation lets us remove all of the restrictions on what you can do in your AI. This was possible as we implemented WebSockets – a relatively new web technology that is included in the Java EE spec. WebSockets were added to WebSphere Application Server Liberty Profile’s beta stream in May this year so we were able to use that to enable two-way communication between the remote server and your AI on your computer.
· The Liberty profile allows dynamic code changes to web applications running on it. You can watch a race while it's running. If you want to make a code change you can; as soon as you save the change the Liberty profile application server detects the change and updates your AI almost instantly. This is usually so fast that you have zero penalty in the game for changing the AI; it's down for a fraction of a second.
· You can use system.out and log output to local files so you can see what your AI is trying to do, and what values there are (eg the car's current speed, etc)
· If you leave the Code Rally perspective and look at the Code Rally Vehicles project in the Java EE perspective, you can see all of the code used in your AI’s web application. You can make changes there, if you like, as long as you don’t break the code for communicating between server and your AI.
Agents in v1.3
Now in version 1.3 we have enhanced the Agent AI. Not only can you run an AI on your own computer, but you can now take an agent AI that you're happy with and run it on a remote server in the cloud (using IBM Bluemix). That AI can then enter races automatically even when you’re offline. So youcan simulate a lot of races without having to enter every single one. You can re-watch the races when you come online again to see how your agent AI is performing, as well as see the finish times for every race it entered. This new framework also lets us add in data collection and analytics to your agent AI in Bluemix, which we are hoping to add in a future release.
Version 1.3 is also adding a lot of quality of life improvements for the game. As well as using Google OAuth to log in, you can now use OAuth for Twitter, Facebook, and Weibu too. We have also optimised our database access to speed things up and given you an option in the “my races” view to limit the number of races displayed in there. I’ll go into more detail on the release notes when we go live with v1.3 in the coming weeks.
That’s all I wanted to say about the various AIs we now have in the game, and I think it shows the evolution from having very limited, in-process AIs to allowing you to create AIs that live in the cloud and enter races against other people automatically for you!
Why is IBM building the Code Rally game?
One question we frequently get asked is why are we making this game, and what can people learn from it? Other than it being a fun example of what you can build with IBM technology, there is a method to our madness.
The natural progression we see with people creating AIs is that theystart coding at a level they are happy with – be that intermediate, advanced or agent – and then progress to the more advanced AI types as they get better with their AI code.
The Agent AI is designed to show you the development cycle professionals will be following when creating applications for the cloud. First, they develop their application on their machine (hopefully using Liberty profile as it’s free to use in development and really good at what it does) until they reach a point where they are happy with it. Then they push that application, without needing to change any code, to the cloud (in this case IBM Bluemix which runs Liberty profile) where, within a couple of minutes, the application is live for the world to see and use. We want you to see how easy it is to follow that development path. We also want to show you how it makes the game more fun if you automatically enter races against other players and you don't need to be online all the time to enter the races manually.
I hope you found this post interesting. By playing the game and using agent AIs locally and in the cloud, you're seeing how easy it is to develop web applications using the Liberty profile application server and Bluemix.
I’ll see you on the racetrack,