Giter VIP home page Giter VIP 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, 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.

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 project is under AGPL-3.0 license.

Exceptions

Files under these folders are under another license:

Folder License Author
assets/sounds/lisp/ CC BY-NC-SA 4.0 EdinburghCollective

hex's People

Contributors

alcalyn avatar atalanttore avatar bannerets avatar guillevg avatar ursi avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hex's Issues

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.

For newcomers, when AI takes time to play its first move, they think the game has not started

Case here: https://playhex.org/games/16bdcbb7-36ae-408d-9762-b063790b4f63

For new players who don’t know PlayHex yet, it should be clear when the AI is computing a move, or the player think he still have to make the game starts.

It happens more when players choose high level Mohex (take ~20sec per move),
or when there is no fast worker: katahex intuition can take ~20sec on first move, mohex 2 take 4sec per move, sometimes 8sec when there is 2 ai games at same time (moves are queued).

Here is time taken for moves computation when no fast worker available and 2 AI games at same time:

image

A solution would be to show a "computing" icon next to AI username

Make cancel game button blinks when I joined an afk game and I can still cancel

If I join an afk game, I wait for opponent but is afk, and I can still cancel, make cancel button softly blink to suggest to cancel game.

Useful to new players that don’t know yet the UI, and are maybe worried to lose a game and impact rating.

  • When it is possible to cancel, host is offline and I wait, make cancel button blinks
  • Show explanation in cancel confirmation popin to say canceling is not a lost and won’t impact rating.

SGF: add players ratings

When generating a SGF file for a game, add BR and WR with players ratings.

Ratings must be player rating at the time the game was played.

Change win messages

proposed changes:

{player} won the game! -> {player} won!
{player} won by time! -> {player} won on time!
{player} won by resignation! -> {player} won!
{player} wins the game! -> {player} wins!
{player} wins by time! -> {player} wins on time!
{player} wins by resignation! -> {player} wins!

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.)

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.