@slugbugblue/trax 0.5.0 → 0.9.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 CHANGED
@@ -1,51 +1,91 @@
1
1
  # @slugbugblue/trax
2
2
 
3
+ ## 0.9.0 - 2022-04-24
4
+
5
+ - Added tab-completion and completion preview code to the interactive CLI
6
+ - Restructured the CLI by moving most commands to their own file
7
+ - Changed the `view` CLI command to optionally examine previous moves
8
+
9
+ ## 0.8.0 - 2022-04-08
10
+
11
+ - Breaking change: `playMove()` now takes the _next_ move number instead of the
12
+ _last_ move number. It makes more sense to say "move number 1 is @0/" than to
13
+ say "the move following move number 0 is @0/".
14
+ - Added variant name info to the engine as `Trax.name[rules]` as well as
15
+ `trax.name`
16
+ - Restructured the repo to handle additional files, creating `src` and `hooks`
17
+ folders
18
+ - Added a command-line interface (CLI) `cli.js` which npm will install using the
19
+ alias `trax`
20
+ - The CLI usage is self-documenting; run `trax help` to get started
21
+ - Initial commands available: `delete`, `export`, `help`, `import`, `list`,
22
+ `new`, `play`, `select`, `try`, `undo`, `view`
23
+
24
+ ## 0.7.0 - 2022-03-28
25
+
26
+ - Fixed a bug when including extra characters in a starting notation
27
+ - Added regression tests to detect/prevent this bug in the future
28
+
29
+ ## 0.6.0 - 2022-02-13
30
+
31
+ - Completed documentation for `engine.js` at [docs/engine.md](docs/engine.md)
32
+ - `x` and `y` locations are now handled in a `Point` class
33
+ - Renamed `tentativeIcon()` to `dropsIcon()`
34
+
35
+ ## 0.5.0 - 2022-01-29
36
+
37
+ This code base is now using [`xo`](https://github.com/xojs/xo) for style and
38
+ [`ava`](https://github.com/avajs/ava) for testing. Should be no functional
39
+ changes, but a lot of code was updated, including the names of all functions and
40
+ variables from snake_case to camelCase.
41
+
3
42
  ## 0.4.0 - 2022-01-17
4
43
 
5
- * Testing coverage of `engine.js` is now at 100%
6
- * Testing revealed a few bugs, which are now fixed
7
- * The name and signature for provisional move handling,
8
- which was broken, has been changed. It is now called
9
- `provisional_moves()` and takes three arguments:
44
+ - Testing coverage of `engine.js` is now at 100%
45
+ - Testing revealed a few bugs, which are now fixed
46
+ - The name and signature for provisional move handling, which was broken, has
47
+ been changed. It is now called `provisional_moves()` and takes three
48
+ arguments:
10
49
 
11
- * `from`: the normalized position code of the board before the move
12
- * `to`: the normalized position code of the board after the move
13
- * `via`: the move notation to go from `from` to `to`
50
+ - `from`: the normalized position code of the board before the move
51
+ - `to`: the normalized position code of the board after the move
52
+ - `via`: the move notation to go from `from` to `to`
14
53
 
15
54
  ### 0.3.1 - 2022-01-07
16
55
 
17
- * Make a faster implementation of `trax.possible_locations()`
18
- * Display updates for tentative moves
56
+ - Make a faster implementation of `trax.possible_locations()`
57
+ - Display updates for tentative moves
19
58
 
20
59
  ## 0.3.0 - 2021-12-29
21
60
 
22
61
  Display a tentative move on the screen
23
62
 
24
- * Add `trax.tentative_icon()` function
25
- * `tty.display()` now accepts a tentative move
63
+ - Add `trax.tentative_icon()` function
64
+ - `tty.display()` now accepts a tentative move
26
65
 
27
66
  ## 0.2.0 - 2021-12-28
28
67
 
29
68
  Breaking changes:
30
69
 
31
- * Converted from CommonJS to ESM
32
- * `trax.normalized` now prepends turn information to the string
70
+ - Converted from CommonJS to ESM
71
+ - `trax.normalized` now prepends turn information to the string
33
72
 
34
73
  More convenience:
35
74
 
36
- * `trax.color`: the color of the player whose turn it is
37
- * `Trax.color_of[num]`: go from player number to color
38
- * `Trax.player_num[color]`: or from color to player number
39
- * `Trax.other[color]`: easily switch from 'w' to 'b' and back
75
+ - `trax.color`: the color of the player whose turn it is
76
+ - `Trax.color_of[num]`: go from player number to color
77
+ - `Trax.player_num[color]`: or from color to player number
78
+ - `Trax.other[color]`: easily switch from 'w' to 'b' and back
40
79
 
41
80
  ## 0.1.0 - 2021-12-26
42
81
 
43
82
  Initial release:
44
83
 
45
- * engine.js
46
- * create a new Trax game with `trax = new Trax()`
47
- * play one move at a time with `trax.play('@0/')`
48
- * ... etc
84
+ - engine.js
85
+
86
+ - create a new Trax game with `trax = new Trax()`
87
+ - play one move at a time with `trax.play('@0/')`
88
+ - ... etc
49
89
 
50
- * tty.js
51
- * display a game with `tty.display(trax)`
90
+ - tty.js
91
+ - display a game with `tty.display(trax)`
package/README.md CHANGED
@@ -4,33 +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
- For more information about Trax,
9
- including its rules and history,
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
- is to allow Trax to be played programmatically.
14
- It can be used as an engine in a web browser
15
- or in nodejs.
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.
16
15
 
17
- The Trax engine now enjoys automated testing
18
- with 100% code coverage. Any future changes
19
- to the engine should meet the same standard.
16
+ The Trax engine now enjoys automated testing with 100% code coverage. Any future
17
+ changes to the engine should meet the same standard.
20
18
 
21
19
  ## Installation
22
20
 
23
21
  ```bash
22
+ # Install into a javascript project
24
23
  npm install @slugbugblue/trax
24
+
25
+ # Or install globally to use the trax CLI
26
+ npm install -g @slugbugblue/trax
27
+ ```
28
+
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
80
+
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
25
94
  ```
26
95
 
27
- ## Usage
96
+ ## API Usage
28
97
 
29
- The main Trax engine is provided as `engine.js`,
30
- which can be used as follows:
98
+ The main Trax engine is provided as `engine.js`, which can be used as follows:
31
99
 
32
100
  ```javascript
33
- import Trax from '@slugbugblue/trax'
101
+ import { Trax } from '@slugbugblue/trax'
34
102
 
35
103
  // default constructor gives you a Trax game
36
104
  let trax = new Trax()
@@ -47,89 +115,72 @@ let puzzle = new Trax('trax', '@0/ a0\\ @2/')
47
115
  puzzle.play('@2\\')
48
116
  ```
49
117
 
50
- Explore the file `engine.js` for more information
51
- until I get around to documenting the functionality.
118
+ For specifics, see the [engine.js documentation][engine-docs].
52
119
 
53
120
  ## Roadmap
54
121
 
55
- * Documentation
56
- * Command line interface
57
- * Bot for solo games (?)
58
- * Puzzles
122
+ - Game position analysis
123
+ - Bot
124
+ - Puzzles
59
125
 
60
126
  ## Support
61
127
 
62
- This project is built by [Chad Transtrum][ctrans]
63
- for [slugbugblue.com][sbb].
64
- Issues can be opened on the
65
- [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].
66
130
 
67
131
  ## Contributing
68
132
 
69
- Contributions are welcome.
70
- Ideally in the form of pull requests,
71
- but feel free to open an issue with a bug report
72
- or a suggestion as well.
73
-
74
- ## Authors and acknowledgment
75
-
76
- Many thanks to the late David Smith
77
- for coming up with the idea of Trax
78
- and for his generosity in allowing me to
79
- add the game to [GoldToken.com][goldtoken].
80
-
81
- Thanks to his widow Colleen Foley-Smith
82
- for extending that courtesy
83
- to allow me to include Trax on [slugbugblue.com][sbb]
84
- as well.
85
-
86
- I would also like to extend a huge heartfelt appreciation
87
- to the magnanimous [Donald G. Bailey][dgb],
88
- who, through his excellent [book][traxbook],
89
- taught me the basics (and more!) of Trax.
90
- I found him always ready to share his insights
91
- on the mechanics of the game,
92
- as well as various approaches to encoding its complexities.
93
- His undeserved kindness
94
- and infinite patience
95
- in indulging my many questions
96
- 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.
97
150
 
98
151
  ## License
99
152
 
100
153
  Copyright 2019-2022 Chad Transtrum
101
154
 
102
- Licensed under the Apache License, Version 2.0 (the "License");
103
- you may not use the files in this project
104
- except in compliance with the License.
105
- 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
106
158
 
107
- http://www.apache.org/licenses/LICENSE-2.0
159
+ http://www.apache.org/licenses/LICENSE-2.0
108
160
 
109
- Unless required by applicable law or agreed to in writing, software
110
- distributed under the License is distributed on an "AS IS" BASIS,
111
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112
- See the License for the specific language governing permissions and
113
- 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.
114
165
 
115
166
  ## Trax rules copyright
116
167
 
117
- In the United States, game mechanics may not be copyrighted;
168
+ In the United States, game mechanics are not eligible for coyright protection;
118
169
  however, the specific wording of game rules does fall under copyright law.
119
170
 
120
171
  The official rules for Trax are found at http://traxgame.com/about_rules.php.
121
172
 
122
- As Trax is a proprietary game,
123
- these rules are the intellectual property
124
- of David Smith and heirs,
125
- and are not to be used without permission.
126
-
127
-
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.
128
175
 
129
176
  [ctrans]: mailto:chad@transtrum.net
130
177
  [dgb]: mailto:donald@traxgame.com
178
+ [engine-docs]: docs/engine.md
179
+ [env-path]: https://www.npmjs.com/package/env-paths
131
180
  [goldtoken]: https://goldtoken.com/
132
181
  [repo]: https://gitlab.com/slugbugblue/trax
133
182
  [sbb]: https://slugbugblue.com/
134
183
  [traxbook]: http://traxgame.com/shop_book.php
135
184
  [traxgame]: http://traxgame.com/
185
+ [xdg]:
186
+ https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html