Card Game - Need help generating valid combinations.
Author |
Message |
Faz_86
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sat Feb 28, 2009 6:00 pm Post subject: RE:Card Game - Need help generating valid combinations. |
|
|
sounds like you could use recursion |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Vermette
![](http://compsci.ca/v3/uploads/user_avatars/637825944810b5d4444c6.jpg)
|
|
|
|
![](images/spacer.gif) |
|
|