Making of KavidiKali
The flash game
Note: This article talks about an older version of KavidiKali (Beta 1.0).
Last update: 10 July 2011.
Kali means “Game” or “Play” in Malayalam. Kavidi-Kali is “Money cowry shell-game”. KavidiKali is one of the interesting uses of “Kavidi”; the other significant use being predicting one’s future with his/her horoscope.
I am no future teller, so to me, Kavidi is something to play with, and we used to play KavidiKali a lot. But that was when I was a child, and today I sure am missing those days.
So when I had the opportunity to do something I love to, Kavidikali flash game was one of the natural choices, and indeed I enjoyed doing it.
Flash and ActionScript; I had to learn them for this game. Basically I am a C++/Windows application developer. This is my very first flash application, and I am sharing the story with you hoping that some of you would find it interesting :)
Idea of this game was in my mind for about two years, I even did some paintings (not rough sketches) based on it.
C++ being one of my favourite languages, offered a good alternative to prototype the algorithm, I implemented the entire logic of this game in C++ without any GUI. Then it was very easy to re-do it in ActionScript, and add the graphics. By the way, I used ActionScript3 the Object Oriented way.
2 to 4
Players play the game at a time (you can find the detailed set of rules of the game in the help page) each player has 4 pieces, and has to take all the four pieces to the inner most cell of a 5x5 cell board travelling through all the cells following a given path.
Players take turn to throw the Kavidi in anti clockwise order, four Kavidis are thrown together, and the number of Kavidis that end up with their flat face up will be the result of the throw, if all the Kavidis fall with their flat face down the throw will be 8.
This throw is "3"
Algorithm for the game can be mentioned in the 9 steps below
1. Simulate throw (Take care of bonus throws)
2. Is there is any valid moves, if not, go to step 1, but this time it's the next player's turn.
3. If the current player is the user of the game, let the user choose his Move; if the current player is computer, choose most suitable Move.
4. If the Move is valid, Move the piece(s), if not go to step 3.
5. Check if the game is over. If yes, tell user the game's result. Skip all steps below this.
6. If the move has resulted in cutting an opponent's Piece, current player gets a bonus throw. He/She is also given permission to enter inner circle.
7. If more valid Moves exist, go to Step 3.
8. If bonus throws are available for current user, go to step 1 for bonus throw.
9. Go to step 1 to make throw for the next player.
Choosing the best move when the computer is playing is done using a weighted tree mechanism. All the possible moves get a weightage value based on the type of the move (i.e. simple move like advancing a piece a few cells gets a smaller weight where as cutting an opponent's piece or entering a piece to the board from outside will get a higher weight). The weights of all the best possible Moves after this Move is also added to it.Coding was exciting, but doing the graphics was the real fun.
Coluor scheme of the game is chosen to reflect Keralites' association with wood, traditionally, houses in Kerala used to have all wooden furniture, a wooden framework for the roof, wooden doors wooden pillars, etc. The game attempts evoke a feel of a traditional Kerala house by using the colours of wood.
Board and background for the game.
Sword and shield used in Kalarippayattu, a traditional martial art form of Kerala, is used as symbols to mark the type of cells in the board.
Two swords mark cells where "cut" is allowed, Shield over two swords mark "Temple Cells" where cut is not allowed.
Pieces for each player are modelled after diamonds with different colours.
Making of a piece (green).
Animating Kavidis is done with hand drawn images. I placed the Kavidi on a mirror, drew it (including the reflection) in Photoshop with the brush tool, and then reduced the opacity of the reflection.
Hand movements for making a throw was the real challenge; the throw happens very fast, I was afraid that trying to imitate it slowly might not give the right poses. The solution was to capture the throw in a video, then analyze the video frame by frame and pick the most suitable frames.
Of course, I had to paint the image based on the video frame, which was fun to do with Photoshop.
Sound was the last thing in my list. Many options were considered, "Singari melam" a popular festival music of Kerala, was one of the primary candidates for background score, It is fun to listen to, but proved to be too much distraction for the game. I settled with only the natural sound of throwing the Kavidi and silence in between.
Finally, the KavidiKali is ready, I enjoyed making it, and hope that some of you will enjoy playing it, whether you like it or not, could you please let me know, I would really appreciate your feedback, please post them here.
Copyright: © 2010 - 2011 DhaneW Software Research Private Limited. All rights reserved.