Saturday 7 July 2012

The Game Player Project

I've decided my C and C++ skills really need to be improved since more and more of my work appears to depend on them. So in order to improve them I've decided to take on a project in my spare time that covers both programming in C and C++, OpenCV, Java and JNI. These are all pretty useful tools to use together so hopefully these entries will be of help to others as well.

The project is going to be called 'Game Player' and the aim is to develop an automated system, based on computer vision techniques, that can be used to play games. I make a point of emphasising the computer vision techniques part because there are already lots of automated game players out there that use data held in the computer's memory to play games and that's not what I'm looking to do. I want to build a system that can play a game based purely on what it can 'see' in front of it, the same a regular player does.



So first off we need to pick a game and I've went with Diamond Digger, a new game from King.com. King.com is free to sign up to and free to play games website so if you want to get a feel for the game then I recommend it, however here is a quick description for those who can't be bothered or just don't want to:


Diamond Digger is a shape / colour based matching game where you have to click on sets of 3 or more similar, touching shapes in order to remove them from the board. When you do, the 'wall' under the shape is removed and 'water' is able to flow through it. The aim is to clear a path from the entrance at the top of the board to one of the exits else where on the board.

It is a very common game theme that has lots of different version but this was the first one I came across so I decided to choose it. It also mixes it up a little by having some power ups that can help you but we'll get into them later.

I'm a big believer in getting the basics done first, the proof of concept system if you will, so to start with our system won't be very smart, all we want to be able to do is find sections of three or more matching shapes and click on them. The idea of tactics or intelligence is way down the line. So let's begin.

As I've said I want to use a combination of Java, C/C++ and OpenCV in this project since I am doing it as a learning exercise. If you were to look into it I'm sure you could do the whole project in just one language but then you miss out on all the pain and heartache of trying to get features to work in a language you don't know and who would want to miss out on that?

So let's plan out what exactly we want our system to accomplish. It should:
  1. Grab an image of the game board.
  2. Determine a valid move.
  3. Make that move.
  4. Repeat from step 1 until the game is over.
Doesn't sound too hard and you know what, with Java's Robot class it isn't. I worked on this project a while back using only Java and it was pretty straight forward, so straight forward in fact I got bored and moved on. But hopefully the use of C will help keep things interesting. Oh and from now on whenever I need to refer to C or C++ and it isn't important to distinguish which, I'm just going to say C ;)

We'll complete Step 1 in the next post.

2 comments:

  1. hi ryan, this is interesting, i always wish i could have some good time to make a fancy game like the one you did.

    ReplyDelete
    Replies
    1. Haha I didn't make the game! I'm (hopefully) going to make a system to play it though :)

      Delete