It is currently 29 Apr 2024, 04:28
   
Text Size

AI Breakthrough

Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!

Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins

AI Breakthrough

Postby jatill » 04 Feb 2011, 16:23

I was durdling around trying to remember how to make Murmuring Bosk act like a Forest, and I stumbled across an unfamiliar piece of code. After a little digging, I found that there is actually a variable hanging out in the code that let's you sway the AI's opinion about whether or not to play a card. I'm not sure how many applications this will actually have, but the one I'm most excited about is non-basic lands. I think I have convinced the AI to actually play the Tri-lands instead of just skipping their turn. Exciting, right? Assuming this variable actually does what I think it does, what other cards could benefit from having additional code telling the AI when to play or not play that card?
jatill
DEVELOPER
 
Posts: 2118
Joined: 24 Feb 2009, 16:35
Has thanked: 5 times
Been thanked: 17 times

Re: AI Breakthrough

Postby shinra » 04 Feb 2011, 16:47

Sounds good Jatill!

Do you think this piece of code define priority too or not?

If this work, it open a lot of thing in order to making IA better but hours and hours of coding....

Nice job

:)
User avatar
shinra
 
Posts: 25
Joined: 20 Dec 2010, 23:30
Location: France
Has thanked: 20 times
Been thanked: 2 times

Re: AI Breakthrough

Postby Aswan jaguar » 04 Feb 2011, 17:30

Great news,from little testing and playing with this tri-lands I thought and was almost convinced that AI somehow sees them like a card which needs 3turns to pass and then is allowed to play them unless they are the only lands in opening hand and plays them right away but only the first of the tri-lands smt like that.Enough bumbling,can't wait to hear more good news from you. :D
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Re: AI Breakthrough

Postby juzamjedi » 04 Feb 2011, 18:17

Countermagic - the AI is terrible with it. The AI mostly just counters creature spells and the "truly broken" cards like Demonic Tutor.

Also burn spells - too often the AI does not use X burn spells to kill me when it could.

Some spells like Worship never get cast by AI. The AI did not always play Ajani Vengeant either. There are others that "don't get played" but I will have to remember them and post later.
juzamjedi
Tester
 
Posts: 575
Joined: 13 Nov 2008, 08:35
Has thanked: 6 times
Been thanked: 8 times

Re: AI Breakthrough

Postby jatill » 04 Feb 2011, 21:05

I'm sad. I was hoping I could use this to force the AI to equip Jitte and use the Rules Engine, but still no luck there.
jatill
DEVELOPER
 
Posts: 2118
Joined: 24 Feb 2009, 16:35
Has thanked: 5 times
Been thanked: 17 times

Re: AI Breakthrough

Postby aww1979 » 04 Feb 2011, 21:19

-AI should be using fetchlands as soon as it plays them, not waiting until its discard phase (or combat phase, if it attacks)
-AI should use a planeswalker ability every turn
-AI should play a land drop every turn if able (yeah, I know there's reasons not to, like enemy armageddon and stuff, but I doubt the AI will be able to figure that out, so it's safest to just have it always play one)
-AI should not play stuff like Duress against an empty hand (which is just about the only time it WILL play that card)
-certain cards like Moat or The Abyss, the AI is scared shitless to cast. I've never seen it cast The Abyss, and saw it cast a Moat ONCE, and that was on the turn after it cast Inkwell Leviathan in challenge mode.
aww1979
Tester
 
Posts: 1717
Joined: 03 Mar 2009, 19:36
Has thanked: 0 time
Been thanked: 2 times

Re: AI Breakthrough

Postby Salbei » 08 Feb 2011, 01:25

I found that there is actually a variable hanging out in the code that let's you sway the AI's opinion about whether or not to play a card.
Got me curious. What does the variable look like ?
Simple On/Off like

0= AI doesn´t play the card ever!
1= AI plays the card "normal"

Or is there more to it like:

2= AI plays/activates the card If condition XY is met (that would be truly awesome).
3= AI plays/activates the card If condition XZ is met
...
etc.

Would it also be possible to add multiple conditions then ?
Would be great if the AI would use certain cards depending on their own hp or the players hp.When the Players HP is >15 then it shouldn´t use burn spells to the players face for example.Guess you can´t "teach" the AI how to play complex combo deck interactions with it, but it is a start.

On top of my head and depending on the possibilities these come in mind:

