Card game AI help

Started by
8 comments, last by buzylaxy 5 years, 9 months ago

Hi,

My apologies if I am posting in the wrong section. I want to code a card game where the player needs to make pairs, triplet or quadruple to earn points. I need some help/guidance  for the AI to make it compute the best strategy based on the hand it draws and the cards on the table. to take decisions. If possible to rise difficulty by teaching the AI to count the cards in some manners to predict the player moves / mimic real players.

1- the game has 40 cards 1st round 4 cards are distributed and 3 cards for each player after that

2- points can be earned by making a match: 1point = a pair, 5points = triplet, 6point = quadruple.

I don't Know if this is similar to some existing pattern, the one I found were specific to some pupular card games like black jack.

thanks

Advertisement

I'm not getting a clear picture of the game from your description, so it is hard to give a concrete answer.

Do you understand how to win the game yourself? When you are playing, do you hold out for a quadruple or do you immediately "cash in" pairs as soon as you get them. What about for a triplet?

If you haven't already, this sounds like the kind of game you could quickly prototype with a regular deck of cards and start playing with your family and friends.

9 minutes ago, rip-off said:

I'm not getting a clear picture of the game from your description, so it is hard to give a concrete answer.

Do you understand how to win the game yourself? When you are playing, do you hold out for a quadruple or do you immediately "cash in" pairs as soon as you get them. What about for a triplet?

If you haven't already, this sounds like the kind of game you could quickly prototype with a regular deck of cards and start playing with your family and friends.

sorry about that, the highest score wins, yes you cash in the points as you go no stack up

the only situation where you can stack up points are:

1- making a pair with the opponent card right after it is played

2- make a pair with the last card on the table

it gives 1 extra point each.

there are 40 card arranged this way 4 cards of each type so below combination would be possible.

triplet and quadruplet is basically when player2 makes a pair with player1 card and player1 responds by making a triplet with player2's card

quadruple is rare as it assumes that both players have 2cards of the same type.

That helps, but I'm still not really sure about your game. It isn't clear to me what a player's turn consists of. Can they play more than one card? You mentioned something about "3 cards after that", is that per turn or how does that work? Is there a "hand limit" as to how many cards they can hold at a time?

Remember you have a lot of knowledge of your game, but we start with none. You need to think about writing a "rule book" that can quickly explain the game to a new player, with minimal ambiguity. For inspiration, look at the rule books you have for other physical board games and see how well (or in some cases, how poorly) the rules are communicated. Some of the best I have read would include an example of a round to help illustrate the rules.

In any case, you didn't answer my question: have you played your own game, ideally with other people? You should be able to prototype it, and that will help you iterate on the rules (if necessary) and understand what strategies work. Doing so will also help you refine how you communicate the rules to new players.

The rules of a game are often given by describing:

  • the setup,
  • what you do in your turn,
  • when the game ends and
  • how you determine who won.

It's not even clear to me from the description if this is a game the OP is creating or an existing game.

Once we know what we are talking about, we might be able to give you decent advice.

Explain it to us as if we were sitting around the table and you were telling us how to play it. Include a step-by-step series of examples if necessary. (e.g. "so after I play that card, then you might realize you had one in your hand and ASDF... or you could do QWER")

In the mean time, google things like Tic-Tac-Toe AI, chess tree search, minmax algorithm, etc.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

ah you got a point guys thanks for your comprehension and sorry.

yes, existing game no rule book it is more like a folklore thing played with Spanish card it is not a Spanish game however

the setup:

40 cards = 4 cards of the same type 1 to 7 jack / knight / king

the dealer distributes cards 4 on the first round then 3 each round

dealer always plays at the end case of 2, 3 or 4 players

***what you do in your turn

you can play one card only

=>during the first round

     1- first turn you play a card from your hand (this is no match no point ever)

     2- 2nd turn you try to make a match using cards in hand and the card on the table

=>during the rounds after

     1- you try to make a match using cards in hand and the cards on the table

=>during final round: last player to score points gets all the cards left on the table

***battle chance to make hit(pair) triplet or quadruplet

when you play a card if next play makes a matching with your card that's a hit

if you respond by another hit that's a triplet

if the player respond by another hit that's a quadruple (rare case in 2 players mode means the dealer distributed a pair of the same type to each hand, more chance to happen in 4 players mode)

***when the game ends and

when there is no cards left to distribute

***how you determine who won.

the player with more cards wins since one card is 1 point added to final score

Yeah, there's going to be a minmax component but to really make it work well, you could include some Bayesian inference in it. e.g. "Well, I don't have any 7s which means that it is N% more likely that other players have a 7." At that point, you can iterate through the cards you have to possibly play and come up with a score for playing that card. More importantly, you can iterate through the possible remaining turns and score out the rest of the game so that you can determine why it might be a good idea to hold onto some cards and wait for better times to play them. For example, if you have seen 3 7s so far, there's no reason for you to hold onto the last one since it will never be paired. If you have a situation where you would rather hold onto other cards and you can't pair anything right now, burn the 7. This will somewhat roll out as you are keeping track of the likelihood of each person having each card.

Bridge AI does some of this sort of thing, btw.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Thanks, IADaveMark

I'll give it a try :)

This topic is closed to new replies.

Advertisement