MsPacMan Artificial Intelligence

After taking the course CS7032: Agents, AI & Games at Trinity College, Dublin. We were asked to design and implement an artificial intelligence algorithm for the famous PacMan game, under the rules of (Which seems to be down as of now) and using our knowledge of abstract architectures.

We could choose to design either the behaviour of Ms PacMan or the phantoms. I though implementing Ms PacMan AI would be “faster” as there’s only one entity to design. Never have I been so wrong. It took me around one week of spare time to get it right. Though in the end, I got some acceptable results.

The core AI algorithm is inspired by reactive agents and the evaluative feedback approach. I ran around a thousand games with multiple strategies and identified the best one by plotting the score histogram. The results are on the report.

One algorithm which I found particularly interesting is “Clustering regions by connected components”, which is a linearithmic algorithm with respect to the number of components. This algorithm has certainly many different use cases outside the PacMan world. I explain this algorithm in the report. A screenshot showing the pills clustered by region:


The project is open source and is hosted on github. Feel free to browse the code and adapt it to your needs:

Without further ado, here you have the full report. Enjoy the reading!

NB: the report was rendered using LaTeX and the graphs where plotted using Mathematica 9.

Java, WebGL and cross-platform game development


Web browsers are probably the most widely used software in desktops and mobile computers. They have become the swiss army knife of the Web 2.0 digital world and it is under this context that a Javascript API for rendering GPU-based graphics was born: WebGL.

Long live Java

The WebGL technology enables rendering complex 3D or 2D scenes such as games within your browser. You could write the next Angry Birds in javascript and WebGL. But why not leverage the power of existing Java technologies and write your game in Java using WebGL? Yes! You can write Java code and deploy it on the web as javascript thanks to the help of the Google Webtoolkit. (If you haven’t tried it, then you should!).

The following web app illustrates how easily Java and WebGL can be used together with Libgdx game development framework to create fancy 3D scenes.

Click on the image to see the webGL app. Note: you’ll need a WebGL compatible browser such as Firefox or Chrome.

Teddy bear

A screenshot of the webGL application.

Instructions: use the arrow keys to move the camera and drag the mouse to rotate the camera.

Notes about the code

  1. The code uses WebGL which is pretty much OpenGL ES 2.0.
  2. The sky and mountains background texture (a.k.a Skybox) are rendered using cube mapping and custom shaders.
  3. There is one shader program for rendering the water which is based on the excellent Jay Conrod’s water simulation shader. The water looks jaggy because there aren’t many triangles in the model. Feel free to change this.
  4. The boat 3D model comes from here and the texture from here.
  5. The teddy bear comes from here (if you know the original source, let me know).
  6. All models were exported to G3DT format using blender.

NB. The code will be available on github in the coming days.

Edit: The code is available here:

Cross-platform game development

The holly grail of developers is to code once and run everywhere. Unfortunately, this is hardly true as platforms are extremely different from each other. Furthermore, screen sizes and input devices are not the same. Nevertheless, the Java ecosystem provides great multi platform support out of the box. Add GWT and Monotouch to the mix and you’ll support Mac, Windows, Linux, Android, HTML5 and iOS from day one. Check the following cross-platform gaming frameworks to see how it can be done: PlayN and Libgdx.

Phiball, the game

Born as an informatics project, a new game has arrived: Phiball.

It’s the result of the work and effort of a very active and motivated team.

The game is in fact a mix of the classic Brick Breaker game with sophisticated physics and ‘à la Mario’ stars. It’s a java based game and uses pulpcore and jbox2d under the hood.

Try to reach all the stars in each of the 10 levels by shooting the canon. Hint: you can change the ball’s impulse by varying the time you press the left mouse button.

Tell us what you think !

You can play it online here.