# Ultimate TTT - Server

> Ultimate Tic Tac Toe Algorithm - Game Server

This is a system intended for games & hackathons mainly, for teams to write their own bot and compete against other bots.

They will be playing games of "Ultimate Tic Tac Toe", which provides a great opportunity for learning, predicting moves...

## Getting started

### Deploy online

You can directly deploy the server to Heroku for a quick start:

When deploying, choose any available App Name (or let Heroku decide for you), and click on Deploy. Once it's finished browse to `https://{app-name}.herokuapp.com` and you should see the server welcome message.

If you open our web client, you can then connect it to the server by clicking on "Connect" and entering `https://{app-name}.herokuapp.com` as the server host.

### Install locally

     $ npm install -g @socialgorithm/uttt

### Run in online mode

By default, the server will start in online mode and listen for players on port `3141`.

By default the server will have players play 1000 games per session.

You can launch the server using:

    $ uttt

Options:

    uttt

      Ultimate Tic Tac Toe - Game Server

    Options

      --verbose           The input to process.
      -v, --version       Display the server version
      -p, --port 3141     Port on which the server should be started (defaults to 3141)
      -g, --games 1000    Number of games to play, defaults to 1000
      -t, --timeout 100   Milliseconds after which a player loses (defaults to 100)
      -h, --help          Print this guide

    Synopsis

      $ uttt --games 100
      $ uttt --port 5000
      $ uttt --help

When running in online mode you can also use env variables to override the settings (which is very useful when deploying to a server for example)

- `PORT` overrides the port
- `TTT_TIMEOUT` overrides the timeout
- `TTT_GAMES` overrides the number of games that are played per round

The server uses the `ultimate-ttt` Nodejs implementation of the game to validate and verify game states.

If you're developing a client in JavaScript you can also use that package to maintain your local state easily.

## Developer Docs

## Roadmap

- Execute X number of games and display stats
- Setup a server so clients can play over a socket
- Setup a DB so players can use a token to identify
- Create a web frontend to see stats and manage the competition (ultimate-ttt-web)

## Testing a client

This repository includes a test file that can be run against a custom client to verify that it does the basics right. Simply copy `tests/client.test.js` and point it to your implementation. The tests can be run by installing `ava` and then adding it as the test runner in your `package.json` file.

Generated using TypeDoc