PDA

View Full Version : Cards Game AI



Paizo
15-06-2004, 01:52 PM
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

Alimonster
15-06-2004, 05:22 PM
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).

Paizo
16-06-2004, 09:16 AM
The game is like magic.

Problem:

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 :(

Paizo
03-11-2004, 04:22 PM
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.

cairnswm
04-11-2004, 03:55 AM
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.

blackvoid
26-09-2006, 10:25 PM
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).

jdarling
27-09-2006, 12:07 AM
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.

Traveler
27-09-2006, 06:43 AM
just to point out, the OP date is june '04...

jdarling
27-09-2006, 12:24 PM
LOL, ok guess that this thread is dead. I just answer the ones I see come up in the daily updated list :).

Paizo
14-12-2006, 02:53 PM
LOL

is never too late :D

ty for the help guys :)

skobin
15-06-2010, 06:38 PM
Try to use neural network, it works good for card games