You shouldn't store possible moves. You should calculate them on the fly instead. Of course you can use some sort of cache on the file system (like an opening book, in Chess) to improve the performance of the program, but you definitely shouldn't store everything.
Surya Prakash Raju
Joined: Dec 25, 2011
Happy new Year.
Could you please give an example?
First off all I want to explain description about this game.
Description: Tiger and Goat Game
This is a two player game in which 4 Tigers (Which is in Yellow Color) and 18 Goats (Which is in Block Color) try to overpower the other. The tigers kill the goats whenever they find goats alone and try to overpower them where as Goats move strategically to contain Tigers movements and try to leave no room for Tigers to move.
While starting game Tigers will be in the template and Goats will be Out of the template. The Player who is having goats will start the game first. Then opponents will play tigers. Here I am passing "If in case of Computer play with goats, Placing the goat in right place in the template" is the main problem.
Surya Prakash Raju wrote:How to store possible movements? and which is the best way?
Looking up the game on the web showed a square board rather than the triangular one you're using. This sort of board is much easier to represent as it's a simple array where each place can hold a value indicating the point is free, holds a tiger or holds a goat. More importantly it's easy to find out which points every other point is connected to.
You then just need a recursive method that loops through each move for either goats or tigers and then calls itself to try out the moves for the other side. You'll also need a scoring method to say whether one outcome is better than another. The moves are quite simple for tigers, just look for the first tiger in the array and then try each connected point that's free. Once you've moved the tiger then call the method again but this time for the goats. The moves for goats is the same as tigers if all the goats have been placed otherwise you just look for a free point to place your goat.
Once you've looked so many moves ahead then you can score the resulting position to see whether the outcome is good. You'll need to lookup minmax (or alphabeta) algorithms to understand how the score for the position is passed back. Once you've scored each move just play the best move.
Surya Prakash Raju wrote:I am developing a game which is similar to chess. It is a two player game.
I'm guessing the fact it's a 2 player game is the only similarity with chess or am I missing something?