@slugbugblue/trax 0.21.0 → 0.23.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 +23 -6
- package/README.md +9 -175
- package/docs/engine.md +1 -1
- package/package.json +12 -23
- package/src/engine.js +128 -52
- package/src/types.d.ts +23 -131
- 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,30 @@
|
|
|
1
1
|
# @slugbugblue/trax
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.23.0 - 2023-03-28
|
|
4
|
+
|
|
5
|
+
Release candidate
|
|
6
|
+
|
|
7
|
+
Finalize work with jsdoc/typescript
|
|
8
|
+
|
|
9
|
+
## 0.22.0 - 2023-03-25
|
|
10
|
+
|
|
11
|
+
- Pull point.js into its own package: `@slugbugblue/point`
|
|
12
|
+
- Pull lru.js into its own package: `@slugbugblue/lru`
|
|
13
|
+
- Pull puzzles.js into its own package: `@slugbugblue/trax-puzzles`
|
|
14
|
+
- Pull tty.js into its own package: `@slugbugblue/trax-tty`
|
|
15
|
+
- Pull analyst.js into its own package: `@slugbugblue/trax-analyst`
|
|
16
|
+
- Pull cli.js into its own package: `@slugbugblue/trax-cli`
|
|
17
|
+
|
|
18
|
+
## 0.21.0 - 2023-03-12
|
|
4
19
|
|
|
5
20
|
- Update the analysis engine to be more lazy
|
|
6
21
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
22
|
+
- The LRU cache is more likely to have a hit because it no longer separates
|
|
23
|
+
validated from unvalidated analyses
|
|
24
|
+
- Suggestions are much faster because it now skips validations for low-scoring
|
|
25
|
+
moves
|
|
26
|
+
- You will now need to call `validateThreats()` to remove faulty threats
|
|
27
|
+
manually
|
|
11
28
|
|
|
12
29
|
## 0.20.0 - 2023-02-11
|
|
13
30
|
|
|
@@ -17,7 +34,7 @@
|
|
|
17
34
|
- Drop support for node 14; node v16.15 is our minimum supported version
|
|
18
35
|
- More puzzles from Martin M. S. Pedersen -- bringing the total to 100+
|
|
19
36
|
- Enhance the docker configuration and document it in the README
|
|
20
|
-
- Refine faulty threat detection and add test for
|
|
37
|
+
- Refine faulty threat detection and add test for one case it was failing
|
|
21
38
|
|
|
22
39
|
## 0.19.0 - 2023-02-06
|
|
23
40
|
|
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.23.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,
|