Skip to content
forked from chirs/arena

A framework for staging 2-player, adversarial games over a network

Notifications You must be signed in to change notification settings

stmcgovern/arena

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arena

A game server for staging turn-based, 1-vs-1 match between AI players.

Uses a server/client framework using TCP sockets so players can be written in your language of choice.

Quick example

In one terminal, launch the server, host and port:

$ python3 supervise.py some.host.here 12345

In another terminal, connect player 1:

$ python3 clients/python/checkers.py some.host.here 12345

In another terminal, connect player 2:

$ python3 clients/python/checkers.py some.host.here 12345

API

This section covers the API calls a client needs to handle. A game basically consist of three steps:

(i) The AI client connects to the game server (host ??? and port ???)

(ii) The AI client sends a string encapsulating a JSON object (henceforth the "request"). This request must have the field "game" (see Supported Games section). E.g.: "{game:checkers}"

(iii) The server sends a string encapsulating a JSON object (henceforth the "acknowledgment"). This acknowledgment has the following fields:

Field nameDetails
namecheckers or tictactoe or etc
player1 or 2
timelimit5 seconds

An example acknowledgement would be "{name:tictactoe, player:2, timelimit:5}".

(iv) The server sends a string encapsulating a JSON object (henceforth the "game state"). This game state has the following fields:

Field nameDetails
player1 or 2
boardboard representation (see [supported games section](#games)
winner-1 is tie, 0 is game ongoing, 1 is player 1 wins, 2 is player 2 wins
historyA list holding the sequence of moves done in the game
logA log of miscellaneous relevant info about the game

An example of game state would be "{player:2, board:"xoxoxo ", winner:0, history:[0,1,2,3,4,5], log:""}.

(v) The AI player sends the server a move (see supported games section for the representation of moves for the different games)

Steps (iv) and (v) are repeated until the game is over.

Supported Games

NameBoard representationMove representation
checkers (i.e. English draughts) A 64 char-long string. Char position runs from left to right, top to bottom (e.g. position 10 represents the third square from the left in the second row from the top). Spaces (' ') represent empty squares, 'b' represents a player 1 pawn, 'B' represents a player 1 king. 'r' and 'R' are the same for player 2. A string encapsulating a 2 elements-long array with the beginning index and the end index (e.g. "[0,9]").
tictactoe A 9 char-long string. Char position runs from left to right, top to bottom (e.g. position 4 represents the second square from the left in the second row from the top (the middle square)). Spaces (' ') represent empty squares, 'x' represents player 1, 'o' represents player 2. A string encapsulating an int with the index of the square the player wants to put its next mark in (e.g. "2").
connect four A 42 char-long string. Char position runs from left to right, top to bottom (e.g. position 0 represents the upper-left square, 18 represents the middle square in the third row (from the top). Spaces (' ') represent empty squares, 'x' represents player 1, 'o' represents player 2. A string between 0 and 6 inclusive, encapsulating an integer with the index of the column where the player wants to drop her next piece.

chess is in the pipeline, let us know if you would like to see it implemented.

Test Suite

To run the test suite:

(i) Start the game server on a host and port in one terminal:

$ python3 supervise.py localhost 12345

(ii) In another terminal, run the test on the same host and port:

$ python3 test/test.py localhost 12345

Wish List

  • Better handling of client crash
  • Handle multiple checkers jumps in one turn
  • Write clients in different languages
  • Improve the test suite
  • Documentation

About

A framework for staging 2-player, adversarial games over a network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published