Programmer Resources Home Page

From StrategoUSA

Jump to: navigation, search

Contents

[edit] Stratego AI API

Human players on Metaforge download and run a client application that communicates with the Metaforge server to implement game moves between opponents across the Internet. The Stratego AI API enables Stratego programs to use the client to play games on Metaforge, essentially substituting the AI program's moves for that of a human. The API supports implementations in Java and native code; an adapter is also available to support implementations in web service technology.

[edit] Required Methods

The complete API supports features beyond the scope of the tournaments. For the purposes of the tournaments, a program need only be able to play classic Stratego with range attacks enabled, from either side of the board.

Following are the methods a program must implement for tournament play:

setGameOption()
set the passed game option

createAISetup()
create or select a setup for the AI

getAISetupPiece()
return the AI setup, piece-by-piece

illegalSetup()
the AI setup is illegal

setOpponentSetupPiece()
mark squares that have an opponent piece

getAIMove()
generate a move and pass it back

submitAIMoveResult()
learn the result of the AI move (for attacks)

submitOpponentMove()
learn the opponent move

[edit] Usage Tips

Here are some programming tips to help you get started.

[edit] Creating Games

To enable a bot to create games, override the createGame method like this:

public void createGame() {

   return true;

}

[edit] Enabling Range Attacks

The tournaments require the Range Attacks option to be on. To implement this, override the getCreateGameOption method like this:

public int getCreateGameOption(int option) {

   return (option == MetaforgeStrategoAI.GAMEOPT_RANGE_ATTACK) ? OPTION_ON : OPTION_OFF;

}

[edit] Joining Games

To enable a bot to join tournament games, several methods must be overridden from MetaforgeBaseAI:

public boolean newGameOption(int option, int value) {

   return ((option == MetaforgeStrategoAI.GAMEOPT_RANGE_ATTACK) && (value == MetaforgeStrategoAI.OPTION_ON)) ||
          ((option != MetaforgeStrategoAI.GAMEOPT_RANGE_ATTACK) && (value == MetaforgeStrategoAI.OPTION_OFF))

}

public boolean newGameCreated(String owner, int mode) {

   return (mode == MetaforgeStrategoAI.GAMEMODE_CLASSIC);

}

public boolean joinGame() {

   return true;

}

[edit] Download SDK

You can download the Stratego AI API development kit here:

Version 2.0.36: http://www.metaforge.net/olg/webstratego/ai/MetaforgeBotSDK.zip

[edit] Web Service API

Stratego AI programs can be written in any programming language that supports web service technology (e.g., C# and Visual Basic). The AI program must be implemented as a web service that exposes the PlayerService interface. At runtime, the web service is called by the Metaforge client via an adapter.

[edit] SDK Contents

The following content is in the web service adapter SDK:

  • Metaforge Client Application with web service adapter
  • PlayerService interface definition file (WSDL)
  • README file with documentation for installation and configuration

[edit] C# API

Use the web service API for implemention of a Stratego AI program in C#. The web service should be implemented in ASP.Net according to the IPlayerService interface. Support for WCF is currently not provided.

[edit] Download Web Service API

You can download the adapter SDK here:

http://jayoogee.dyndns.org/downloads/MetaforgeClientWSAdapterSDK.zip

[edit] Sample Java Program

A Java implementation that generates random moves ("Random Bot") is available for download:

http://jayoogee.dyndns.org/downloads/RandomBot.zip

[edit] Games Archive

There exists an online archive of over 100,000 Classic Stratego games between human opponents. The archive can be useful to perform statistical evaluations of setups and game moves. The archive can be downloaded here:

www.gravon.de/strados2/files/.

Files are in the StraDoS 2 (Stratego DOcumentation System version 2) format.

Following is an example setup entry:

content="EBFBDBMBEEEDBHDHBIGEGDJCDFHDDDHFIKGILJGFAA__AA__AAAA__AA__AARTUPSTPUTRPSWQPSXPSPNQPOVQPVQNNRNQYTNNUR"

Each character represents a position on the board:

Flag Bomb Marshal General Colonel Major Captain Lieutenant Sergeant Miner Scout Spy Empty Island
M B L K J I H G F E D C A _
Y N X W V U T S R Q P O



Personal tools