~skiqqy/chess

edcde9e9960c09e04dc2a95740aebe62f259acb6 — Stephen Cochrane 4 months ago 3233555
Updated README
1 files changed, 6 insertions(+), 65 deletions(-)

M README.md
M README.md => README.md +6 -65
@@ 32,72 32,13 @@ $ make test

## Purpose

This engine is something I plan on using in my next project, an abstract bot
that given an engine to a game played with two players on a 2 dimensional board
(using a predetermined interface) that will use
[MPI](http://condor.cc.ku.edu/~grobe/docs/intro-MPI-C.shtml) and some sort of
tree search/ optimization algorithm (most likely
[negamax](ihttps://en.wikipedia.org/wiki/Negamax)).
This is a simple implementation of chess, using the interface defined by
[`include/engine.h`](ihttps://git.sr.ht/~skiqqy/chess/tree/master/item/include/engine.h)
as defined by [TGB](https://git.sr.ht/~skiqqy/tgb).

The interface will be something along the lines of, the game engine __must__
provide the following functions. What follows is a rough specification of what
this engine __must__ provide.

### Engine Interface

> Note, argument params and types are subject to change. This is simply a rough
> roadmap.

* The board __must__ be represented as a single dimension array, to access the
  co-ord we simply use mod and div appropriatly. E.G, given an n by n board.
  position 21 in the array indicates, x -> 2, y -> 1 on the board, note that
  the top left of the board is represented by 00, and bottom right by
  (n-1)(n-1). Reason: This makes copying board states trivial, and passing via
  MPI trivial as well, also a move is simply written as two ints (start point
  and end point). That being said, the engine __must__ have an init function
  that returns the start board for the game.
  * Func Def: `int *initgame()`
* Given a board state and a move, check to see if a given move is legal.
  * Func Def: `int islegal(int *board, int *move)`
* Make a move, and return the new board state. Reason, some games can vastly
  alter the game state (think
  [othello](https://www.eothello.com/#how-to-play)), and this should be
  abstracted to the game engine, the bot simply wants to see if a move is
  valid, and then get the game state after applying that move.
  * Func Def: `int *move(int *board, int *move)`
* An eval function, I have not yet decided if this should come with the game
  engine, but as of now I think this will be the best place to package it. The
  purpose of the eval function will be to determine how good the game state
  is for the current player, higher int -> better state.
  * Func Def: `int eval(int *board, int player)`
* Check the game state, given a board. (WIP, still deciding on struct).
  * Func Def: `struct state *gamestate(int *board)`
  * Struct: The struct `state` will have the following fields.
    * `int winner;`
      * -1: Game is still ongoing
      *  0: Player 0 won.
      *  1: Player 1 won.
      *  2: Draw.
    * `int turn`
      * 0: Player 0's turn
      * 1: Player 1's turn
    * `void *other;`

#### Events

Certain games can have a move that results in a certain amount of steps that
happen (e.g promoting a piece in chess), too handle this, the library should
implement an event handler(s) which are simple function pointers which exec the
given event.

This abstract bot will essentially be a more advanced version of what I
implemented in my third year concurrency course, excepte it has the advantage
of working given an engine for any game (that implemented the above interface
correctly).

Given the above interface, the engine will allow us to implement a driver that
will allow users to play the game, which by extension will allow us to
implement a bot that plays the game against itself.
This engine will be used in the [TGB](https://git.sr.ht/~skiqqy/tgb) project,
for more information consult the TGB
[README](https://git.sr.ht/~skiqqy/tgb/tree/master/item/README.md).

## Notes