[BattleCards] Designing the AI of BattleCards

Projects that are no longer in development anymore.

Moderator: MaxCoderz Staff

User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

[BattleCards] Designing the AI of BattleCards

Post by kv83 »

Introduction
Ok. This will be a small research of how a smart AI should work in the BattleCards game. I will try to write down all my thoughts in the first chapter, which I will call "Brainstorming". The second chapter I will try to translate my thoughts to a programable explanation of my thoughts... ah well... you'll figure it out once you read it I hope.

P.s.: Yes, this was written BEFORE I actually started writing the other things. I used this as an plan of how to approach this.

Brainstorming
Ok... We have an AI which should try to win. But what also is important that it doesn't want to lose. If you think those two are the same, you are wrong. For example, if the AI only wants to win, it will attack you every turn, no matter what. Rather simple. But the problem is, that it doesn't check whether it will lose or not. So in fact, to win, it must survive. As long as possible, with keeping also an eye on winning. Why? Only Healing doesn't help much either. So there must be a balance between winning and losing...

Let's say a AI is low on health. Let's say 10. It has a DMG15 card, which deals 15 damage to the opponent and a HP+15 card, which will heal 'him' (no offence to girls :P). What is the best thing to do? Well... that depends on several things. How much HP does the AI have? How much HP does the opponent have? What could be the consequences in the next turn? Here some scenarios:
1.It's obvious that, if the opponents HP is higher than 15 there is no way of winning the game in this turn. Furthermore, if the opponent still has a DMG10 or even a DMG15 card he could win the next turn if the AI doesn't heal.

2.Let's say the opponent is also low on HP (also 10). It's the AI's turn, so why don't finish the opponent off? If the game is over, it's over, right? Right!

So in fact, the AI has to do several steps.
Step 1. Check whether the AI can win the game with a card on his hand.
Step 2. Check whether the player can win the next turn.
Step 3. If step 1 and step 2 resulted in a 'no', than play a card which fits best to it's person.

What's with the 'person' stuff? Well, I thought it may be a cool addition that an AI is not only based on stats, but also has a also a certain 'taste' and 'strategy'. For example, I could introduce a 'Snake-like' enemy, which could base his strategy on poison his enemy (poison card will be introduced later on to the engine). Another example could be a Monk, which would base his strategy on 'protect' and 'light' cards. Of course the enemy's would get decks based on their strategy (like a real human would build a deck based on his strategy).

Till now I got the following monsters with a strategy.

- Snake will mainly use poison card to poison the enemy and drain cards to get health.
- Tank will use protect cards to block attacks and strength-up cards to power up himself so that he can destroy the player in one great blow.
- Monk will use regenerate and other heal cards to keep his HP high. Light spells will be the main attack source for the monk. Secondly it will use Runes to power himself up.
- Devil will use a lot of fire cards, as well as paralyze the other player to block his attacks.

A more ambitious idea I just got is that the AI even could try to match the strategy of the human player to one of the AI's located in the game and than try to 'guess' what the next step of the human player would be. Or that he tries to find a pattern in the strategy of the human.
Ahhhh... AI, a very interesting subject indeed :D

End
Hmmm... Well, seems like the second chapter isn't really needed. So I will skip this section.

This is thread is a growing thread, so I might throw in some other idea's, but even better; I always like to get some input of others.

What are your idea's? I really would like to hear! Come on... don't be shy ;).

-kv83
Last edited by kv83 on Wed 21 Jun, 2006 1:05 pm, edited 1 time in total.
Image
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post by DarkAuron »

Can't think of much to say, except that you've got this really well planned!!
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
Kozak
Maxcoderz Staff
Posts: 791
Joined: Fri 17 Dec, 2004 5:33 pm
Location: On the dark side of the moon.
Contact:

Post by Kozak »

My preference goes to an AI that resembles humans most. Predictable to an extent with some unexpected moves now and then that can give him the upper hand or let him die.

So if you could tell use what 'players' know about each other I can better think of how I would plan it. Your plans look good though.
"They say that sea was created by a man named Maarten Zwartbol, a long time ago...." - Duck, an old Corbin version
the_unknown_one
Calc Master
Posts: 1089
Joined: Fri 17 Dec, 2004 9:53 am