"I play Dark Ritual during my Combat Step and don´t use the mana for anything".(should only cast it when it is required to cast something else)
"I waste Might of Oaks to save my 1/1 token".(should just save the card to finish the game)
"I randomly Lightning Bolt Birds of Paradise instead of a 3/3 right next to it" (priority is messed up)
"I randomly Giant Growth YOUR Creature"(just wrong in every aspect)
"I play 2 Masticore with 1 or less cards in my hand"
"I just love to Lightning Bolt you when your live is >15 and i am nowhere near discarding"

Guess it is impossible to force the AI to attack at certain conditions so i won´t bother writing about that.

Btw does the "priority" of cards does anything beside Sealed Deck / Draft ? Especially Sealed Deck is quite boring since the AI play mono green like 95% of the time.Been like that for roughly a year, but was working before. Can´t quite pinpoint the patch that "broke" it.
I can´t understand how targets for Countermagic or removal spells get defined otherwise.
Or other "priority" things like having 2 cards with the same casting cost in the AIs hand and deciding what to play.

I would honestly prefer "stronger" AI plays over Sealed Deck / Draft behaviour. Seems like Manafixers are the greatest thing in the world to the AI ... so it even wastes removal to get rid of players Manafixers over more dangerous threats.Elixir of Immortality is getting played over a 1-drop Creature , playing and activating Elixir of Immortality seems to have a higher priority than playing a CC3 Creature aswell.It is things like this that really hurt the game at the moment.
Retired a long time ago. I will not reply.
User avatar
Salbei
DEVELOPER
 
Posts: 1053
Joined: 04 Jun 2009, 10:58
Location: Germany
Has thanked: 3 times
Been thanked: 2 times

Re: AI Breakthrough

Postby EviL_CLonE » 08 Feb 2011, 03:41

@Jatill: Is there any possibility to force AI to play abilities during Upkeeps or End steps?
Would be great if AI could use an Icy Manipulator or a Rishadan Port during my upkeep.
EviL_CLonE
 
Posts: 143
Joined: 24 Feb 2009, 16:54
Location: Buenos Aires, Argentina
Has thanked: 1 time
Been thanked: 0 time

Re: AI Breakthrough

Postby jatill » 08 Feb 2011, 13:04

This variable is a number that modifies how attractive a certain line of play is. So the example I used in testing, I had 2 giant green creatures in play, and the AI had Perish and Pit Scorpion in hand. I have to give the Perish about -500 points before the AI would prefer the Pit Scorpion.

I haven't learned how to modify how to get abilities activated, but perhaps there's another variable for that.
jatill
DEVELOPER
 
Posts: 2118
Joined: 24 Feb 2009, 16:35
Has thanked: 5 times
Been thanked: 17 times

Re: AI Breakthrough

Postby Salbei » 08 Feb 2011, 20:05

Ah now i get it. So THIS is kinda like a "priority" number, right ? Didn´t get that out of the initial post.

So when you got 1 Mana available and 2 cards you could possibly play this "new" thing is responsible for the choice, right ?

How do you plan to use this knowledge ? Lets say you got 4 Forests and could either play 1 Ernham Djinn or 2 Elvish Archers (just an example).

We need a general system to use this (and most likly have to apply this to already existing cards).I know this will require a lot of work, but should significantly increase the AI performance.

Couple ideas:

"Quality system" (not recommended)
-A fixed value of "points" per casting cost in general.
Higher cost -> higher score.
(like 10 points per casting cost)
Usually more expensive spells tend to be better - due to the nature of the mana system.This way the AI would always try to cast the highest casting cost spell available, right ?

"Quantity system"
-A fixed value of "points" per casting cost in general.Lower cost -> higher score.
(like 10 points for a 15 mana spell, 20 points for a 14 mana spell etc. check spoiler)
This way the should try to play the cheap spells first and the high cost spells last.
cost | Open
14 = 20
13 = 40
12 = 60
11 = 80
10 = 100
9 = 120
8 = 140
7 = 160
6 = 180
5 = 200
4 = 220
3 = 240
2 = 260
1 = 280
0 = 300

My guts tell me that the Quantity system offers less problems (Lands or 0 Mana things ...)

"Type based"
Fetchlands 2000 (we want this to be played first)
Nonbasic Lands 1900 (we want this to played before spells)
Basic Lands 1800 (we want this to be played before spells)
Creatures 1200 (we want this to be played after lands)
Artifact 1000 (we want this to be played after Creatures)
Enchantment 800 (we want this to be played after Artifacts)
Sorcery 600 (we want this to be played after ANY permanents)
Instant 400 (we want those to be played after the permanents and after sorceries.)
Interrupt 200 (we want those to be played after anything else.)

