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 .

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.

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

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:


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 …

Summer with Qt and KDE

June 15, 2009

This is my second writing. The first one was about my GSOC application and the way I would like to work. Now I would like to tell about my work, and the problems I faced to implement it so far.

I applied at GSOC with my knowledge on C++ and other programming languages. Working GUI programming with C++ always seemed a bit tough for me. Though, woking for GUI in Java, seemed nice to me, I can’t help myself in C++ (GOD knows, Why?).

I had a little knowledge about Qt before being accepted in GSOC. So, I thought Qt will be very tough for me to learn (because of my bitter experience with C++ GUI). But, I found it quite easy to start with. The thing I like most is the organization of QT, nice and useful.  Qt Assistant has made my life easy. I haven’t seen such nice reference before. Working with QtCreator made my coding simple, and the Qt Examples and demos are superb!!

I found aporoximately all the concepts I gathered on my university courses, implemented in Qt. But, I never expected STL and java like list, vector classes here. Thanks to the Qt Developers.

I found people here (KDE and QtForum) very useful. Tomaz Canabrava, my mentor, always tries so that I can write nice object-oriented code, not a working code only. I remember – in my university courses, I implemented a game with Java, but my teacher was mostly interested in the output, not my coding style. I would like to give an example about this. In C:

#define PI 3.141592654 — is fine, define the constant you need to use.

But, from the perspective of C++, we should use const here. I never thought about these little things. I went on coding define all the places. But, I learnt from my mentor that it is a bad practice. The Qt forum is also very useful to me:

I thought, the code I am writing will only be observed by my mentor. But, only someday before, I got a mail from Stefan Majewsky, where he told me to include license info. Also, he noticed me a little problem, I was using min macro of mine, but, there is qMin in QtGlobal.

Now this is time to give a overview of my GSOC Program, how it is going ….

My GSOC Program:

As I mentioned in my previous writing, I am making a game Mancala. I have made a board of the game (not complete) and now working on the logic part.


The image shows here the board I made. It is a 2*6 mancala board(6 cups on each side) with 2 Storages(big rounded rectangles). This board corresponds to many mancala games like Kalah(USA), Oware(Africa) etc. The lower row is a player’s side and upper row is another player’s side. The sowing is counter-clockwise. At the starting each cup contains 4 stones, which will change at the game continues. The stones will move within cups, but once any put in storage, will never be back from there. The numbers show the stone number in every cup, shown for the player’s ease. When, there is no stone, no number is given. When the ball will move to storage, number will also be shown here. The image below shows a image after some sowing has been done:


While implementing, I faced some problem. At first, I had to make a perfect object-oriented implementation. I made Board, Cup,Kalah(storage), Stone classes and a perfect parent child relationship among them. My mentor helped me a lot to figure out my problems. I have to learn QGraphicsView, QGraphicsScene,QGraphicsItem etc and clear my concept about GraphicsViewFramework to do this. One thing, that was very nice to me is setZValue(), the way it works seemed nice to me. I had some problem with the zValue also. At some point, my QGraphicsSimpleTextItem(number shown here) was under the ball, and from the parent child relationship of the classes , I solved it.

I have started working on the logic part, and I believe I can come up with a working game within some days  ….

GSOC 2009 : Mancala

April 27, 2009

I have been accepted to work for kde under GSOC-2009 . I am going to make a game for kde this summer.

My gsoc application can be found here.

About Mancala:

Mancala is not a game, It is really a type of board game played around the world, especially in Asia and Africa. It is recoginized by different names in different places. The board, game rules also vary from region to region. The most common games are kalah(USA,Germany), Awari(Africa).

A quick overview of mancala can be found here:

For detailed knowledge about how Mancala differs from region to region this can be helpful:

Why Mancala:

Mancala is among the oldest board games currently in existence. So, it has massive historical importance.

The variety of Mancala in different regions can be a good way to represent cultural diversity.

It can be a education game for children and give them a chance to learn counting. Along with counting, they can be acquianted with different culture and regions.

Mancala is a game and game are always fun to play.

What I am going to do:

My main focus will be on supporting variety and distinctness for regions or cultures.

Variety as there will be support for various regions and further regions can be added also. There will be a graphical editor (at primary stage I may work through command line) for setting new rules.

Themes, sounds from one region will be different from other regions. Map of regions will also be included so that barely known regions get their acquaintance to user. These will ensure distinctness.

I will first implement a command line game in C++ that works perfectly on basic rule sets. Then I will check it for bugs and fix those. After my command line program works perfectly, I will add it to the Graphical interface using Qt. The graphical interface will contain necessary menus that all KDE games normally contain. Then I will add nice sounds to feel comfortable.


Finally , I will improve the game to work it with different rules for different regions. GHNS will b eused to download the gamerules from the server. My target will be to implement the game for about 3 to 4 regions. Further addition can always be made.

Hello world!

April 24, 2009

I am A.H.M Mahfuzur Rahman from Bangladesh. Recently, I am a 3rd year student from BUET(Bangladesh University of Engineering and Technology).