
Permutation
Hello community,
I'm working on a project an am in need of a little help, so I hope I'll get some hints here.
This is about a game, but I thought it fits this category best. So I do a board game with cards (which is completed) and now the ai needs to become smart. All this is done, but where I'm having trouble is finding permutations of my cards. Here's what we've got:
 cards are numbered from 0 to 6, so I work with ints (or Strings, whatever is best)
 we are given 9 cards > so there could be something like 111534123
 we want to pick 5 cards (their order is the important thing here)
 we want to try out all permutations an find the best (this is done)
 it should be as fast a possible (getting all 9intpermutation is not fast because of the trying part)
What I have so far is a method that finds all permutations of 5 (or 9) given ints _without_ repeating identical numbers (e.g. 11354 only appears once, not twice).
So my idea was to pick 5 out of these 9 ints and then permutate them with my algorithm.
What I need help with is:
 How do I pick 5 of these 9 cards to then permutate them? Without repetition of course.
 Is my idea nonsense and there is a way to combine these two steps or am I thinking in the complete wrong direction?
Furthermore, there are combinations that are deadly and we do not want to permutate them. Say we have 12345, and the testing shows card 2 kills us, so we don't want to test 12435,... because they're all deadly. (This is not the main question, I don't think this can be done without code.)
So, I hope I made myself clear, I apologize if not, and hope someone can give me some kind of idea. A hint would be enough, pseudo if it makes it clearer.
Thanks a lot,
Nahara

Re: Permutation
I'm a bit confused as to the game I mean what constitutes a good hand? I mean you say 12345 is deadly would 23456 or 01234 be stronger and how strong would say 66666 or 00000 be?

Re: Permutation
Hey Faz, thanks for your interest.
The evaluation of the cards depends on the current position of the player, it is kinda complex and i would rather not go into detail here, but this part is done and works fine.
By the way, the part where the second card kills us and we want to avoid further permutatons afterward is done now, it was easier than it sounded.
I would still be glad if someone could give me a hint on picking all sets of 5 out 9 ints without repitition.
Nahara

Re: Permutation
I'm bamboozled I have to say. If the order of cards is the most important have you thought about ordering them? For a video poker game I wrote I decided to create a duplicate of the hand that was ordered by strength of the card so checking for pairs/straights etc so I would only need to step through the cards from left to right once.
However that was a 5 choose 5 situation not a 9 choose 5 but if it is mostly order I think this would be something to look at.

Re: Permutation
you'll have to explain the rules of the game, otherwise the best solution we can give you is brute force (which you have right now).
I suspect, though, you'd want to do something like Faz suggested and order your original 9 cards (if possible), and then go through a predefined list of hands going from "best" (as in always pick this if possible) to "worst" (as in try to avoid this if possible). The number of different hands can be quite large, but you should be able to categorize different hands into a handful of categories and compare them using a simple algorithm.

Re: Permutation
Problem solved, topic can be closed.
Solution was completely different to my first approach, but works perfectly.
I guess I didn't describe it right, but thanks for helping anyway. (:

Re: Permutation
Fyi, you can mark your own threads as solved when they are solved. Simply go to Thread Tools > Mark Thread as Solved. I've marked this one as solved for you.