Giter VIP home page Giter VIP logo

cfw's Introduction

Protocol

High level

Here's a high level view of a full turn cycle (white plays, then black plays).

The framework sends the current board to the white AI. The white AI send back a move and the board that is the result of making that move. The same procedure is repeated for black. The framework should validate each move and flag check, checkmate, and stalemate.

Currently the moves have no time constraints. This will be coming later.

Lower level

A board should be 64 piece symbols, each separated by a space and ending with a newline. Each symbol is two characters. The first character identifies the color of the piece and the second character identies the type of the piece. 00 represents an empty square.

The board starts at the top left and moves by rows to the bottom right.

So the starting board for a game is as follows:

BR BH BB BQ BK BB BH BR BP BP BP BP BP BP BP BP 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 WP WP WP WP WP WP WP WP WR WH WB WQ WK WB WH WR

When the board is sent to either agent, it is prefixed with the color the agent should be moving for. At the start of a game, the starting board is sent (on stdin) to the white AI prefixed with "white " (note the space). White then responds (on stdout) with a move. The response should be an integer representing the index of the piece to move, a space, and an integer representing the target of the move. This move will be validated by the framework. If the move is invalid, it is considered a loss. The AIs do not need to flag check, checkmate, or stalemate because the framework is aware of these conditions and handles the end of the game.

Running the framework

Run the framework with any of the following:

go run main.go -black /path/to/ai -white /path/to/ai

go build
./cfw -black /path/to/ai -white /path/to/ai

go install
# works if $GOPATH/bin is on your path
cfw -black /path/to/ai -white /path/to/ai 

Other Notes

I took a class using a chess framework that requires the use of .NET (or mono). This framework makes it extremely difficult to run a lot of tests against two different AIs and it was very tightly coupled with the user interface. I decided that I wanted to design a similar framework that effectively only defines a communication protocol and doesn't enforce the use of any specific programming environment when creating the AI. cfw should work on any platform that the Go compiler targets (at least OS X, Linux, and Windows). However, my ability to test on these various platforms is limited (particularly Windows). If something doesn't work on any particular platform, it should be reported as a bug.

A more long term goal is to allow an agent to compete over a network connection instead of (as is currently the case) requiring the agent to run locally.

Status

This project is very incomplete and currently does NOT satisfy most of the protocol specified above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.