Play Hex online.
Currently hosted here: https://playhex.org
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:
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
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:
You can contribute to translations without any coding, thanks to Weblate.
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.
# Unit tests (Mocha)
yarn test
# e2e tests (Cypress)
yarn test:e2e
# Open Cypress browser
yarn cypress open
Warning: For e2e/cypress tests, there is some configuration requirements:
- Random bots must exists in database, if not, run:
yarn hex create-random-bots
- Random bots must play instantaneously, which is the default. If you changed this, make sure this env var is zero again:
RANDOM_BOT_WAIT_BEFORE_PLAY=0
- A functional test in auth.cy.ts needs at least one game in database to run fully.
# See which dependencies take more size
yarn analyse-size
Compare two json files with: https://happy-water-0887b0b1e.azurestaticapps.net.
This project is under AGPL-3.0 license.
Files under these folders are under another license:
Folder | License | Author |
---|---|---|
assets/sounds/lisp/ |
CC BY-NC-SA 4.0 |
EdinburghCollective |