"sub-quality filter"
Junk cards get 0-2
mediocore cards ger 3-6
good cards get 7-9
This should be relevant when the AI got 2 or more cards with roughly the same "points" to play and help to decide what to play.

Examples:
examples | Open
Ernham Djinn (1424)
Creature (+1200)
CC 4 (+220)
Quality 4

Elvish Archers (1465)
Creature (+1200)
CC 2 (+260)
Quality 5

Giant Growth (686)
Instant (+400)
CC 1 (280)
Quality (6)

Forest (1800)
Basic Land (+1800)

Taiga (1900)
Non-basic land (1900)

Bloodstained Mire
Fetchland (2000)

Arc Lightning (847)
Sorcery (600)
CC 3 (240)
Quality 7

Primeval Titan (1388)
Creature (1200)
CC 6 (180)
Quality 8

Fireball (907)
Sorcery (600)
CC 0 (300)
Quality 7

Kird Ape (1508)
Creature (1200)
CC 1 (300)
Quality 8

Harrow (646)
Instant (400)
CC 3 (240)
Quality 6

Counterspell (468)
Interrupt (i know it is an instant, but the game treats it like that). (200)
CC 2 (260)
Quality 8

Dismiss (427)
Interrupt (200)
CC 4 (220)
Quality 7
Dark Ritual (507)
Interrupt (bla) (200)
CC 1 (300)
Quality 7

Seething Song (446)
Interrupt (bla) (200)
CC 3 (240)
Quality 6


So with the Current example the AI should play the cards in this order:

Bloodstained Mire 2000
Taiga 1900
Forest 1800
Kird Ape 1508
Elvish Archers 1465
Ernham Djinn 1424
Primeval Titan 1388
Fireball 907 (<- X-spell example)
Arc Lightning 847
Giant Growth 686 ( <- mistake , should be a lot lower! )
Harrow 646
Dark Ritual 507 (<- not sure how to handle mana sources)
Counterspell 468 (<- AI uses cheapest countermagic first)
Seething Song 446
Dismiss 427

The general idea is to play spells in this order:
Lands
Creatures
other permanents
Sorceries
Instants
Interrupts

So those 3 "filters" should define the "priority".Just an idea.The coders would really have to stick to one system.
This is just a general idea how it may be done.
The method above has still got some flaws as you can see in the example.There should be another "filter" to avoid duplicate "points" when cards got the same castingcost , but i didn´t want to make this too complex.

Would mostly be "grunt work", could split up the work pretty easy.A few people that do the math for each card (split) so there is just "copy/paste" to be done for a coder.

Do you see any major flaws ? Is there an easier way to do this ?
Retired a long time ago. I will not reply.
User avatar
Salbei
DEVELOPER
 
Posts: 1053
Joined: 04 Jun 2009, 10:58
Location: Germany
Has thanked: 3 times
Been thanked: 2 times

Re: AI Breakthrough

Postby gmzombie » 08 Feb 2011, 23:16

love this idea and i hope that it will be able to be used...although i dont mind the random giant growth on my creature lol..
can I maze of ith your snowstorm?

http://home.comcast.net/~gmzombie/index.html old stuff in here. don't use this stuff right now till I get time to get back into it and readjust.
gmzombie
 
Posts: 857
Joined: 26 Feb 2009, 01:05
Location: Wyoming, Mi
Has thanked: 200 times
Been thanked: 51 times

Re: AI Breakthrough

Postby Salbei » 12 Feb 2011, 03:57

So how do you plan to use this "new" knowledge ?

Btw:
Here is an interesting discussion about "card threat level". A few points in there are very relevant for this topic.

viewtopic.php?f=27&t=2586

Is there currently a way to influence the AIs decisions beside this "new" variable ? Could anyone pinpoint AI related parts at the code ? Is it possible to tweak the "general" AI behavior ?

So many open questions ... sorry. I really need a new mod project :)

Offtopic:
http://www.wizards.com/Magic/Magazine/A ... feature/44
A very nice article about the AI of Wizards DOTP.
Complex things like the AI of a program aren´t always as "easy" as they might look.
Retired a long time ago. I will not reply.
User avatar
Salbei
DEVELOPER
 
Posts: 1053
Joined: 04 Jun 2009, 10:58
Location: Germany
Has thanked: 3 times
Been thanked: 2 times


Return to Development

Who is online

Users browsing this forum: No registered users and 33 guests


Who is online

In total there are 33 users online :: 0 registered, 0 hidden and 33 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 33 guests

Login Form