Building an AI (part 1)

Hi again,

After being in hiatus for quite some time I’ve gotten back to programming a bit. I guess there is an ebb and flow with everything.

Back in November I was looking into how I could be Building an AI with ASyncTask, but I never got to feed the thing some rules with regards to how to play the game. This I aim to remedy now. Since this could get pretty lengthy I’m planning a short series as I go though the process of building an AI for the dice game “10.000”.


Choosing a method for problem solving

Building an AI can be done in different ways. I haven’t explored the topic that much, but I could see going about problem solving in different ways; neural networks or some other kinds of fuzzy logic, search algorithms or a basic heuristic. I do however have some programming experience with heuristics and I believe that, since we’re talking about a limited problem space like this a heuristic can do the job just fine.

One of the issues at hand is whether or not we want to get the optimal solution i.e. winning as fast as possible. I can see an argument for building an AI that can do this, but I don’t think it would be very fun to play against. The probability built into the game somewhat remedies this, but the AI should strike a balance between being challenging to play against and still being beatable. Another plus for using a heuristic is that they can be made to give us an answer in short time consistently, thus giving the user a better experience.


A basic set of rules

When implementing the heuristic I need to come up with some rules that it will consist of. In principle I want the AI mimics the process of a human player asking himself a set of questions at every decision point during his turn and answering them based on a predefined logic (as humans we have the advantage of being able to adjust our evaluation during a game, whereas my AI will have a fixed set of rules).

Questions you could be asking yourself?

  • What is the probability of being able to make points with X dices?
  • What is the reward for rolling the dices?
  • What is the risk for rolling the dices?
  • Is it the last round and do I have the most points?

Joining these together my heuristic becomes:

Rule A) If my chance of success times the reward for rolling the dices is bigger than the chance of failure times the risk, then roll the dice. Otherwise bank the points (if able)

Rule B) If it is the last round and I haven’t got the most points, then keep rolling.


What remains to be done?

For now I’ve established a basic set of rules. To determine whether or not the AI should keep rolling I need to feed some numbers into rule A. These numbers I’ll try and calculate in my next post using statistical analysis.


That’s it for now 🙂


EDIT: To read part 2 go here.

Statistics as per 31th of October

It’s been a while since I posted anything about my progress in Magic. That is not indicative of my play time. I’ve done both release and pre-release events and quite a few drafts online. I’ve had both ups and downs and at the moment I’m on an up. The numbers won’t show it though 🙂

I haven’t been able to win a single event since July, but that’s ok, since I’m learning a ton. I’m doing the slow bleed and I’m ok with that. I’m having fun despite that.

The numbers breaks down like this for the rounds played/won:

Month Played Won Win percentage
July 23 14 60,9%
August 24 12 50,0%
September 25 14 56,0%
October 43 24 55,8%

… and for matches played/won:

Month Played Won Win percentage
July 52 30 57,7%
August 62 32 51,6%
September 56 29 51,8%
October 106 54 50,9%

I’ve made a small graph of this.

As you can see my round win percentage tanked in August and I have been trying to improve that since then. My match win percentage has been pretty stable, but I’ve noticed that getting far more 0-2’s and 2-1’s than 2-0’s and 1-2’s, which is supported by the fact that the match win percentage is lower than the round win percentage.

So where have I gone from here
First off, I’ve started playing Swiss drafts. This may have some effect on the numbers, but I can’t tell you how much.
I’ve started recording the events I play in, both the actual matches and results on an overall basis. I review these and try to figure out where I can get better. I feel like this has already helped me quite a bit, but it’s sometimes tedious work. Oh well, it’s all good 🙂

So November may be shaping up to be a good month for me… who knows?

Statistics for August – M15

Once again I tallied up the score for events played. This time it’s the August numbers, and that was not one of my better performances.


Win percentages

The numbers from August where:

Type Played Won Win percentage
Events 7 0 0,0%
Rounds 21 10 47,6%
Matches 54 28 51,9%

No events won, which is ok. I never participate in an event, and expect to win it. If I win it is just a nice surprise, since it drastically improves my Expected Value of the event. But losing more than half my rounds really gave food for thought. This ties into the statistics on the color distribution, but more on that later.


Color distribution

I also did some statistics on the deck color distribution and their individual win rates:

 Guild (Color) Wins Losses Rounds Win percentage
Blue 2 1 3 66,67%
Selesnya (WG) 4 6 10 40,00%
Golgari (BG) 4 4 8 50,00%

First off, the sample size on each color is relatively small, which makes any conclusions based on this quite uncertain. The numbers for blue (which is from alive draft) and BG are quite ok, but the WG combination just fell through for me. When I read Matt Costas article on how Team Pantheon dissected the M15 draft format, it gave me a wealth of information I wanted to try out, but I think I may have screwed up somewhere along the way. I think, and this is where I second guess myself, that I may have been forcing the Selesnya decks too much. This may be based off an assumption that they’d come through more often than not. I could have been building them wrong or just misevaluated their power level in general, but the fact of the matter is that I lost far more with those, than with any of the others. Of course I didn’t play much else 😉

