@slugbugblue/trax 0.23.0 → 1.0.1

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,5 +1,17 @@
1
1
  # @slugbugblue/trax
2
2
 
3
+ ## 1.0.1 - 2026-02-20
4
+
5
+ - Add references for ambient typescript definitions
6
+
7
+ ## 1.0.0 - 2025-11-04
8
+
9
+ v1 release:
10
+
11
+ - Update dev dependencies to latest versions
12
+ - Fix xo complaints
13
+ - No other code changes
14
+
3
15
  ## 0.23.0 - 2023-03-28
4
16
 
5
17
  Release candidate
@@ -18,7 +30,6 @@ Finalize work with jsdoc/typescript
18
30
  ## 0.21.0 - 2023-03-12
19
31
 
20
32
  - Update the analysis engine to be more lazy
21
-
22
33
  - The LRU cache is more likely to have a hit because it no longer separates
23
34
  validated from unvalidated analyses
24
35
  - Suggestions are much faster because it now skips validations for low-scoring
@@ -43,23 +54,19 @@ Finalize work with jsdoc/typescript
43
54
  ## 0.18.0 - 2023-02-05
44
55
 
45
56
  - Analysis improvements:
46
-
47
57
  - Add `count.b(level)` and `count.w(level)` methods to an analysis to quickly
48
58
  count the number of threats at a given level
49
59
  - Remove faulty threats from an analysis
50
60
  - Add additional threats for more puzzle solving mojo
51
61
 
52
62
  - Development environment enhancements:
53
-
54
63
  - Added an initial benchmarking framework with puzzle benchmarks so far
55
64
  - Added husky pre-commit hook to ensure npm test is run before a commit
56
65
 
57
66
  - CLI improvements:
58
-
59
67
  - Puzzle information is now stored as notes, to make it searchable
60
68
 
61
69
  - More puzzles:
62
-
63
70
  - Martin M. S. Pedersen contributed eleven new puzzles
64
71
 
65
72
  ## 0.17.0 - 2022-12-29
@@ -69,7 +76,6 @@ Finalize work with jsdoc/typescript
69
76
  ## 0.16.0 - 2022-12-27
70
77
 
71
78
  - Added a `notes` command to the CLI to add comments to a game
72
-
73
79
  - all comments are included in the output generated by the `export` command
74
80
  - the latest comment can be used as a text filter by the `list` command
75
81
  - the latest comment is displayed by the `view` and `list` commands
@@ -79,17 +85,14 @@ Finalize work with jsdoc/typescript
79
85
  ## 0.15.0 - 2022-12-14
80
86
 
81
87
  - Added shared `puzzles` commands to the CLI:
82
-
83
88
  - `trax ls puzzles`: see all the puzzles
84
89
  - `trax new puzzle`: start a new puzzle
85
90
 
86
91
  - Puzzle improvements:
87
-
88
92
  - Adjust puzzle category levels for harder puzzles
89
93
  - Add multiple hints when the puzzle can be solved multiple ways
90
94
 
91
95
  - Analysis improvements:
92
-
93
96
  - Analysis suggestions now "solve" all tough puzzles
94
97
  - Reworked threats to be more precise
95
98
  - Reworked scoring to add more nuance
@@ -97,7 +100,6 @@ Finalize work with jsdoc/typescript
97
100
  ## 0.14.0 - 2022-12-05
98
101
 
99
102
  - Added `puzzles` to the CLI:
100
-
101
103
  - `trax puzzles ls`: see all the puzzles
102
104
  - `trax puzzle new`: start a new puzzle
103
105
 
@@ -108,13 +110,11 @@ Finalize work with jsdoc/typescript
108
110
  ## 0.13.0 - 2022-11-25
109
111
 
110
112
  - Add move suggestions to `analyst.js` for CLI and bot use
111
-
112
113
  - use `suggest(trax)` to get a suggestion for the current position
113
114
  - added the `suggest` CLI command for quick access to a random suggestion
114
115
 
115
116
  - Use font glyphs for text bubbles in `tty.js` only if one of the following
116
117
  environment variables are defined and non-empty:
117
-
118
118
  - `NERDFONT`, `POWERLINE`, `P9K_TTY`, `P9K_SSH`
119
119
 
120
120
  - Begin work on documenting the javascript files using jsdoc, with the initial
@@ -131,7 +131,6 @@ Finalize work with jsdoc/typescript
131
131
  `play()`. `playMove()` is no longer available.
132
132
  - Add a new function `playMoves()` to submit multiple moves at once
133
133
  - Initial work on `analyst.js`, with documentation and a start on tests
134
-
135
134
  - use `analyze(trax)` to perform an analysis
136
135
  - added the `analyze` CLI command to see an analysis
137
136
 
@@ -191,7 +190,6 @@ variables from snake_case to camelCase.
191
190
  - The name and signature for provisional move handling, which was broken, has
192
191
  been changed. It is now called `provisional_moves()` and takes three
193
192
  arguments:
194
-
195
193
  - `from`: the normalized position code of the board before the move
196
194
  - `to`: the normalized position code of the board after the move
197
195
  - `via`: the move notation to go from `from` to `to`
@@ -227,7 +225,6 @@ More convenience:
227
225
  Initial release:
228
226
 
229
227
  - engine.js
230
-
231
228
  - create a new Trax game with `trax = new Trax()`
232
229
  - play one move at a time with `trax.play('@0/')`
233
230
  - ... etc
package/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright © 2021-2023 Chad Transtrum
189
+ Copyright © 2019-2026 Chad Transtrum
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -71,7 +71,7 @@ Trax][gnutrax] for over two decades, and has a lot of expertise in this area.
71
71
 
72
72
  ## License
73
73
 
74
- Copyright 2019-2023 Chad Transtrum
74
+ Copyright 2019-2026 Chad Transtrum
75
75
 
76
76
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
77
77
  the files in this project except in compliance with the License. You may obtain
package/docs/engine.md CHANGED
@@ -75,7 +75,6 @@ trax = new Trax(rules, moves, id)
75
75
  that if an array is used, each item in the array should be a notation string.
76
76
  If a string is used instead, it is permissible to include the move numbers of
77
77
  each move as well. As an example, the following are equivalent:
78
-
79
78
  - `['@0/', '@1+', 'B0\\']`
80
79
  - `'1. @0/ 2. @1+ 3. B0\\'`
81
80
  - `@0/ @1+ b0\\`
@@ -414,7 +413,7 @@ tie.
414
413
 
415
414
  ## License
416
415
 
417
- Copyright 2019-2023 Chad Transtrum
416
+ Copyright 2019-2026 Chad Transtrum
418
417
 
419
418
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
420
419
  the files in this project except in compliance with the License. You may obtain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slugbugblue/trax",
3
- "version": "0.23.0",
3
+ "version": "1.0.1",
4
4
  "description": "Trax game engine",
5
5
  "keywords": [
6
6
  "trax",
@@ -19,25 +19,25 @@
19
19
  },
20
20
  "repository": "gitlab:slugbugblue/trax",
21
21
  "scripts": {
22
- "genversion": "genversion --es6 src/version.js",
22
+ "genversion": "genversion --esm src/version.js",
23
23
  "git-add": "git add src/version.js",
24
24
  "test": "xo && c8 ava",
25
- "prepare": "husky install",
25
+ "prepare": "[ -n \"$CI\" ] || husky",
26
26
  "preversion": "npm test",
27
27
  "version": "npm run genversion ; npm run git-add",
28
- "postversion": "git push && git push --tags && npm publish"
28
+ "postversion": "git push && git push --tags"
29
29
  },
30
30
  "dependencies": {
31
31
  "@slugbugblue/lru": "^1.0.0",
32
32
  "@slugbugblue/point": "^1.0.0"
33
33
  },
34
34
  "devDependencies": {
35
- "ava": "^5.1.0",
36
- "c8": "^7.11.0",
35
+ "ava": "^6.4.1",
36
+ "c8": "^10.1.3",
37
37
  "genversion": "^3.0.2",
38
- "husky": "^8.0.3",
39
- "prettier": "^2.6.1",
40
- "xo": "0.*"
38
+ "husky": "^9.1.7",
39
+ "prettier": "^3.6.2",
40
+ "xo": "^1.2.3"
41
41
  },
42
42
  "type": "module",
43
43
  "engines": {
@@ -60,6 +60,7 @@
60
60
  },
61
61
  "xo": {
62
62
  "prettier": true,
63
+ "space": true,
63
64
  "rules": {
64
65
  "curly": [
65
66
  "error",
package/src/engine.js CHANGED
@@ -1,9 +1,11 @@
1
1
  /** Trax engine.
2
- * @copyright 2019-2022
2
+ * @copyright 2019-2026
3
3
  * @author Chad Transtrum <chad@transtrum.net>
4
4
  * @license Apache-2.0
5
5
  */
6
6
 
7
+ /// <reference path="./types.d.ts" />
8
+
7
9
  import { Point } from '@slugbugblue/point'
8
10
 
9
11
  // Fun trax helper constants
@@ -110,50 +112,42 @@ const addBlank = (code) => {
110
112
  * @returns {number} - the actual length of the row
111
113
  */
112
114
  const codeRowLength = (row) =>
113
- row.replace(/\d/g, (n) => '.'.repeat(Number(n) + 1)).length
115
+ row.replaceAll(/\d/g, (n) => '.'.repeat(Number(n) + 1)).length
114
116
 
115
117
  // This is where the magic happens
116
118
  /** A digital representation of a Trax game. */
117
119
  export class Trax {
118
120
  // Static class properties
119
-
120
121
  /** @readonly @type {Record<TraxVariant, string>} */
121
122
  static names = {
122
123
  trax: 'Trax',
123
124
  traxloop: 'Loop Trax',
124
125
  trax8: '8x8 Trax',
125
126
  }
126
-
127
127
  /** @readonly */
128
128
  static variants = new Set(Object.keys(this.names)) // Known variants
129
-
130
129
  // Static class methods
131
-
132
130
  /** Create an x,y Point object with special functions.
133
131
  * @arg {number|PointLike} x - either the x value, or an object with x,y keys
134
132
  * @arg {number} [y] - if x is a number, y must be provided as well
135
133
  * @returns {Point} a new Point object
136
134
  */
137
135
  static point = (x, y) => new Point(x, y)
138
-
139
136
  /** Given a player number, get the color.
140
137
  * @arg {number} playerNumber - the player number, 1 or 2
141
138
  * @returns {Color} the color of that player, w or b
142
139
  */
143
- static colorOf = (playerNumber) => ({ 1: 'w', 2: 'b' }[playerNumber])
144
-
140
+ static colorOf = (playerNumber) => ({ 1: 'w', 2: 'b' })[playerNumber]
145
141
  /** Given a color, get the player number.
146
142
  * @arg {string} color - the color, w or b
147
143
  * @returns {number} the player number, 1 or 2
148
144
  */
149
- static playerNumber = (color) => ({ b: 2, w: 1 }[color])
150
-
145
+ static playerNumber = (color) => ({ b: 2, w: 1 })[color]
151
146
  /** Given a color, get the other color.
152
147
  * @arg {string} color - the color, w or b
153
148
  * @returns {Color} the other color, b or w
154
149
  */
155
- static other = (color) => ({ b: 'w', w: 'b' }[color])
156
-
150
+ static other = (color) => ({ b: 'w', w: 'b' })[color]
157
151
  /** Encode a numeric column number into the Trax notation column letter.
158
152
  * @arg {number} col - the colum number, with 0 just to the left of the tiles
159
153
  * @returns {string} the encoded column letter
@@ -168,7 +162,6 @@ export class Trax {
168
162
 
169
163
  return n || '@'
170
164
  }
171
-
172
165
  /** Decode a Trax notation column letter back to a number.
173
166
  * @arg {string} col - the Trax column letter
174
167
  * @returns {number} the column number
@@ -626,12 +619,12 @@ export class Trax {
626
619
  moves = moves.join(' ')
627
620
  }
628
621
 
629
- moves = moves.replace(/\n/g, ' ').split(/\s+/)
622
+ moves = moves.replaceAll('\n', ' ').split(/\s+/)
630
623
 
631
624
  let moveNumber = 0
632
625
  for (const move of moves) {
633
626
  if (moveNumberRegex.test(move)) {
634
- moveNumber = Number(move.replace(/\D/g, ''))
627
+ moveNumber = Number(move.replaceAll(/\D/g, ''))
635
628
  }
636
629
 
637
630
  if (notationRegex.test(move)) {
@@ -663,7 +656,7 @@ export class Trax {
663
656
  /** An array of the moves made in the game. */
664
657
  get moves() {
665
658
  return this.notation
666
- .replace(/\n/g, ' ')
659
+ .replaceAll('\n', ' ')
667
660
  .split(' ')
668
661
  .filter((n) => Boolean(n) && !n.endsWith('.'))
669
662
  }
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.23.0'
2
+ export const version = '1.0.1'