AI Competition!

Posted by ludamad on Oct. 3, 2008, 8:16 p.m.

Hello boys and girls. If you know me, you would know that I am very interested in artificial intelligence, and game theory. So I decided to create a competition combining the two! Horribly complicated? Nope. Let me explain.

THE TASK: To create a GML script that plays the most effective strategy - against other entries - for the game described below.

THE GAME:

Every turn you have three options:

DEFEND: You gain 1 point this round and stop the opponent from stealing.

STEAL: You take 2 points from your opponent (added to your own score). This does not work if your opponent chose to defend.

BANK: You gain 2 points.

Every AI entry plays against other AI entries for 200 rounds. Your goal is to have the highest score at the end of all the playing. That is, you add the total score from all the rounds.

THE ENGINE:

http://64digits.com/users/ludamad/AI-Engine.gm6

To add a script to the players there, create a new script, and alter both the constant NUM_PLAYERS and the create event of object Arbiter.

Sample AI's are provided.

The script has the following rules:

-You may only access local variables, and constants.

-You may create any local variables you need. These are wiped after the 200 rounds against an AI are played.

-You may not use functions I deem dangerous. Use common sense and don't try to cheat.

To use the engine, load the game and press space. It will then show the scores for each script.

Additional Stuff:

-Up to two entries, I will make sure they are not explicitly cooperating however. You will win if either of your AI's is on top.

-The game is not rock paper scissors. Banking is inherently more useful.

-Try to make a script that beats the preset examples. However, remember your AI cannot fully expect what the other AIs will be like.

Any questions, just ask. I wrote this rather sketchingly.

Writing a good AI:

This is obviously your task to figure out, but the sample AI's can give some insight. Although stealing looks all nice and fancy, you gain AND remove, it can be seen that the Thief performs quite miserably. This is simply because stealing fails against both stealing and defending.

Here are some preset things you can use:

SCRIPTS TO HELP YOU:

X represents BANK, DEFEND, or STEAL

counter( x ) : Returns the best possible move against move x, good for fighting predictability.

simulate( x1, x2 ) : Returns the value (for the player who played x1) if x1 is played against x2. Good for analysis.

STORED VALUES TO HELP YOU:

Move - the index of the last move, starts at -1. Use Move==-1 to check if it is the first move.

MyMove [] - the array of moves you have played

TheirMove [] - the array of moves your opponent has played

Score - your current score (nothing about your opponent's) for this game

DEFEND - 2

STEAL - 1

BANK - 0

Comments

ludamad 16 years, 2 months ago

omicron: Against things like tit-for-tat metabot will play like that and continuously analyze if it is working. That's the strongest counter to tit-for-tat of course.

PY 16 years, 2 months ago

my ai lost 200-201 against metabot.

yeh!

gamerman 16 years, 2 months ago

This little thing is doing better then I thought it would.

if Move >= 0 {

var a, b;

b = TheirMoves[Move]

if b = BANK a = choose(BANK)

if b = STEAL a = choose(DEFEND)

if b = DEFEND a = choose(BANK)

}else{

return STEAL

}

in groups at least.

s 16 years, 2 months ago

There are plenty of choices outside Determiner style. Here's a system that changes based on differences of points

//SAMPLE AI SCRIPT BY SERPREX

if Move=-1{w[0]=200;w[1]=200;w[2]=200;return choose(0,1,2)}

w[MyMoves[Move]]+=simulate(MyMoves[Move],TheirMoves[Move])-simulate(TheirMoves[Move],MyMoves[Move])

if Move<20{return choose(0,1,2)}

var v;v=random(w[0]+w[1]+w[2])

if v<=w[0] return 0

if v<=w[0]+w[2] return 2

return 1

@gamerman=Lack of random makes it an easy shot. AttackBank makes it BankDefend. You end with 100 and the foe ends with 400

gamerman 16 years, 2 months ago

I was making a few that where personality based, it wasn't an entry.

s 16 years, 2 months ago

What you have setup is the cautious banker, works well with AIs that don't do pattern recognition

Anyways, here's Pavlov (Meta wins by 140%, and it doesn't seem to beat much. Thus standing against Juju's conjecture)

if Move=-1{m=choose(0,1,2);return m}

if TheirMoves[Move]=counter(MyMoves[Move]){m=choose(counter(MyMoves[Move]),counter(counter(MyMoves[Move])))}

return m

And I call this one Markov (Meta loses by 103% (Probably going to change))

if Move=-1{pre[0]=0;pre[1]=0;pre[2]=0;return 2}

pre[counter(TheirMoves[Move])]+=Move

var v;v=random(pre[0]+pre[1]+pre[2])

if v<=pre[0]{return 0}

if v<=pre[0]+pre[2]{return 2}

return 1

Castypher 16 years, 2 months ago

If I had time, I'd compete, but I don't really see the point.

Guys, the idea of AI is to have them learn your patterns and come up with a better solution. Unfortunately, as Ludamad may have figured out, you can't have very efficient AI with only three options.

ludamad 16 years, 2 months ago

Kilin: Are you not reading this properly? Its not like you're making an AI that plays one of the three moves, end of story. You're making an AI that will try to gain advantages over the opponent in a 200 round span, the game has 200 separate choices needed from your script, with 3^200 possible permutations. If the game was only played for one round, you might as well bank. Your opponent has no chance to respond. But if you're always banking for those 200 rounds, your opponent has plenty of time to catch on and punish you. Don't let the simple description fool you.

Castypher 16 years, 2 months ago

Yeah, I'm reading this right and I know what AI is. AI is built to learn patterns and find a more effective way to beat the opponents. I'm saying this is just a pretty simple form in a simple game. Three options, even through 200 rounds, still doesn't give much room for anything especially interesting to happen. That's all I'm saying.

ludamad 16 years, 2 months ago

Iterated prisoner dilemma competitions are still held, and that game is even simpler. Plenty of interesting things happen in the interaction of various AI scripts in this game.