Computer Science Canada Card Game - Need help generating valid combinations. |
Author: | Faz_86 [ Sat Feb 28, 2009 5:52 pm ] |
Post subject: | Card Game - Need help generating valid combinations. |
Im programming a card-shredding game in java and am currently in the process of writing code for the AI move generation. To generate all combinations of possible moves. I am stuck at this point because I have no idea how to implement it. The problem is this: Each card has a suit (Clubs=0, Diamonds=1, Hearts=2, Spades=3) Each card has a value (Two=2, Three=3...Jack=11, Queen=12...Ace=14) I need a method in which to generate all possible moves, based on a given vector of cards and an initial card from which to start from. E.g. Initital card = Nine of Diamonds (value=9, suit=1) Vector of cards= (3 of hearts, 4 of diamonds, 4 of clubs, 6 of diamonds, 8 of diamonds, 9 of spades, 10 of diamonds, 10 of hearts, 10 of clubs, king of diamonds, king of hearts. Rule1 - From the given initial card, the allowed first card in the combination is any card which meet the following criteria:- (match the suit) or (match the value) Rule2 - The cards following the second card can match (The same value as the previous card) or (value +1 or -1 of the same suit) I am unsure of the data structure and method to implement this problem. Any advice would be greatly appreciated. |
Author: | Tony [ Sat Feb 28, 2009 6:00 pm ] |
Post subject: | RE:Card Game - Need help generating valid combinations. |
sounds like you could use recursion |
Author: | Vermette [ Mon Mar 02, 2009 12:06 pm ] |
Post subject: | Re: Card Game - Need help generating valid combinations. |
Considering the Sun tutorial on Enums uses a deck of cards as its sample, you may want to check it out: http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html |