@slugbugblue/trax 0.4.0 → 0.8.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 +68 -17
- package/README.md +123 -69
- package/docs/engine.md +414 -0
- package/docs/point.md +134 -0
- package/package.json +33 -6
- package/src/cli.js +994 -0
- package/src/engine.js +657 -0
- package/src/point.js +116 -0
- package/src/tty.js +295 -0
- package/src/version.js +2 -0
- package/.eslintrc.yaml +0 -68
- package/engine.js +0 -535
- package/jsconfig.json +0 -8
- package/tty.js +0 -202
package/CHANGELOG.md
CHANGED
|
@@ -1,34 +1,85 @@
|
|
|
1
1
|
# @slugbugblue/trax
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.8.0 - 2022-04-08
|
|
4
|
+
|
|
5
|
+
- Breaking change: `playMove()` now takes the _next_ move number instead of the
|
|
6
|
+
_last_ move number. It makes more sense to say "move number 1 is @0/" than to
|
|
7
|
+
say "the move following move number 0 is @0/".
|
|
8
|
+
- Added variant name info to the engine as `Trax.name[rules]` as well as
|
|
9
|
+
`trax.name`
|
|
10
|
+
- Restructured the repo to handle additional files, creating `src` and `hooks`
|
|
11
|
+
folders
|
|
12
|
+
- Added a command-line interface (CLI) `cli.js` which npm will install using the
|
|
13
|
+
alias `trax`
|
|
14
|
+
- The CLI usage is self-documenting; run `trax help` to get started
|
|
15
|
+
- Initial commands available: `delete`, `export`, `help`, `import`, `list`,
|
|
16
|
+
`new`, `play`, `select`, `try`, `undo`, `view`
|
|
17
|
+
|
|
18
|
+
## 0.7.0 - 2022-03-28
|
|
19
|
+
|
|
20
|
+
- Fixed a bug when including extra characters in a starting notation
|
|
21
|
+
- Added regression tests to detect/prevent this bug in the future
|
|
22
|
+
|
|
23
|
+
## 0.6.0 - 2022-02-13
|
|
24
|
+
|
|
25
|
+
- Completed documentation for `engine.js` at [docs/engine.md](docs/engine.md)
|
|
26
|
+
- `x` and `y` locations are now handled in a `Point` class
|
|
27
|
+
- Renamed `tentativeIcon()` to `dropsIcon()`
|
|
28
|
+
|
|
29
|
+
## 0.5.0 - 2022-01-29
|
|
30
|
+
|
|
31
|
+
This code base is now using [`xo`](https://github.com/xojs/xo) for style and
|
|
32
|
+
[`ava`](https://github.com/avajs/ava) for testing. Should be no functional
|
|
33
|
+
changes, but a lot of code was updated, including the names of all functions and
|
|
34
|
+
variables from snake_case to camelCase.
|
|
35
|
+
|
|
36
|
+
## 0.4.0 - 2022-01-17
|
|
37
|
+
|
|
38
|
+
- Testing coverage of `engine.js` is now at 100%
|
|
39
|
+
- Testing revealed a few bugs, which are now fixed
|
|
40
|
+
- The name and signature for provisional move handling, which was broken, has
|
|
41
|
+
been changed. It is now called `provisional_moves()` and takes three
|
|
42
|
+
arguments:
|
|
43
|
+
|
|
44
|
+
- `from`: the normalized position code of the board before the move
|
|
45
|
+
- `to`: the normalized position code of the board after the move
|
|
46
|
+
- `via`: the move notation to go from `from` to `to`
|
|
47
|
+
|
|
48
|
+
### 0.3.1 - 2022-01-07
|
|
49
|
+
|
|
50
|
+
- Make a faster implementation of `trax.possible_locations()`
|
|
51
|
+
- Display updates for tentative moves
|
|
52
|
+
|
|
53
|
+
## 0.3.0 - 2021-12-29
|
|
4
54
|
|
|
5
55
|
Display a tentative move on the screen
|
|
6
56
|
|
|
7
|
-
|
|
8
|
-
|
|
57
|
+
- Add `trax.tentative_icon()` function
|
|
58
|
+
- `tty.display()` now accepts a tentative move
|
|
9
59
|
|
|
10
|
-
## 0.2.0
|
|
60
|
+
## 0.2.0 - 2021-12-28
|
|
11
61
|
|
|
12
62
|
Breaking changes:
|
|
13
63
|
|
|
14
|
-
|
|
15
|
-
|
|
64
|
+
- Converted from CommonJS to ESM
|
|
65
|
+
- `trax.normalized` now prepends turn information to the string
|
|
16
66
|
|
|
17
67
|
More convenience:
|
|
18
68
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
69
|
+
- `trax.color`: the color of the player whose turn it is
|
|
70
|
+
- `Trax.color_of[num]`: go from player number to color
|
|
71
|
+
- `Trax.player_num[color]`: or from color to player number
|
|
72
|
+
- `Trax.other[color]`: easily switch from 'w' to 'b' and back
|
|
23
73
|
|
|
24
|
-
## 0.1.0
|
|
74
|
+
## 0.1.0 - 2021-12-26
|
|
25
75
|
|
|
26
76
|
Initial release:
|
|
27
77
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
78
|
+
- engine.js
|
|
79
|
+
|
|
80
|
+
- create a new Trax game with `trax = new Trax()`
|
|
81
|
+
- play one move at a time with `trax.play('@0/')`
|
|
82
|
+
- ... etc
|
|
32
83
|
|
|
33
|
-
|
|
34
|
-
|
|
84
|
+
- tty.js
|
|
85
|
+
- display a game with `tty.display(trax)`
|
package/README.md
CHANGED
|
@@ -4,29 +4,101 @@ Trax game-playing engine and etc.
|
|
|
4
4
|
|
|
5
5
|
## Description
|
|
6
6
|
|
|
7
|
-
Trax is a two-player boardless board game invented by David Smith.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
see the official website at [traxgame.com][traxgame].
|
|
7
|
+
Trax is a two-player boardless board game invented by David Smith. For more
|
|
8
|
+
information about Trax, including its rules and history, see the official
|
|
9
|
+
website at [traxgame.com][traxgame].
|
|
11
10
|
|
|
12
|
-
This goal of this javascript project
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
This goal of this javascript project is to allow Trax to be played
|
|
12
|
+
programmatically. It can be used as an engine in a web browser, for example at
|
|
13
|
+
[slugbugblue.com][sbb]; or in nodejs, for example by using the `trax` CLI
|
|
14
|
+
provided as part of this project.
|
|
15
|
+
|
|
16
|
+
The Trax engine now enjoys automated testing with 100% code coverage. Any future
|
|
17
|
+
changes to the engine should meet the same standard.
|
|
16
18
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
19
21
|
```bash
|
|
22
|
+
# Install into a javascript project
|
|
20
23
|
npm install @slugbugblue/trax
|
|
24
|
+
|
|
25
|
+
# Or install globally to use the trax CLI
|
|
26
|
+
npm install -g @slugbugblue/trax
|
|
21
27
|
```
|
|
22
28
|
|
|
23
|
-
## Usage
|
|
29
|
+
## CLI Usage
|
|
30
|
+
|
|
31
|
+
The command-line interface is provided as `trax`, available in your path if
|
|
32
|
+
installed globally, or in the `node_modules/.bin` directory and runnable using
|
|
33
|
+
`npx trax` if installed locally.
|
|
34
|
+
|
|
35
|
+
The CLI can be used interactively by passing the `--interactive` or `-i` flag.
|
|
36
|
+
When run interactively, you can avoid worries about the need to escape certain
|
|
37
|
+
characters from the shell, and it can be easier to run multiple commands back to
|
|
38
|
+
back.
|
|
39
|
+
|
|
40
|
+
Help is available for the CLI through the use of the `help` command. Type
|
|
41
|
+
`trax help` to see a list of the available commands, and `trax help play` to see
|
|
42
|
+
information about the `play` command. Aliases and abbreviations are provided to
|
|
43
|
+
minimize typing and to try to avoid the requirement of memorizing the commands.
|
|
44
|
+
For example, the `list` command has an alias of `ls`, and the `select` command
|
|
45
|
+
can be activated using `#`.
|
|
46
|
+
|
|
47
|
+
When you first launch the CLI, you can create a new game using the `new`
|
|
48
|
+
command, and then enter moves for that game using `play`. Since `play` is likely
|
|
49
|
+
to be the most common command used, you can simply omit the command name. For
|
|
50
|
+
example, at the interactive prompt, entering `@0/` is the same as if you had
|
|
51
|
+
entered `play 1. @0/`.
|
|
52
|
+
|
|
53
|
+
Multiple games can be started at once, and the CLI will remember the currently
|
|
54
|
+
active game and apply future actions to that game. Each game will retain its
|
|
55
|
+
`#id` number until it is deleted, and you can use that number to switch between
|
|
56
|
+
games. For example, to make game #1 active, enter `select 1` or `select #1` or
|
|
57
|
+
simply `#1` at the interactive prompt.
|
|
58
|
+
|
|
59
|
+
For ease of working at the command line, the symbols used as the last character
|
|
60
|
+
of the Trax notation can optionally be replaced with letters. Use `s` for slash
|
|
61
|
+
symbol (`/`), `b` for backslash (`\`), and `p` for plus (`+`). While there is no
|
|
62
|
+
need to escape at the interactive prompt, these substitutions will be avilable
|
|
63
|
+
there as well.
|
|
64
|
+
|
|
65
|
+
The CLI uses standard Windows and Linux [XDG][xdg] file locations as provided by
|
|
66
|
+
the [env-paths library][env-path], with current uses being the `config` and
|
|
67
|
+
`data` folders.
|
|
68
|
+
|
|
69
|
+
Examples:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
# Start a new Trax game with Chad playing as white
|
|
73
|
+
> trax new Chad vs
|
|
74
|
+
|
|
75
|
+
# Start a new Loop Trax game with Chad playing as black
|
|
76
|
+
> trax new loop vs Chad
|
|
77
|
+
|
|
78
|
+
# Start a new 8x8 Trax game with Chad as white and Another Player as black
|
|
79
|
+
> trax new 8x8 Chad vs Another Player
|
|
24
80
|
|
|
25
|
-
|
|
26
|
-
|
|
81
|
+
# Switch back to the first game. Note the quoting required at the command line.
|
|
82
|
+
# This would not be necessary when running at the interactive prompt.
|
|
83
|
+
> trax '#1'
|
|
84
|
+
|
|
85
|
+
# Play two moves, using full notation
|
|
86
|
+
> trax play 1. @0/ 2. A0/
|
|
87
|
+
|
|
88
|
+
# Two more moves, using short notation and symbol substitution
|
|
89
|
+
# B2/ => b2s and A0\ => a0b
|
|
90
|
+
> trax b2s a0b
|
|
91
|
+
|
|
92
|
+
# See the status of all games
|
|
93
|
+
> trax ls
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API Usage
|
|
97
|
+
|
|
98
|
+
The main Trax engine is provided as `engine.js`, which can be used as follows:
|
|
27
99
|
|
|
28
100
|
```javascript
|
|
29
|
-
import Trax from '@slugbugblue/trax'
|
|
101
|
+
import { Trax } from '@slugbugblue/trax'
|
|
30
102
|
|
|
31
103
|
// default constructor gives you a Trax game
|
|
32
104
|
let trax = new Trax()
|
|
@@ -43,90 +115,72 @@ let puzzle = new Trax('trax', '@0/ a0\\ @2/')
|
|
|
43
115
|
puzzle.play('@2\\')
|
|
44
116
|
```
|
|
45
117
|
|
|
46
|
-
|
|
47
|
-
until I get around to documenting the functionality.
|
|
118
|
+
For specifics, see the [engine.js documentation][engine-docs].
|
|
48
119
|
|
|
49
120
|
## Roadmap
|
|
50
121
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* Bot for solo games (?)
|
|
55
|
-
* Puzzles
|
|
122
|
+
- Game position analysis
|
|
123
|
+
- Bot
|
|
124
|
+
- Puzzles
|
|
56
125
|
|
|
57
126
|
## Support
|
|
58
127
|
|
|
59
|
-
This project is built by [Chad Transtrum][ctrans]
|
|
60
|
-
|
|
61
|
-
Issues can be opened on the
|
|
62
|
-
[gitlab project page][repo].
|
|
128
|
+
This project is built by [Chad Transtrum][ctrans] for [slugbugblue.com][sbb].
|
|
129
|
+
Issues can be opened on the [gitlab project page][repo].
|
|
63
130
|
|
|
64
131
|
## Contributing
|
|
65
132
|
|
|
66
|
-
Contributions are welcome.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
I would also like to extend a huge heartfelt appreciation
|
|
84
|
-
to the magnanimous [Donald G. Bailey][dgb],
|
|
85
|
-
who, through his excellent [book][traxbook],
|
|
86
|
-
taught me the basics (and more!) of Trax.
|
|
87
|
-
I found him always ready to share his insights
|
|
88
|
-
on the mechanics of the game,
|
|
89
|
-
as well as various approaches to encoding its complexities.
|
|
90
|
-
His undeserved kindness
|
|
91
|
-
and infinite patience
|
|
92
|
-
in indulging my many questions
|
|
93
|
-
can never be repaid.
|
|
133
|
+
Contributions are welcome. Ideally in the form of pull requests, but feel free
|
|
134
|
+
to open an issue with a bug report or a suggestion as well.
|
|
135
|
+
|
|
136
|
+
## Acknowledgments
|
|
137
|
+
|
|
138
|
+
Many thanks to the late David Smith for coming up with the idea of Trax and for
|
|
139
|
+
his generosity in allowing me to add the game to [GoldToken.com][goldtoken].
|
|
140
|
+
|
|
141
|
+
Thanks to his widow Colleen Foley-Smith for extending that courtesy to allow me
|
|
142
|
+
to include Trax on [slugbugblue.com][sbb] as well.
|
|
143
|
+
|
|
144
|
+
I would also like to extend a huge heartfelt appreciation to the magnanimous
|
|
145
|
+
[Donald G. Bailey][dgb], who, through his excellent [book][traxbook], taught me
|
|
146
|
+
the basics (and more!) of Trax. I found him always ready to share his insights
|
|
147
|
+
on the mechanics of the game, as well as various approaches to encoding its
|
|
148
|
+
complexities. His undeserved kindness and infinite patience in indulging my many
|
|
149
|
+
questions can never be repaid.
|
|
94
150
|
|
|
95
151
|
## License
|
|
96
152
|
|
|
97
|
-
Copyright
|
|
153
|
+
Copyright 2019-2022 Chad Transtrum
|
|
98
154
|
|
|
99
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
You may obtain a copy of the License at
|
|
155
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
156
|
+
the files in this project except in compliance with the License. You may obtain
|
|
157
|
+
a copy of the License at
|
|
103
158
|
|
|
104
|
-
|
|
159
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
105
160
|
|
|
106
|
-
Unless required by applicable law or agreed to in writing, software
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
limitations under the License.
|
|
161
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
162
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
163
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
164
|
+
specific language governing permissions and limitations under the License.
|
|
111
165
|
|
|
112
166
|
## Trax rules copyright
|
|
113
167
|
|
|
114
|
-
In the United States, game mechanics
|
|
168
|
+
In the United States, game mechanics are not eligible for coyright protection;
|
|
115
169
|
however, the specific wording of game rules does fall under copyright law.
|
|
116
170
|
|
|
117
171
|
The official rules for Trax are found at http://traxgame.com/about_rules.php.
|
|
118
172
|
|
|
119
|
-
As Trax is a proprietary game,
|
|
120
|
-
|
|
121
|
-
of David Smith and heirs,
|
|
122
|
-
and are not to be used without permission.
|
|
123
|
-
|
|
124
|
-
|
|
173
|
+
As Trax is a proprietary game, these rules are the intellectual property of
|
|
174
|
+
David Smith and heirs, and are not to be used without permission.
|
|
125
175
|
|
|
126
176
|
[ctrans]: mailto:chad@transtrum.net
|
|
127
177
|
[dgb]: mailto:donald@traxgame.com
|
|
178
|
+
[engine-docs]: docs/engine.md
|
|
179
|
+
[env-path]: https://www.npmjs.com/package/env-paths
|
|
128
180
|
[goldtoken]: https://goldtoken.com/
|
|
129
181
|
[repo]: https://gitlab.com/slugbugblue/trax
|
|
130
182
|
[sbb]: https://slugbugblue.com/
|
|
131
183
|
[traxbook]: http://traxgame.com/shop_book.php
|
|
132
184
|
[traxgame]: http://traxgame.com/
|
|
185
|
+
[xdg]:
|
|
186
|
+
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|