Archive for August, 2009

GSOC WrapUp : Mancala

August 24, 2009

The Google Summer Of Code 2009 ended. So, this is the time to share with the world what I’ve done.

A Mancala Recap:

The goal of my project was to make a new game for KDE. It is a board game named mancala. The target was to make a mancala game and also to set a generalized rule for different mancala games. The details of my project goals are here.

GSOC Tale:

I had experience of working in C++. But, I never used Qt or KDE API before. So,the toughest thing was to getting up to speed on the code base and tools. I chose Qt Creator as the IDE and it worked nice for me.

I thought, I should start working with setting of game rules and developing a demo version of the game. But, my mentor told me to start with the graphical interface with Qt. Honestly, I felt a little disappointed, but now I know how important that was for me. If I started with the game first, life might be much harder for me in the long run. Anyway, I ended up with a board with cups and stone. Here are the details of that phase.

The board was ready, but the stones on the cup was looking so un-smart. My mentor told me to look them real(and also gave some clue). With some effort, I was able to make them look nice. Then the real work began(as per my application). I made a xml file with the rules that defines the game(the nice Qt documentation made it easy). I changed my code so that everything conforms to the data of xml file. At this stage, I was working on the game Kalah. After being confirmed that my xml scheme works, I made other games.

Everything was going fine, but something still missing. Yeah, the animation part. The movements previously looked totally unrealistic. Perfect implementation of animation was not that easy. I am coming to this later. After I thought, I have made the animation, I started working on the game AI. I came up with a AI and implemented 3 levels of the game. So, this stage ended with a human to computer playable game(with bugs). Here are the details of this stage.

Now what I was saying. I thought the animation is fine, but after implementing AI, I found how wrong I was. Somewhere, things were going real fast, somewhere slow. I was disappointed with QTimer and the timing issues. Then, I made everything ok with a real use of signals and slots and QSignalMapper. If I were not in the problem, I might never realized the power of signals and slots.

Everything was Fine, my game is ready, but it was looking naked. Why?? The game had no background!!! So, to the theme file for every game I added theme for background and the name. Now, this is how it looks:

GSOC WrapUp : MancalaGSOC : WrapUp Mancala

The code of mancala is in the playground.

Future Of Mancala:

GSOC has been ended but, my journey with mancala will continue (and I am staying with u people).

I would like to implement the Indian lap styles so that the mancala game can work with any kind of traditional mancala games. I also want to make a human to human playable version to play through internet.

And, I will try to take mancala as far as I can.

It’s ThanksGiving Time:

I have a lot of people to thank for my GSOC project. I would like to start from the applicaiton period.

I am very grateful to Lydia Pintscher(NightRose) and JLP(I don’t know your name) to help me to prepare my application. Thanks to Stefan Majewsky for making me clear about the proposal. I also thanks Mauricio Piacentini and others those answered my questions in the IRC channel.

I feel lucky, that I got a nice mentor. Tomaz Canabrava, my mentor,  helped me every time I was in problem.

Thanks to all the people those helped me different times in IRC, mailing-list with my project and when I was messing with the svn. I found people in KDE really nice and helpful and I am happy to be one of them .

Advertisements

GSOC: My PC can play mancala too !!!

August 1, 2009

My PC have already learnt how to play mancala. I would like to know you how it can play mancala !!! But, before this I want you to introduce something worthy:

There are a lot of traditional mancala games available. I am working on African two row mancala games. These games are also diferent in many cases. http://www.wikimanqala.org/wiki/Main_Page

The games I am implementing are:

Kalah: This is the only modern mancala game I have implemented. The reason behind is, it is one of the most popular mancala games in the world. It is a single lap game, anticlockwise rotation, comprising of bonus turn and cross capture rules.

Oware: It is a traditional game from Ghana . It has many variations and I adopted the abapa. Quite different from Kalah game, no bonus turn or cross capture, but new rule of capture named count and series capture. It is also anticlockwise.

Barbados_warri: An oware version in Barbados, quite similar to oware with some little difference.

Bechi: A game from Eritrea, quite complex rotation rules, supports both clockwise and anticlockwise rotation. Single lap, count and series capture rules are supported.

Dakon: The all previous games I discussed were single lap games. Dakon is a multiple lap game from Java Island. The other rules are similar to kalah.

Sungka and chungka: These games are not much different from Dakon. Sungka is from Phillipines and Chungka from Mairian Island(Oceanea).

To know detail about these games and other such games, go to http://wikimanqala.org.

Now, come to the point. What my program is doing:

For every type of game, I have a theme file named with the game name like kalah.svg. I am also having rule of the game with the same name convention ( kalah.xml ). The name of every game is written in another xml file gamelist.xml.

When the program starts:

Screenshot

It reads the gamelist.xml file and creates buttons dynamically according to the names. So, if you click new game, you will find every available games listed in gamelist.xml. Just click a name from new game menu and play the game.

When the game starts, it reads the gamename.xml file where all rules are defined and draw the board(default game is kalah) initially. All the rules of the game are maintained in the GameInfo class.

There is a GameController class which controls all the movements of human and computer, turn making, scoring(with help of score class) etc. The computer movement comes from the MoveGenerator class.

I have implemented 3 versions of AI, easy,medium and hard(not graphical option yet), depending on the search depth of the game-tree. I have to adopt the normal minimax algorithm(with alpha-beta pruning) for mancala. There are still some scopes to improve the evaluation function.

Shortly to say, I have implemented a Human to Computer playable graphical mancala game already. I have animated the movements, but there are still much problems in the animation and I have to work on it.

On the next few days, what Should I do??

At first, I will implement game difficulty options graphically(Will start it right now). In the next few days, I will improve the animation and the graphical interface. I also want to implement a game with Indian-lap Style or pussa-kanawa lap(the only sowing style left to support) to make my program support Indian style games also. Then, if I get time, I will try to implement human to human playable game through the net.

So, I hope, some blog writings are yet to come in the next few days …