3

I want to arrange an AI contest between some friends. Lets say tic tac toe, each player program a method which get the board and a symbol(X\O) and return the place which he want to play at his turn. Now my problem its how to "connect" two AI's in another program so I can test all users and see who has the best code. The only way I think of is to communicate with a text file - all the AI's have thread running on background and check changes on the text file,the engine summary the game details(which turn,the board,score,players) to the text file.

How can this can be done better? And one more little thing, this is common to have a time frame for each turn in AI contests? (Because the AI program will run in different times on different computers)

T.Rob
  • 31,522
  • 9
  • 59
  • 103
xavi1675
  • 39
  • 1
  • 4
    This question isn't about "building AI engines". It is about connecting/coordinating independently developed applications. Please re-title this. – Ira Baxter Apr 18 '11 at 01:11
  • I'd also choose something harder than tic tac toe. Either create your own game or find a game that doesn't have very many solutions online to cut down on people copying solutions. – itchi May 13 '11 at 17:58

7 Answers7

1

It isn't clear from your question whether this has to be performed online or not.

If you're after finding "the best Tic Tac Toe algorithm", you could simply:

(This may slightly differ, depending on the programming language)

  1. Define an interface (e.g: ITicTacToeSolver)
  2. Have all your friends implement it in their own way and send you a DLL with their solution.
  3. Create the game which will dynamically load these DLLs, and test them (play 1,000,000 games with the algorithm that is loaded).
  4. Keep track of game statistics to see which algorithm is best.
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
0

If the AI programs are competing in a game like tic tac toe, typically every program would have limited total "thinking" time (e.g. 5 minutes), and a program that exceeds its time allotment would lose.

Typically often the programs are connected over some sort of a simple protocol, not through text files. The protocol can run on standard I/O or through TCP/IP sockets.

To normalize CPU usage, you can request that for tournament games, all the programs are compiled to work on a reference platform and then you provide two identical PCs, both running one of the active contestants. It then becomes a requirement of your tournament that the programs can be executed on this reference platform.

Antti Huima
  • 25,136
  • 3
  • 52
  • 71
0

Use an interface and a standard programming language - so you can forget about text files and bollocks like that.

William Mioch
  • 917
  • 9
  • 21
0

Figure out a simple SOAP protocol. You can simply create a WSDL interface - easy to create using windows communication foundatoin (WCF) or JMS.

Easiest would be to have a centralized server to serve as a referee and keep track of time. Each player could be assigned an ID.

Then you could have a the following interface (use WCF or JMS to create a WSDL SOAP protocol)

function  int requestGame(int opponentID, int color)
 - if called with color = -1, randomly assigns a color and returns it (0=white, 1=black).
 - otherwise you can request a color, and returns it if accepted, -1 if not accepted.
 - could use -1 to request random opponent.

function int getRemainingTime(int color)
- returns the time remaining on clock for color

function bool play(int color, int i, int j)

where color = 0  - white - 1 black,
i, j are board coordinates,
- returns true if it is a legal move

function bool won(int color)
- returns true if color has won the game.

Not having a centralized server would be more complex since they would have to negotiate over agreed wins, time, etc.

Larry Watanabe
  • 10,126
  • 9
  • 43
  • 46
0

I would suggest to have each of the AI be executable files, communicating by using standard input and output. The game engine (the referee) would send the complete state of the world to AI_one as input, then wait for a move from standard output. It would then perform the move (if legal) and repeat the process for AI_two, then alternate between the two until the game is over. As a failsafe the referee can make one side lose if it takes too long to make a move.

This method is used by Google AI challenge.

One very big advantage to this approach is that people can write their AI in different languages, as long as they follow the agreed standard for how to make a move.

Orka
  • 1,095
  • 1
  • 9
  • 16
0

If your goal is to have an AI programming competition amongst friends, I'd suggest that you don't waste time designing and implementing the framework for holding the competition. Use something that already exists for that purpose. You can skip all the pain and heartache of fixing bugs in your framework and get right to the fun part: developing AI.

A good framework is the Robocode game. Watching your robots kill each other will be a lot more fun than watching them play tic-tac-toe.

sho222
  • 722
  • 1
  • 6
  • 14
0

You should take a look at this question: What is the best Battleship AI?

In it he creates a battleship AI contest / challenge. It was very high rated and a lot of fun to code for and watch.

He used the Tournament API http://tournaments.codeplex.com/ to run the competition.

Also, it's important to allow the submissions to compete multiple times.. ie 1000 times each. This removes alot of the randomness and luck from the competitors.

Community
  • 1
  • 1
itchi
  • 1,683
  • 14
  • 30