# How Can I Improve This Card-Game AI?

Let me get this out there before anything else: this is a learning exercise for me. I am not a game developer by trade or hobby (at least, not seriously) and am purely delving into some AI- and 3D-related topics to broaden my horizons a bit.

As part of the learning experience, I thought I'd have a go at developing a basic card game AI. I selected Pit as the card game I was going to attempt to emulate (specifically, the 'bull and bear' variation of the game as mentioned in the link above). Unfortunately, the rule-set that I'm used to playing with (an older version of the game) isn't described. The basics of it are:

• The number of commodities played with is equal to the number of players.
• The bull and bear cards are included.
• All but two players receive 8 cards, two receive 9 cards.
• A player can win the round with 7 + bull, 8, or 8 + bull (receiving double points).
• The bear is a penalty card.
• You can trade up to a maximum of 4 cards at a time. They must all be of the same type, but can optionally include the bull or bear (so, you could trade A, A, A, Bull - but not A, B, A, Bull).

For those who have played the card game, it will probably have been as obvious to you as it was to me that given the nature of the game, gameplay would seem to resemble a greedy algorithm. With this in mind, I thought it might simplify my AI experience somewhat.

So, here's what I've come up with for a basic AI player to play Pit... and I'd really just like any form of suggestion (from improvements to reading materials) relating to it.

Here it is in something vaguely pseudo-code-ish ;)

``````While AI does not hold 7 similar + bull, 8 similar, or 8 similar + bull, do:
1. Establish 'target' hand, by seeing which card AI holds the most of.
2. Prepare to trade next-most-numerous card type in a trade (max. held, or 4, whichever is fewer)
3. If holding the bear, add to (if trading <=3 cards) or replace in (if trading 4 cards) hand.
5. If cards are accepted for trade within X turns, continue (clearing 'failed card types').
Otherwise:
a. If only one card remains in the trade, go to #6.
Otherwise:
i. Remove one non-penalty card from the trade.
6. Add card type to temporary list of failed card types.
7. Repeat from #2 (excluding 'failed card types').
``````

I'm aware this is likely to be a sub-optimal way of solving the problem, but that's why I'm posting this question. Are there any AI- or algorithm-related concepts that I've missed and should be incorporating to make a better AI? Additionally, what are the flaws with my AI at present (I'm well aware it's probably far from complete)?

-