Another thing I noticed is that my mood is directly linked to my win percentage in an event. This is something that I really need to work on, since no game should be worth getting pissed over.



– Don’t force too much. Look at all options a second time

– It’s not important to win, but to improve.


Until next time, take care 🙂

Statistics for July – Theros Block action

It’s been a while since my last post. A little too long not to have something new to write about 😀


At the beginning of July I started taking notes on how my performance was on MTGO. At the time I was playing only Phantom Sealed Theros Block events. I was doing ok, since my goal was to win more rounds and matches than I lost.


Win percentages

The numbers from July where:

Type Played Won Win percentage
Events 9 1 11,1%
Rounds 26 15 57,7%
Matches 60 34 56,7%

That at least shows me that I accomplished my aforementioned goal 🙂


Color distribution

I also did some statistics on the deck color distribution and their individual win rates:

 Guild (Color) Wins Losses Rounds Win percentage
Azorius (WU) 2 1 3 66,67%
Selesnya (WG) 1 1 2 50,00%
Izzet (UR) 3 3 6 50,00%
Simic (UG) 6 3 9 66,67%
Golgari (BG) 3 3 6 50,00%

The sample size may be too small to be able say anything conclusive about, but it does shed some light on how I’m performing. M15 has already been released and I’ll continue keeping track of the events I play.


Until next time, may your mana curve be smooth and efficient 😉

PTQ Post mortem

Hi again,


This is a follow up on my previous post. The PTQ in Aarhus is over and I feel it’s time to look back on how things shaped out for me.


With unlimited time and the intellect of a genius I guess anythings possible. Unfortunately I had neither, although I think less could have put me at the top.  In the end the result was not a ticket to the Pro Tour, since I went 4-4 on the day of the PTQ. The final result put me at a 49th place out of a 150 participants.


The pool

The pool contained the cards below. To begin with I built a midrange RB deck, but after losing my first three matches, I asked a friend and went into aggro. That helped 🙂

The final deck contained the following



1 Felhide Brawler

1 Pain Seer

1 Blood-Toll Harpy

1 Odunos River Trawler

1 Nyxborn Eidolon

1 Felhide Minotaur

1 Insatiable Harpy

1 Gray Merchant of Asphodel

1 Marshmist Titan

1 Cyclops of One-Eyed Pass

1 Everflame Eidolon

1 Nyxborn Rollicker

1 Minotaur Skullcleaver

1 Thunder Brute

1 Firedrinker Satyr


1 Pharika’s Cure

1 Read the Bones

1 Lash of the Whip

1 Sip of Hemlock

1 Bolt of Keranos

1 Fearsome Temper

1 Rage of Purphoros

1 Magma Jet


1 Unknown Shores

9 Swamps

7 Mountains


1 Servant of Tymaret

1 Cavern Lampad

1 Warchanter of Mogis

1 Marshmist Titan

1 Spearpoint Oread

1 Read the Bones

2 Rise to the Challenge

1 Portent of Betrayal

1 Siren of the Fanged Coast

1 Nimbus Naiad

1 Chorus of the Tides

1 Divination

1 Vortex Elemental

2 Retraction Helix

1 Artisan of Forms

1 Crypsis

1 Stratus Walk

1 Crackling Triton

1 Priest of Iroas

2 Loyal Pegasus

1 Nyxborn Shieldmate

1 Observant Alseid

1 Wingsteed Rider

1 Ray of Dissolution

1 Decorated Griffin

1 Fated Retribution

1 Hold at Bay

2 Last Breath

1 Great Hart

1 Vanquish the Foul

1 Ephara’s Radience

1 Forsaken Drifters

1 Weight of the Underworld

1 Drown in Sorrow

1 Medomai the Ageless

1 Ephara’s Enlightenment

1 Sealock Monster

1 Dissolve

1 Triton Shorethief

1 Gainsay

1 Lost in a Labyrinth

1 Evanescent Intellect

1 Thassa’s Rebuff

1 Nylea’s Disciple

1 Sedge Scorpion

1 Nessian Wilds Ravager

1 Pheres-Band Tromper

1 Swordwise Centaur

1 Satyr Hedonist

1 Fade into Antiquity

1 Time to Feed

1 Raised by Wolves

1 Satyr Piper

1 Hunt the Hunter

1 Defend the Hearth

1 Satyr Wayfinder

1 Guardian of Meletis



When looking back I think I made a mistake when I constructed my deck. The cards to take it towards aggro where there, but I missed it and went into some midrange solution. The deck tried to do two different things, which I’m not interested in in general. I believe that the more uniform a decks plan is, the better it will perform.