Skip to content

tomasz-chojna/hex

Repository files navigation

hex

Build Status Coverage Status

Hex is a board game for 2 players. In order to to win, one of the players has to connect opposite sides of the board with unbroken chain. Every player can ocupy single free hexagon on the board during the move.

Technically, solving for a winner requires finding a path between the opposite sides of the board, which is implemented here as traversing a graph consisting of hexagons (nodes) linked to each other through their edges. Breadth-first search graph traversal algorithm is used. See here.

Board graph

Backend

GraphQL API (with GraphQL Subscriptions for Websockets handling) is implemented using Node.js and Express framework.

Data about players and game sessions is stored in PostgreSQL database.

This implementation assumes single game server, although it could be extended to use a different Pub/Sub mechanism (Redis Pub/Sub for example) to scale to more instances.

Frontend

Frontend of the game is built as a Single Page Application using Facebook's React.

The following views can be presented in the app:

  • Homepage with Login (including fb login)

Homepage

  • Registration (regular registration with email)
  • Fb login account creation confirmation (setting up a profile)
  • Online players view
  • Game invitation
  • Invitations list
  • Game board
  • Winner popup
  • Scoreboard

Development environment

Application is dockerized and docker-compose.yml file is included, so it can be launched with a single command:

docker-compose up

By default the application will listen on http://localhost:5000/.

Environment variables
FACEBOOK_APP_ID
FACEBOOK_APP_SECRET
DATABASE_HOST
DATABASE_USER
DATABASE_PASSWORD
DATABASE_NAME
PORT