lol

Post by the_unknown_one »

Very nice worked out, exactly as i would do, if i had enough wisdom exp. to think of something like that :lol:
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Kozak wrote:My preference goes to an AI that resembles humans most. Predictable to an extent with some unexpected moves now and then that can give him the upper hand or let him die.

So if you could tell use what 'players' know about each other I can better think of how I would plan it. Your plans look good though.
Well the good (or bad) thing is that you will never know what exactly is the next step, cause you don't know which card are in the hand of your opponent. The only thing you can see is the card he plays... and maybe even find a pattern in that... but it's hard I would think
Image
User avatar
blueskies
Calc Wizard
Posts: 553
Joined: Tue 25 Apr, 2006 2:24 pm

Post by blueskies »

does the computer know what cards the player has in his hand? In your first post it sounds like the AI will check if the player can win with what he has in his hand. But, you say the player can't see the computer's hand. Is there some gameplay element that I'm just missing, or does the AI have a huge advantage?

I like the idea of different styles of opponents, ie the snake or tank enemies. I think a good way to design them is to have one baseline characteristic that varies between each opponent, and one special move or style for each character. So for example, attack vs. defend is the baseline. Let's say your snake character uses lots of attacks, little defense, and poison / drain is his special type of move. Then you can have Tank, who has a slow attack pattern, but builds up a lot of defense (like you said). His special move could then be his big nuke drop or something that destroys the player and all his defense he's built up. This also requires you to build certain strategies based on who you're playing against.

I think our ideas are similar, but I think it's important to have the one sliding scale characteristic for each enemy, instead of a sort of random assortment of attributes. Then again, I am just throwing ideas around...:)
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Hehe, nice... as you may read I am also only throwing idea's so that's ok

no, the AI does not know what kind of card the player has. it can only guess whether it is possible he will be destroyed or not. For example, the highest damage card atm is 15. So if his HP is below 15, he will know that there is a possibility that he can lose
Image
Mike K
New Member
Posts: 59
Joined: Sun 16 Jan, 2005 3:25 am
Location: St. Louis
Contact:

Post by Mike K »

It could do some card counting type things, meaning, determine the likelihood the players has a DMG15 card if he has already played 4-5 of these.

-Mike
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Mike K wrote:It could do some card counting type things, meaning, determine the likelihood the players has a DMG15 card if he has already played 4-5 of these.

-Mike
nah... that wouldn't be to realistic, since a player can make his own deck.
Image
Mike K
New Member
Posts: 59
Joined: Sun 16 Jan, 2005 3:25 am
Location: St. Louis
Contact:

Post by Mike K »

Oh, gotcha. You wouldn't know how many max cards the other player COULD be holding.

-Mike
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Mike K wrote:Oh, gotcha. You wouldn't know how many max cards the other player COULD be holding.

-Mike
exactly :) it nice though that you are trying to help... keep it coming!
Image
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post by DarkAuron »

Shouldn't there be a limit of how many cards you have of certain ones? Some cards might be really useful but you'd only be allowed to have one, otherwise you could overpower your deck..
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
tokijnct
Regular Member
Posts: 105
Joined: Sat 18 Dec, 2004 3:01 pm

Post by tokijnct »

Perhaps the limit should be set for each card level? (Unless it's too much of a hassle) For example: DMG 3 has a limit of four and DMG+15 has a limit of 2.
Duck
Sir Posts-A-Lot
Posts: 231
Joined: Sat 18 Dec, 2004 3:38 am

Post by Duck »

I once wrote an AI for dutch card-game "toepen". I used my own experience of the game into the AI such as the sequence of playing cards and what to do in end-game situations. So it may be helpfull to play the game to other persons a few times to get the hang of it, learn some tricks, get the basic idea of what a good player should do, and then translate this behaviour into programmable conditionals or the like. It will feel humanlike and can be much faster then any A* depth-first or whatever treesearch.
Jack

Post by Jack »

You could add cards that let's you draw or discard or retrieve cards from discard pile, etc

Just my two cent
Locked