I'm developing a gameboard for a 4 players cardgame well know in my region (like a Bridge with 8 cards).

I create a cardcontrol class, all the deck methods and all the logics for value card and score count.

But I need some link or suggestion for the implementation of "computer player" based on a few rules to follow.

  • 1
    \$\begingroup\$ It's not clear what you're asking here. Are you asking how to program an AI to make intelligent decisions, or how to allow an AI to interact with the gameboard and cards? Or both? If it's the first, you might be interested in these questions: gamedev.stackexchange.com/questions/6189/… gamedev.stackexchange.com/questions/2194/… \$\endgroup\$ Commented Jan 7, 2011 at 8:25
  • \$\begingroup\$ how to allow an AI to interact with the gameboard and cards. I have no experience in this kind of develloping, but i know how to develop. Thanks \$\endgroup\$
    – Christian
    Commented Jan 7, 2011 at 8:26
  • \$\begingroup\$ The AI for the card game is very different from game to game, i do not think you are going to find much of an answer with out some specific card game in mind. (You do not play poker in the same way you would spades, gin or rummey for example) \$\endgroup\$
    – James
    Commented Jan 7, 2011 at 23:32

2 Answers 2


Try building a class which handles game turns, who knows all the players and their order, in a array for example.

Each time a player (human or CPU) finish playing, check if the condition to end the game (win or lose) are met.

If not, find who will be the next player. In case the next player is CPU, make it choosing the correct card combination according to its level (easy-medium-hard), and then finish the game loop again by triggering the same method I've just discussed.

  • \$\begingroup\$ Many thanks. I'm studyng Strategy techniques for solve my doubt! \$\endgroup\$
    – Christian
    Commented Jan 7, 2011 at 11:29

Here's something that I try to follow when programming AIs.

Create a set of "personalities", that is, ways in which you might expect the computer player to act. Have their actions conform to these. For instance, in a card game, you might have 3 personalities: aggressive, defensive and moderate.

Next, when it gets to the computer player's turn, randomly choose an action that conforms to the player's personality, and make sure the action is also in a list of sensible things to do.

So the logic comes down to this:

1- Based on the situation, what is a list of sensible actions to take?

2- Based on my personality, what actions from the above list would I choose?

3- Randomly choose one of these, then do it!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .