Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Cards Game AI

  1. #1

    Cards Game AI

    I would like to have some hints fo make an easy AI for cards game.
    More specifically the AI I need is for a Cards game with more than 1000 differents cards.

    Every tips/hints are welcome.

    Thanks Paizo
    Will: "Before you learn how to cook a fish you must first learn how to catch a fish." coolest

  2. #2

    Cards Game AI

    Could you expand on what you're meaning when you say "cards" game? Is it one of those ones where you're meant to collect cards of a certain type and play or trade them? If so, you'll have to expand on what your game involves (the attributes, how to win, what the basic rules are, and so on).
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  3. #3

    Cards Game AI

    The game is like magic.


    Has general rules for gameplay but the text write in any cards may ignore normal rules and apply its one....I don't know if i explain better than before.

    sorry for my poor english
    Will: &quot;Before you learn how to cook a fish you must first learn how to catch a fish.&quot; coolest

  4. #4

    Cards Game AI

    e.g.: rules say " you can't attack your self"

    a card say "you can attack your self if you have onother card in play"

    The card should take effect.
    Will: &quot;Before you learn how to cook a fish you must first learn how to catch a fish.&quot; coolest

  5. #5
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Randburg, South Africa

    Cards Game AI

    Magic the Gathering has an online version. (Magic Online). I have tried to find out how they have actually made the rules of the game work. Each time a new set of magic cards is released a new version of the game is released. Each cards rule effects are coded into the new application release. This basically means that each card is manually programmed into the game.
    William Cairns
    My Games: (Currently very inactive)
    MyOnline Games: (Currently very inactive)

  6. #6

    Cards Game AI

    Some ideas.

    Without cheat:
    Evaluate the current state of the game and give it a score. Eg: score:=own_life_pts - enemy_life_pts + own_cards_on table;
    Of course you will need a much more complicated scoring system.

    Then go through all possible actions, give them a score and finally choose the one that has the highest score.

    With cheating:
    You can use the above, but you should also calculate a score on all enemy moves. You can build a chess A-B algorithm this way (many references to it). A-B is very effective, I wrote an AI once for Maya, where you have to move 6 piles of stones - each of 6 stones. The computer was unbeatable (without cheating, no hidden cards).

  7. #7

    Cards Game AI

    I actually started to do this when Magic was still a card game and not available online. The way that I aproached the game itself was nothing like the way that Wizards has. I'll attempt to outline it and hopefully it helps you a bit:

    1) Players
    a) Players have life
    b) Players "Own" cards
    c) Players recieve protection and vuln flags (dynamic)
    d) When a player runs out of life they are removed from the game
    *) If it was agreed upon, a player will loose a card to the winner of the game
    e) By default players have a "No more then 7 cards in play" flag

    2) Cards
    a) A card can not affect on a player unless the player has the proper flag for the action
    b) Cards can place and remove flags on a player (thus allowing modification of 2.a)
    c) Once used cards are placed into the "Grave Yard"
    d) Cards can modify the flags of the "Grave Yard"
    e) Cards recieve a target set with each target set have actions and flags associated with them

    3) Grave Yard
    a) The Grave Yard contains a listing of the cards already used for each player
    b) By default a Grave Yard has the "No removal of cards" flag
    c) By default a Grave Yard has the "Cards can't be destroyied" flag

    4) Game
    a) Cards are drawn at random from the play stack
    b) Players turns are rotated unless a free play flag appears
    c) Players turns can be modified by free play, no play (skip x turns), and advanced play (allows player to play out of order) options
    d) Players marked as dead are removed from the player pile

    5) Computer Controlled Characters
    a) Draw a randomly created "Deck" from the library
    b) Evaluate cards on the table
    c) Make appropriate play

    Now all of this is at a very high level, and of course you asked specifically about 5.b and 5.c. So I'll try and explain;

    I created a custom scripting language based solely on the game itself. With options for drawing, discarding, and other common actions. The AI was a dual association, first related to the player object selected and then on the deck selected.

    So for example, if I chose a moron (play the top card on the deck no matter what) and Green Power (more land to generate stronger strikes), the AI would always play top cards unless there were a land card in the hand (rule of power from deck).

    Now, believe it or not, the example above actually makes moron fairly hard to beat. To expand on this we have to go a bit further.

    For a tougher AI; Deck tells AI that it is a Green Power deck (Land = Hit Hard) the AI scans the deck and sees that it needs at least 5 lands to play well and at most 20 lands. So the first rounds of play will simply be to place lands. Once the AI reaches land count it will then test to see what the best card it can play is (land value wise). If it can't play a card, then it will play a land. If it can't play a land or a card, then it chooses to discard the card that costs the least (yes, I said least).

    This model actually functions even better. Again though we can expand on this model to give it more information about the cards, what cards its played, and what combination cards are worth playing.

    Now days, I'd do this in Lua and FPC with SDL as the rendering engine. I wouldn't try to do it on the web (I'm not fond of Web based games), but I might make it multi-player over the web.

    Hope that helps.

  8. #8

    Cards Game AI

    just to point out, the OP date is june '04...

  9. #9

    Cards Game AI

    LOL, ok guess that this thread is dead. I just answer the ones I see come up in the daily updated list .

  10. #10

    Cards Game AI


    is never too late

    ty for the help guys
    Will: &quot;Before you learn how to cook a fish you must first learn how to catch a fish.&quot; coolest

Page 1 of 2 12 LastLast


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts