Git Product home page Git Product logo

hex's Introduction

Hex

Play Hex online.

Currently hosted here: https://playhex.org

PlayHex

Install

Requires:

  • node >= 18.18.2
  • yarn
  • mysql or postgres

Create an .env file with at least a database access. Example:

DATABASE_URL="mysql://root:root@localhost:3306/hex"

Then run these commands:

# Install dependencies
yarn install

# Create database schema
yarn db:sync

# Start application
yarn serve

Wait javascript to be bundled, then the application is available at:

http://localhost:3000/

Play with AI

For development you can use random and determinist random bots.

Enable them with:

yarn hex create-random-bots

Determinist random bot will always plays same games if you play same moves in same order. This is useful to reproduce things.

If you need to work with real AI (Katahex, Mohex), see:

https://github.com/alcalyn/hex-ai-distributed

You can install it locally, and with Docker you don't need to compile any ai engine.

Once installed, add to your .env file:

HEX_AI_API=http://localhost:8088

And enable ai players in database with:

yarn hex create-katahex-bots
yarn hex create-mohex-bots

Translate PlayHex

PlayHex uses i18next and i18next-vue to translate user interface.

Here are all available translations, just click the following image to help translating or add a new language:

Translation status

You can contribute to translations without any coding, thanks to Weblate.

Admin endpoints

Some API endpoints exists for admin tasks (i.e persist all memory games into database manually).

To use them, you must add in your .env:

ADMIN_PASSWORD=your-password

Then you can now call admin endpoints by setting this same password as bearer token, curl example:

curl --location --request POST 'http://localhost:3000/api/admin/persist-games' \
    --header 'Authorization: Bearer your-password'

See available admin endpoints in postman collection, in "Admin" folder.

Test

# Unit tests (Mocha)
yarn test

# e2e tests (Cypress)
yarn test:e2e

# Open Cypress browser
yarn cypress open

Warning: For e2e/cypress tests, random bots are required so don't forget to run this before:

yarn hex create-random-bots

Optimize js size

# See which dependencies take more size
yarn analyse-size

Compare two json files with: https://happy-water-0887b0b1e.azurestaticapps.net.

License

This library is under AGPL-3.0 license.

hex's People

Contributors

alcalyn avatar bannerets avatar ursi avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hex's Issues

Configurable shading patterns

It would be nice to have user-configurable display of the shading patterns on the board. Some of the possible options:

  • uniformly colored hexes (now)
  • tri-color checkerboard-like pattern (used on http://www.mseymour.ca/hexdb.html). makes it easier to see a chain of bridges
  • highlight even rows concentrically (used on https://hexworld.org/board/ and BGA)
  • a potential experimental one to highlight all height-5 rows in a grid pattern (not used anywhere right now afaik but was proposed before)

Additionally, an independent option to display "star points", i.e., for example, small dots on all four 4-4 points (used on playok), would be useful. The star points (and the aforementioned patterns) make it easier to play bullet games.

(Personally I like the checkerboard-like pattern the most.)

Add a share button

On mobile, the best experience is to add the web page to your home screen, that way the bars in the mobile browser don't obscure the game board, but when doing so there is no way to send someone a link to your game. A share button that hooks into to the phone's share API (see a youtube video for an example) should be added.

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.