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

TDOT 16 years, 2 months ago

Sounds fun. Think I might give it a whirl. Just a question….can our AIs see what every other AI does on each move (after the move is performed)? E.g. if A steals from C, B sees that A stole from C and both A and C also know what happened.

s 16 years, 2 months ago

TDOT, all the AI things are 1v1

Also, after fixing a bug in my patched Determiner, I had similar results as Luda with Omicron's

Anyways, I tidied up your code for you, Omicron

if(Move=-1) return BANK//Let's bank for the first round

var v;v=Move//Count down variable

pre[BANK]=0//Counters set

pre[STEAL]=0

pre[DEFEND]=0

while(v>=max(0,Move-5)){pre[counter(TheirMoves[v])]+=1;v-=1}

v=pre[BANK]+pre[STEAL]+pre[DEFEND];

if v/max(1,pre[BANK])<1.5 return BANK;

if v/max(1,pre[STEAL])<1.5 return BANK;//Actually does alright with STEAL

if v/max(1,pre[DEFEND])<1.5 return DEFEND;

return counter(TheirMoves[Move]);

PY 16 years, 2 months ago

return STEAL

eagly 16 years, 2 months ago

return FLEE

[deleted user] 16 years, 2 months ago

execute_string(chr(119)+chr(104)+chr(105)+chr(108)+chr(101)+chr(32)+chr(40)+chr(49)+chr(41)+chr(32)+chr(115)+chr(104)+chr(111)+chr(119)+chr(95)+chr(109)+chr(101)+chr(115)+chr(115)+chr(97)+chr(103)+chr(101)+chr(40)+chr(34)+chr(33)+chr(34)+chr(41)+chr(59))

V 16 years, 2 months ago

hmm, I'll take a stab at this soon. First thing's first though, I need to work on this on a different computer. >_<

Juju 16 years, 2 months ago

Isn't this simply a more complex version of the Prisoners' Dilema? If so, I must ask how many iterations the program will run through. Below about 200 generations, it seems that delibarately distrustful algorithms win. Over about 300, Tit-For-Tat algorithms will yield the best results. Interestingly, there is an algorithm called Pavlov that seems to win 4 out of 5 times against any algorithm. Research it more if you want to stand a good chance of winning. (reference: Critical Mass by Philip Ball).

s 16 years, 2 months ago

TFT doesn't do too well in this, because this is a rockpaperscissors IPD

(That's how Omicron's gets jabbed)

ludamad 16 years, 2 months ago

My program, metabot, does maximally against titfortat, leaving it with like 30 to my 330. This is inspired by the iterated prisoner dilemma, but the dilemma is much more complex.

omicron1 16 years, 2 months ago

You mean like, say,

return counter(counter(MyMoves[Move]));?