@slugbugblue/trax 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -5
- package/README.md +9 -175
- package/docs/engine.md +1 -1
- package/package.json +12 -23
- package/src/engine.js +7 -12
- package/src/types.d.ts +11 -134
- package/src/version.js +1 -1
- package/.dockerignore +0 -11
- package/Dockerfile +0 -14
- package/docs/analyst.md +0 -236
- package/docs/lru.md +0 -151
- package/docs/point.md +0 -148
- package/src/analyst.js +0 -858
- package/src/cli.js +0 -732
- package/src/cmds/analyze.js +0 -112
- package/src/cmds/delete.js +0 -71
- package/src/cmds/help.js +0 -81
- package/src/cmds/import-export.js +0 -394
- package/src/cmds/list.js +0 -177
- package/src/cmds/new.js +0 -136
- package/src/cmds/notes.js +0 -37
- package/src/cmds/play-try.js +0 -175
- package/src/cmds/puzzles.js +0 -188
- package/src/cmds/select.js +0 -47
- package/src/cmds/suggest.js +0 -55
- package/src/cmds/undo.js +0 -40
- package/src/cmds/view.js +0 -65
- package/src/lru.js +0 -153
- package/src/point.js +0 -173
- package/src/puzzles.js +0 -1236
- package/src/threats.js +0 -223
- package/src/tty.js +0 -317
- package/src/utils.js +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
# @slugbugblue/trax
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.22.0 - 2023-03-25
|
|
4
|
+
|
|
5
|
+
- Pull point.js into its own package: `@slugbugblue/point`
|
|
6
|
+
- Pull lru.js into its own package: `@slugbugblue/lru`
|
|
7
|
+
- Pull puzzles.js into its own package: `@slugbugblue/trax-puzzles`
|
|
8
|
+
- Pull tty.js into its own package: `@slugbugblue/trax-tty`
|
|
9
|
+
- Pull analyst.js into its own package: `@slugbugblue/trax-analyst`
|
|
10
|
+
- Pull cli.js into its own package: `@slugbugblue/trax-cli`
|
|
11
|
+
|
|
12
|
+
## 0.21.0 - 2023-03-12
|
|
4
13
|
|
|
5
14
|
- Update the analysis engine to be more lazy
|
|
6
15
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
16
|
+
- The LRU cache is more likely to have a hit because it no longer separates
|
|
17
|
+
validated from unvalidated analyses
|
|
18
|
+
- Suggestions are much faster because it now skips validations for low-scoring
|
|
19
|
+
moves
|
|
20
|
+
- You will now need to call `validateThreats()` to remove faulty threats
|
|
21
|
+
manually
|
|
11
22
|
|
|
12
23
|
## 0.20.0 - 2023-02-11
|
|
13
24
|
|
package/README.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# Trax
|
|
2
2
|
|
|
3
|
-
This project
|
|
4
|
-
|
|
5
|
-
- Trax game-playing engine
|
|
6
|
-
- Position analysis engine
|
|
7
|
-
- Over 100 puzzles to help hone your Trax skills
|
|
8
|
-
- Command-line interface for ease of use
|
|
3
|
+
This project provides the ability to work with Trax games in Javascript.
|
|
9
4
|
|
|
10
5
|
## Description
|
|
11
6
|
|
|
@@ -15,130 +10,15 @@ information about Trax, including its [rules][traxrules] and
|
|
|
15
10
|
|
|
16
11
|
The goal of this javascript project is to allow Trax to be played
|
|
17
12
|
programmatically. It can be used as an engine in a web browser, for example at
|
|
18
|
-
[slugbugblue.com][sbb]; or in nodejs, for example by using the
|
|
19
|
-
provided as
|
|
13
|
+
[slugbugblue.com][sbb]; or in nodejs, for example by using the [trax
|
|
14
|
+
CLI][trax-cli] provided as a child of this project.
|
|
20
15
|
|
|
21
16
|
The Trax engine now enjoys automated testing with 100% code coverage. Any future
|
|
22
|
-
changes
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
Installation can be done in one of three ways, each for a slightly different
|
|
27
|
-
purpose.
|
|
28
|
-
|
|
29
|
-
If you want to use this code in your own javascript project:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install @slugbugblue/trax
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
If you want to use the trax CLI on your computer:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm install -g @slugbugblue/trax
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
If you don't have node installed and want to use the CLI as a docker container:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
git clone https://gitlab.com/slugbugblue/trax.git ~/trax
|
|
45
|
-
docker build -t trax ~/trax
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## CLI Usage
|
|
49
|
-
|
|
50
|
-
The command-line interface is provided as `trax`, available in your path if
|
|
51
|
-
installed globally, or in the `node_modules/.bin` directory and runnable using
|
|
52
|
-
`npx trax` if installed locally.
|
|
53
|
-
|
|
54
|
-
> If you installed by creating a Docker image, use the following command to
|
|
55
|
-
> launch the CLI:
|
|
56
|
-
>
|
|
57
|
-
> - `docker run --name trax -itv $HOME/trax:/mnt/data --rm trax`
|
|
58
|
-
>
|
|
59
|
-
> Since that's a bit much to type, it's recommended to create an alias in one of
|
|
60
|
-
> your startup scripts:
|
|
61
|
-
>
|
|
62
|
-
> - `alias trax="docker run --name trax -itv $HOME/trax:/mnt/data --rm trax"`
|
|
63
|
-
>
|
|
64
|
-
> Then you can launch the docker container simply by typing in `trax`, the same
|
|
65
|
-
> as if it were installed globally.
|
|
66
|
-
|
|
67
|
-
The CLI can be used interactively by running the command with no parameters or
|
|
68
|
-
by passing the `--interactive` or `-i` flag. When run interactively, you can
|
|
69
|
-
avoid worries about the need to escape certain characters from the shell, and it
|
|
70
|
-
can be easier to run multiple commands back to back.
|
|
71
|
-
|
|
72
|
-
Help is available for the CLI through the use of the `help` command. Type
|
|
73
|
-
`trax help` (or `npx trax help` with a local installation, or simply `help` if
|
|
74
|
-
run interactively) to see a list of the available commands, and `trax help play`
|
|
75
|
-
to see information about the `play` command. Aliases and abbreviations are
|
|
76
|
-
provided to minimize typing and to try to avoid the requirement of memorizing
|
|
77
|
-
the commands. For example, the `list` command has an alias of `ls`, and the
|
|
78
|
-
`select` command can be activated using `#`.
|
|
79
|
-
|
|
80
|
-
When you first launch the CLI, you can create a new game using the `new`
|
|
81
|
-
command, and then enter moves for that game using `play`. Since `play` is likely
|
|
82
|
-
to be the most common command used, you can simply omit the command name. For
|
|
83
|
-
example, at the interactive prompt, entering `@0/` is the same as if you had
|
|
84
|
-
entered `play 1. @0/`.
|
|
85
|
-
|
|
86
|
-
Multiple games can be started at once, and the CLI will remember the currently
|
|
87
|
-
active game and apply future actions to that game. Each game will retain its
|
|
88
|
-
`#id` number until it is deleted, and you can use that number to switch between
|
|
89
|
-
games. For example, to make game \#1 active, enter `select 1` or `select #1` or
|
|
90
|
-
simply `#1` at the interactive prompt.
|
|
91
|
-
|
|
92
|
-
For ease of working at the command line, the symbols used as the last character
|
|
93
|
-
of the Trax notation can optionally be replaced with letters. Use `s` for slash
|
|
94
|
-
symbol (`/`), `b` for backslash (`\`), and `p` for plus (`+`). While there is no
|
|
95
|
-
need to escape at the interactive prompt, these substitutions will be avilable
|
|
96
|
-
there as well.
|
|
97
|
-
|
|
98
|
-
### Examples
|
|
99
|
-
|
|
100
|
-
```text
|
|
101
|
-
# Start a new Trax game with Chad playing as white
|
|
102
|
-
> trax new Chad vs
|
|
103
|
-
|
|
104
|
-
# Start a new Loop Trax game with Chad playing as black
|
|
105
|
-
> trax new loop vs Chad
|
|
106
|
-
|
|
107
|
-
# Start a new 8x8 Trax game with Chad as white and Another Player as black
|
|
108
|
-
> trax new 8x8 Chad vs Another Player
|
|
109
|
-
|
|
110
|
-
# Switch back to the first game. Note the quoting required at the command line.
|
|
111
|
-
# This would not be necessary when running at the interactive prompt.
|
|
112
|
-
> trax '#1'
|
|
113
|
-
|
|
114
|
-
# Play two moves, using full notation
|
|
115
|
-
> trax play 1. @0/ 2. A0/
|
|
116
|
-
|
|
117
|
-
# Two more moves, using short notation and symbol substitution
|
|
118
|
-
# B2/ => b2s and A0\ => a0b
|
|
119
|
-
> trax b2s a0b
|
|
120
|
-
|
|
121
|
-
# See the status of all games
|
|
122
|
-
> trax ls
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Environment variables
|
|
126
|
-
|
|
127
|
-
The CLI uses standard Windows and Linux [XDG][xdg] file locations as provided by
|
|
128
|
-
the [env-paths library][env-path], with current uses being user-specific
|
|
129
|
-
`config` (`XDG_CONFIG_HOME`) and `data` (`XDG_DATA_HOME`) folders.
|
|
130
|
-
|
|
131
|
-
In addition, the CLI recognizes several environment variables to determine the
|
|
132
|
-
glyphs to use in the user interface. Setting either `NERDFONT` or `NERDFONTS` to
|
|
133
|
-
any non-empty string will use characters from [Nerdfonts][nerfont]. Otherwise,
|
|
134
|
-
any of `POWERLINE`, `P9K_TTY`, or `P9K_SSH` will use characters from [Powerline
|
|
135
|
-
fonts][powerline].
|
|
17
|
+
changes should meet the same standard.
|
|
136
18
|
|
|
137
19
|
## API Usage
|
|
138
20
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
The main Trax engine is provided in `engine.js`, which can be used as follows:
|
|
21
|
+
The Trax engine can be used as follows:
|
|
142
22
|
|
|
143
23
|
```javascript
|
|
144
24
|
import { Trax } from '@slugbugblue/trax'
|
|
@@ -158,47 +38,7 @@ let puzzle = new Trax('trax', '@0/ a0\\ @2/')
|
|
|
158
38
|
puzzle.play('@2\\')
|
|
159
39
|
```
|
|
160
40
|
|
|
161
|
-
For specifics, see the [engine.js documentation][docs
|
|
162
|
-
|
|
163
|
-
### Analysis
|
|
164
|
-
|
|
165
|
-
The analysis engine is provided in `analyst.js`, and it can be used as follows:
|
|
166
|
-
|
|
167
|
-
```javascript
|
|
168
|
-
import { Trax } from '@slugbugblue/trax'
|
|
169
|
-
import { analyze } from '@slugbugblue/trax/analyst'
|
|
170
|
-
|
|
171
|
-
let trax = new Trax('trax', '@0/ @1\\')
|
|
172
|
-
|
|
173
|
-
let analysis = analyze(trax)
|
|
174
|
-
|
|
175
|
-
console.log('Edge analysis:', analysis.edge)
|
|
176
|
-
console.log('Threat analysis:', analysis.threats)
|
|
177
|
-
console.log('Score analysis:', analysis.scores)
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
For additional information, refer to the [analyst.js
|
|
181
|
-
documentation][docs-analyst].
|
|
182
|
-
|
|
183
|
-
### Threats database
|
|
184
|
-
|
|
185
|
-
The threats database is currently hand-coded in `threats.js`, so refer to that
|
|
186
|
-
file if you want to try to update the analysis engine's understanding of
|
|
187
|
-
threats.
|
|
188
|
-
|
|
189
|
-
### Puzzles database
|
|
190
|
-
|
|
191
|
-
The puzzles database is provided in `puzzles.js`, and contains puzzles that I've
|
|
192
|
-
been using to test the analysis engine, publicly available puzzles from [the
|
|
193
|
-
traxgame.com puzzles page][traxpuzzles], and [puzzles curated][puzzlebook] by
|
|
194
|
-
[Martin M. S. Pedersen][traxplayer].
|
|
195
|
-
|
|
196
|
-
## Roadmap
|
|
197
|
-
|
|
198
|
-
- Improve the threats database / analysis engine.
|
|
199
|
-
- Bot should be able to win all puzzles.
|
|
200
|
-
- Analysis should recognize line threats.
|
|
201
|
-
- Add more puzzles.
|
|
41
|
+
For specifics, see the [engine.js documentation][docs].
|
|
202
42
|
|
|
203
43
|
## Support
|
|
204
44
|
|
|
@@ -227,7 +67,7 @@ infinite patience in indulging my many questions can never be repaid.
|
|
|
227
67
|
|
|
228
68
|
Thanks to [Martin M. S. Pedersen][traxplayer] for contributing ideas, code, and
|
|
229
69
|
puzzles. He's been [curating Trax puzzles][puzzlebook] and [coding solutions for
|
|
230
|
-
Trax][gnutrax] for over two decades, and
|
|
70
|
+
Trax][gnutrax] for over two decades, and has a lot of expertise in this area.
|
|
231
71
|
|
|
232
72
|
## License
|
|
233
73
|
|
|
@@ -257,21 +97,15 @@ David Smith and heirs, and are not to be used without permission.
|
|
|
257
97
|
[contributing]: CONTRIBUTING.md
|
|
258
98
|
[ctrans]: mailto:chad@transtrum.net
|
|
259
99
|
[dgb]: mailto:donald@traxgame.com
|
|
260
|
-
[docs
|
|
261
|
-
[docs-analyst]: docs/analyst.md
|
|
262
|
-
[env-path]: https://www.npmjs.com/package/env-paths
|
|
100
|
+
[docs]: docs/engine.md
|
|
263
101
|
[gnutrax]: https://gnutrax.com
|
|
264
102
|
[goldtoken]: https://goldtoken.com/
|
|
265
|
-
[nerdfont]: https://nerdfonts.com/
|
|
266
|
-
[powerline]: https://github.com/powerline/fonts
|
|
267
103
|
[puzzlebook]: https://gnutrax.com/book
|
|
268
104
|
[repo]: https://gitlab.com/slugbugblue/trax
|
|
269
105
|
[sbb]: https://slugbugblue.com/
|
|
106
|
+
[trax-cli]: https://gitlab.com/slugbugblue/trax-cli
|
|
270
107
|
[traxbook]: http://traxgame.com/shop_book.php
|
|
271
108
|
[traxgame]: http://traxgame.com/
|
|
272
109
|
[traxhistory]: http://www.traxgame.com/about_history.php
|
|
273
110
|
[traxplayer]: mailto:traxplayer@gmail.com
|
|
274
|
-
[traxpuzzles]: http://www.traxgame.com/games_puzzles.php
|
|
275
111
|
[traxrules]: http://www.traxgame.com/about_rules.php
|
|
276
|
-
[xdg]:
|
|
277
|
-
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
package/docs/engine.md
CHANGED
|
@@ -427,4 +427,4 @@ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
427
427
|
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
428
428
|
specific language governing permissions and limitations under the License.
|
|
429
429
|
|
|
430
|
-
[point-docs]: point
|
|
430
|
+
[point-docs]: https://gitlab.com/slugbugblue/point
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slugbugblue/trax",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Trax game engine
|
|
3
|
+
"version": "0.22.0",
|
|
4
|
+
"description": "Trax game engine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"trax",
|
|
7
7
|
"traxgame",
|
|
@@ -14,33 +14,22 @@
|
|
|
14
14
|
"types": "./src/types.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": "./src/engine.js",
|
|
17
|
-
"./
|
|
18
|
-
"./
|
|
19
|
-
"./point": "./src/point.js",
|
|
20
|
-
"./puzzles": "./src/puzzles.js",
|
|
21
|
-
"./threats": "./src/threats.js",
|
|
22
|
-
"./tty": "./src/tty.js",
|
|
23
|
-
"./utils": "./src/utils.js",
|
|
24
|
-
"./version": "./src/version.js"
|
|
17
|
+
"./version": "./src/version.js",
|
|
18
|
+
"./version.js": "./src/version.js"
|
|
25
19
|
},
|
|
26
20
|
"repository": "gitlab:slugbugblue/trax",
|
|
27
|
-
"bin": {
|
|
28
|
-
"trax": "./src/cli.js"
|
|
29
|
-
},
|
|
30
21
|
"scripts": {
|
|
31
|
-
"benchmark": "node benchmark/puzzles.bench.js",
|
|
32
22
|
"genversion": "genversion --es6 src/version.js",
|
|
33
|
-
"git-add": "git add src/version.js
|
|
23
|
+
"git-add": "git add src/version.js",
|
|
34
24
|
"test": "xo && c8 ava",
|
|
35
25
|
"prepare": "husky install",
|
|
36
26
|
"preversion": "npm test",
|
|
37
|
-
"version": "npm run genversion ; npm run
|
|
27
|
+
"version": "npm run genversion ; npm run git-add",
|
|
38
28
|
"postversion": "git push && git push --tags && npm publish"
|
|
39
29
|
},
|
|
40
30
|
"dependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"yaml": "^2.0.0-11"
|
|
31
|
+
"@slugbugblue/lru": "^1.0.0",
|
|
32
|
+
"@slugbugblue/point": "^1.0.0"
|
|
44
33
|
},
|
|
45
34
|
"devDependencies": {
|
|
46
35
|
"ava": "^5.1.0",
|
|
@@ -55,11 +44,11 @@
|
|
|
55
44
|
"node": ">=16.15.0"
|
|
56
45
|
},
|
|
57
46
|
"c8": {
|
|
58
|
-
"branches":
|
|
47
|
+
"branches": 100,
|
|
59
48
|
"check-coverage": true,
|
|
60
|
-
"functions":
|
|
61
|
-
"lines":
|
|
62
|
-
"statements":
|
|
49
|
+
"functions": 100,
|
|
50
|
+
"lines": 100,
|
|
51
|
+
"statements": 100
|
|
63
52
|
},
|
|
64
53
|
"prettier": {
|
|
65
54
|
"bracketSpacing": true,
|
package/src/engine.js
CHANGED
|
@@ -15,23 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
// Trax internals. Woot.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
// starting from the top and going clockwise, and then sorted alphabetically
|
|
20
|
-
// and given a single letter name, so 'bbww' becomes 'a', which gives us six
|
|
21
|
-
// different tile names: a-f
|
|
18
|
+
import { Point } from '@slugbugblue/point'
|
|
22
19
|
|
|
23
|
-
import { Point } from '@slugbugblue/trax/point'
|
|
24
|
-
|
|
25
|
-
// Type definitions
|
|
26
20
|
// Fun trax helper constants
|
|
27
21
|
|
|
28
22
|
const zero = new Point(0, 0)
|
|
29
23
|
const moveNumberRegex = /^(\d+)[.):]?$/
|
|
30
24
|
const notationRegex = /^([@a-z]+)(\d+)([/\\+])$/i
|
|
31
25
|
|
|
32
|
-
/** @type ValidTiles[] */
|
|
33
|
-
const tileTypes = ['a', 'b', 'c', 'd', 'e', 'f']
|
|
34
|
-
|
|
35
26
|
/** Tiles are represented by the letters a-f.
|
|
36
27
|
* a b c d e f
|
|
37
28
|
* +--#--+ +--#--+ +--#--+ +--o--+ +--o--+ +--o--+
|
|
@@ -40,7 +31,12 @@ const tileTypes = ['a', 'b', 'c', 'd', 'e', 'f']
|
|
|
40
31
|
* | o | | # | | o | | # | | o | | # |
|
|
41
32
|
* +--o--+ +--#--+ +--o--+ +--#--+ +--o--+ +--#--+
|
|
42
33
|
*
|
|
43
|
-
*
|
|
34
|
+
* @readonly
|
|
35
|
+
* @type ValidTiles[]
|
|
36
|
+
* */
|
|
37
|
+
const tileTypes = ['a', 'b', 'c', 'd', 'e', 'f']
|
|
38
|
+
|
|
39
|
+
/** Slashes are represented by / \ or +.
|
|
44
40
|
* @readonly
|
|
45
41
|
* @type {Record<ValidTiles, Slash>}
|
|
46
42
|
*/
|
|
@@ -252,7 +248,6 @@ export class Trax {
|
|
|
252
248
|
/** Restore a previously saved position.
|
|
253
249
|
* @arg {SaveState} saved - the previously saved state
|
|
254
250
|
* @see save for saving the state
|
|
255
|
-
* @returns {void}
|
|
256
251
|
*/
|
|
257
252
|
restore(saved) {
|
|
258
253
|
// So we need to be able to restore it when we are done
|
package/src/types.d.ts
CHANGED
|
@@ -7,131 +7,6 @@
|
|
|
7
7
|
/** Color is a single character to represent white or black. */
|
|
8
8
|
type Color = 'w' | 'b'
|
|
9
9
|
|
|
10
|
-
/** Colorize is a fancy function for colorizing text. */
|
|
11
|
-
type Colorize = (text: string, def?: string | number) => string
|
|
12
|
-
|
|
13
|
-
/** Colorer is a little too fancy. Hence the gnarly typescript. */
|
|
14
|
-
type Colorer = {
|
|
15
|
-
(text: string, def?: string | number): string
|
|
16
|
-
black: Colorize
|
|
17
|
-
command: Colorize
|
|
18
|
-
default: Colorize
|
|
19
|
-
error: Colorize
|
|
20
|
-
fatal: Colorize
|
|
21
|
-
help: Colorize
|
|
22
|
-
id: Colorize
|
|
23
|
-
variable: Colorize
|
|
24
|
-
optional: Colorize
|
|
25
|
-
short: Colorize
|
|
26
|
-
white: Colorize
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** An object representing a space on the perimeter of a Trax position.
|
|
30
|
-
* x,y: the coordinates of the space
|
|
31
|
-
* c: the color present beside the space (w, b, l: both w and b, r: none)
|
|
32
|
-
* t: the type of possible moves: n-normal, x-none, c-cave, C-restricted cave
|
|
33
|
-
* b,w: if present, the number of the line to match with its other end
|
|
34
|
-
* pb, pw: if present, can pair with the next line in one turn
|
|
35
|
-
* xb, xw: the label of this space for each color
|
|
36
|
-
*/
|
|
37
|
-
type EdgeLocation = {
|
|
38
|
-
x: number
|
|
39
|
-
y: number
|
|
40
|
-
c: string
|
|
41
|
-
t: string
|
|
42
|
-
b?: number
|
|
43
|
-
w?: number
|
|
44
|
-
pb?: boolean
|
|
45
|
-
pw?: boolean
|
|
46
|
-
zb?: string
|
|
47
|
-
zw?: string
|
|
48
|
-
idx?: number
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type EdgeObject = {
|
|
52
|
-
b: string
|
|
53
|
-
w: string
|
|
54
|
-
edge: RawEdge
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Object representing a concrete threat found in a position. */
|
|
58
|
-
type FoundThreat = {
|
|
59
|
-
threat: string
|
|
60
|
-
match: string
|
|
61
|
-
at: number
|
|
62
|
-
value: number
|
|
63
|
-
level: number
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Threats found for each color that cannot actually be activated. */
|
|
67
|
-
type FaultyThreats = {
|
|
68
|
-
b: FoundThreat[]
|
|
69
|
-
w: FoundThreat[]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** An object with keys representing each level, with arrays for each threat of
|
|
73
|
-
* that level. */
|
|
74
|
-
type ColorThreats = Record<string, FoundThreat[]>
|
|
75
|
-
|
|
76
|
-
/** All the threats found for both the white and black player. */
|
|
77
|
-
type FoundThreatsCollection = { b: ColorThreats; w: ColorThreats }
|
|
78
|
-
|
|
79
|
-
/** Scores for each player. */
|
|
80
|
-
type Scores = {
|
|
81
|
-
b: number
|
|
82
|
-
w: number
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** A note with a move number */
|
|
86
|
-
type GameNote = {
|
|
87
|
-
move: number
|
|
88
|
-
note: string
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Notes saved in the game object in the CLI. */
|
|
92
|
-
type GameNotes = GameNote[]
|
|
93
|
-
|
|
94
|
-
/** A point-like object has numerical x and y properties. */
|
|
95
|
-
type PointLike = {
|
|
96
|
-
x: number
|
|
97
|
-
y: number
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** An object used to track an analysis on a position. */
|
|
101
|
-
type PositionScore = {
|
|
102
|
-
move: string
|
|
103
|
-
score: number
|
|
104
|
-
analysis?: Analysis
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** A puzzle. */
|
|
108
|
-
type Puzzle = {
|
|
109
|
-
id: string
|
|
110
|
-
src: string
|
|
111
|
-
game: TraxVariant
|
|
112
|
-
notation: string
|
|
113
|
-
icon: string
|
|
114
|
-
level: number
|
|
115
|
-
max: number
|
|
116
|
-
player: number
|
|
117
|
-
title?: string
|
|
118
|
-
desc?: string
|
|
119
|
-
hint?: string
|
|
120
|
-
hints?: string[]
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
type PuzzleSource = {
|
|
124
|
-
name: string
|
|
125
|
-
url?: string
|
|
126
|
-
copyright?: string
|
|
127
|
-
license?: string
|
|
128
|
-
licenseUrl?: string
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Array of objects representing the spaces surrounding the perimeter of a
|
|
132
|
-
* Trax position. */
|
|
133
|
-
type RawEdge = EdgeLocation[]
|
|
134
|
-
|
|
135
10
|
/** Treat the save state as an opaque object,
|
|
136
11
|
* produced by save() and fed into restore().
|
|
137
12
|
*/
|
|
@@ -155,14 +30,6 @@ type SaveState = {
|
|
|
155
30
|
*/
|
|
156
31
|
type Slash = '/' | '\\' | '+'
|
|
157
32
|
|
|
158
|
-
/** Threat definition. */
|
|
159
|
-
type Threat = {
|
|
160
|
-
depth: number
|
|
161
|
-
pattern: string
|
|
162
|
-
rx: RegExp
|
|
163
|
-
value: number
|
|
164
|
-
}
|
|
165
|
-
|
|
166
33
|
/** A single tile on the board. */
|
|
167
34
|
type Tile = {
|
|
168
35
|
id: TileId
|
|
@@ -188,5 +55,15 @@ type TileType = ValidTiles | 'x'
|
|
|
188
55
|
/** All of the variants supported by the engine. */
|
|
189
56
|
type TraxVariant = 'trax' | 'traxloop' | 'trax8'
|
|
190
57
|
|
|
191
|
-
/** Tile
|
|
58
|
+
/** Tile type names are determined by listing the line color at each edge,
|
|
59
|
+
* starting from the top and going clockwise, and then sorted alphabetically
|
|
60
|
+
* and given a single letter name, so 'bbww' becomes 'a', which gives us six
|
|
61
|
+
* different tile names: a-f, as follows:
|
|
62
|
+
* a b c d e f
|
|
63
|
+
* +--#--+ +--#--+ +--#--+ +--o--+ +--o--+ +--o--+
|
|
64
|
+
* | # | | # | | # | | o | | o | | o |
|
|
65
|
+
* oo ## ooo#ooo ## oo oo ## ####### ## oo
|
|
66
|
+
* | o | | # | | o | | # | | o | | # |
|
|
67
|
+
* +--o--+ +--#--+ +--o--+ +--#--+ +--o--+ +--#--+
|
|
68
|
+
*/
|
|
192
69
|
type ValidTiles = 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.22.0'
|
package/.dockerignore
DELETED
package/Dockerfile
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Use the latest nodejs long-term-support release,
|
|
2
|
-
# on the latest Alpine Linux for its small footprint
|
|
3
|
-
FROM node:lts-alpine
|
|
4
|
-
# Install current source code
|
|
5
|
-
WORKDIR /trax
|
|
6
|
-
COPY . .
|
|
7
|
-
RUN npm install
|
|
8
|
-
# Ensure the data files can be persisted
|
|
9
|
-
WORKDIR /mnt/data
|
|
10
|
-
ENV XDG_CONFIG_HOME=/mnt/data
|
|
11
|
-
ENV XDG_DATA_HOME=/mnt/data
|
|
12
|
-
VOLUME /mnt/data
|
|
13
|
-
# Use the trax CLI as the starting point
|
|
14
|
-
ENTRYPOINT ["/trax/src/cli.js"]
|