Skip to content

sunflowerseastar/merels

Repository files navigation

Merels

Quick Start

Yarn, Vite.

yarn
yarn start # localhost:5137
tsc --no-emit # type check

yarn build
yarn preview # localhost:4137 to check build

Auto-prettier with simple-git-hooks + lint-staged.

Dependencies

APL

Nick Nickolov’s APL is hard-copied into lib/apl, with a few helper functions cherry-picked from the GitLab repo into lib/aplLibraryHelpers.ts. See lib/apl/license and lib/apl/readme.md. My code calls the library and helpers from src/aplGameFunctions.ts.

TypeScript

Note that allowSyntheticDefaultImports is set to true in tsconfig.json since lib/apl/apl.js is commonJS (module.exports).

Umbrella

Atom manages game state (like Clojure atoms), hdom manages the DOM, and paths is an immutable nested object accessor/helper. If you’re unfamiliar with umbrella, take a look at it and thi.ng. Incredible.

Rules

  • White starts, white & black alternate turns.
  • Phase 1: place one piece on the board in an open position.
  • If a mill is formed (three of your pieces in a row), remove an opponent piece. A piece in a mill cannot be removed unless no others are available.
  • After all pieces have been placed, phase 2 begins: move one piece to an adjacent location. Same form-a-mill-and-remove-an-opponent-piece rule applies.
  • Player reduced to two pieces or trapped with no legal moves loses.

Board

Possible piece positions:

1  0  0  1  0  0  1
0  1  0  1  0  1  0
0  0  1  1  1  0  0
1  1  1  0  1  1  1
0  0  1  1  1  0  0
0  1  0  1  0  1  0
1  0  0  1  0  0  1

Grid index:

0  1  2  3  4  5  6
7  8  9  10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48

Grid index with non-positions omitted:

0        3        6
   8     10    12
      16 17 18
21 22 23    25 26 27
      30 31 32
   36    38    40
42       45       48

Apl index shown on the board:

0       1        2
  9     10    11
     18 19 20
3 12 21    23 14 5
     24 25 26
  15    16    17
6       7        8

Apl index:

0 1 2    9 10 11   18 19 20
3   5   12    14   21    23
6 7 8   15 16 17   24 25 26

Apl positions using the grid indices (translation with utility.ts gridIndexToAplIndex):

 0  3  6    8 10 12   16 17 18
21    27   22    26   23    25
42 45 48   36 38 40   30 31 32

About

nine men's morris using APL in TS

Topics

Resources

License

Stars

Watchers

Forks