@slugbugblue/trax 0.23.0 → 1.0.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,5 +1,13 @@
1
1
  # @slugbugblue/trax
2
2
 
3
+ ## 1.0.0 - 2025-11-04
4
+
5
+ v1 release:
6
+
7
+ - Update dev dependencies to latest versions
8
+ - Fix xo complaints
9
+ - No other code changes
10
+
3
11
  ## 0.23.0 - 2023-03-28
4
12
 
5
13
  Release candidate
@@ -18,7 +26,6 @@ Finalize work with jsdoc/typescript
18
26
  ## 0.21.0 - 2023-03-12
19
27
 
20
28
  - Update the analysis engine to be more lazy
21
-
22
29
  - The LRU cache is more likely to have a hit because it no longer separates
23
30
  validated from unvalidated analyses
24
31
  - Suggestions are much faster because it now skips validations for low-scoring
@@ -43,23 +50,19 @@ Finalize work with jsdoc/typescript
43
50
  ## 0.18.0 - 2023-02-05
44
51
 
45
52
  - Analysis improvements:
46
-
47
53
  - Add `count.b(level)` and `count.w(level)` methods to an analysis to quickly
48
54
  count the number of threats at a given level
49
55
  - Remove faulty threats from an analysis
50
56
  - Add additional threats for more puzzle solving mojo
51
57
 
52
58
  - Development environment enhancements:
53
-
54
59
  - Added an initial benchmarking framework with puzzle benchmarks so far
55
60
  - Added husky pre-commit hook to ensure npm test is run before a commit
56
61
 
57
62
  - CLI improvements:
58
-
59
63
  - Puzzle information is now stored as notes, to make it searchable
60
64
 
61
65
  - More puzzles:
62
-
63
66
  - Martin M. S. Pedersen contributed eleven new puzzles
64
67
 
65
68
  ## 0.17.0 - 2022-12-29
@@ -69,7 +72,6 @@ Finalize work with jsdoc/typescript
69
72
  ## 0.16.0 - 2022-12-27
70
73
 
71
74
  - Added a `notes` command to the CLI to add comments to a game
72
-
73
75
  - all comments are included in the output generated by the `export` command
74
76
  - the latest comment can be used as a text filter by the `list` command
75
77
  - the latest comment is displayed by the `view` and `list` commands
@@ -79,17 +81,14 @@ Finalize work with jsdoc/typescript
79
81
  ## 0.15.0 - 2022-12-14
80
82
 
81
83
  - Added shared `puzzles` commands to the CLI:
82
-
83
84
  - `trax ls puzzles`: see all the puzzles
84
85
  - `trax new puzzle`: start a new puzzle
85
86
 
86
87
  - Puzzle improvements:
87
-
88
88
  - Adjust puzzle category levels for harder puzzles
89
89
  - Add multiple hints when the puzzle can be solved multiple ways
90
90
 
91
91
  - Analysis improvements:
92
-
93
92
  - Analysis suggestions now "solve" all tough puzzles
94
93
  - Reworked threats to be more precise
95
94
  - Reworked scoring to add more nuance
@@ -97,7 +96,6 @@ Finalize work with jsdoc/typescript
97
96
  ## 0.14.0 - 2022-12-05
98
97
 
99
98
  - Added `puzzles` to the CLI:
100
-
101
99
  - `trax puzzles ls`: see all the puzzles
102
100
  - `trax puzzle new`: start a new puzzle
103
101
 
@@ -108,13 +106,11 @@ Finalize work with jsdoc/typescript
108
106
  ## 0.13.0 - 2022-11-25
109
107
 
110
108
  - Add move suggestions to `analyst.js` for CLI and bot use
111
-
112
109
  - use `suggest(trax)` to get a suggestion for the current position
113
110
  - added the `suggest` CLI command for quick access to a random suggestion
114
111
 
115
112
  - Use font glyphs for text bubbles in `tty.js` only if one of the following
116
113
  environment variables are defined and non-empty:
117
-
118
114
  - `NERDFONT`, `POWERLINE`, `P9K_TTY`, `P9K_SSH`
119
115
 
120
116
  - Begin work on documenting the javascript files using jsdoc, with the initial
@@ -131,7 +127,6 @@ Finalize work with jsdoc/typescript
131
127
  `play()`. `playMove()` is no longer available.
132
128
  - Add a new function `playMoves()` to submit multiple moves at once
133
129
  - Initial work on `analyst.js`, with documentation and a start on tests
134
-
135
130
  - use `analyze(trax)` to perform an analysis
136
131
  - added the `analyze` CLI command to see an analysis
137
132
 
@@ -191,7 +186,6 @@ variables from snake_case to camelCase.
191
186
  - The name and signature for provisional move handling, which was broken, has
192
187
  been changed. It is now called `provisional_moves()` and takes three
193
188
  arguments:
194
-
195
189
  - `from`: the normalized position code of the board before the move
196
190
  - `to`: the normalized position code of the board after the move
197
191
  - `via`: the move notation to go from `from` to `to`
@@ -227,7 +221,6 @@ More convenience:
227
221
  Initial release:
228
222
 
229
223
  - engine.js
230
-
231
224
  - create a new Trax game with `trax = new Trax()`
232
225
  - play one move at a time with `trax.play('@0/')`
233
226
  - ... etc
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-2025 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slugbugblue/trax",
3
- "version": "0.23.0",
3
+ "version": "1.0.0",
4
4
  "description": "Trax game engine",
5
5
  "keywords": [
6
6
  "trax",
@@ -19,10 +19,10 @@
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": "husky",
26
26
  "preversion": "npm test",
27
27
  "version": "npm run genversion ; npm run git-add",
28
28
  "postversion": "git push && git push --tags && npm publish"
@@ -32,12 +32,12 @@
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
@@ -110,50 +110,42 @@ const addBlank = (code) => {
110
110
  * @returns {number} - the actual length of the row
111
111
  */
112
112
  const codeRowLength = (row) =>
113
- row.replace(/\d/g, (n) => '.'.repeat(Number(n) + 1)).length
113
+ row.replaceAll(/\d/g, (n) => '.'.repeat(Number(n) + 1)).length
114
114
 
115
115
  // This is where the magic happens
116
116
  /** A digital representation of a Trax game. */
117
117
  export class Trax {
118
118
  // Static class properties
119
-
120
119
  /** @readonly @type {Record<TraxVariant, string>} */
121
120
  static names = {
122
121
  trax: 'Trax',
123
122
  traxloop: 'Loop Trax',
124
123
  trax8: '8x8 Trax',
125
124
  }
126
-
127
125
  /** @readonly */
128
126
  static variants = new Set(Object.keys(this.names)) // Known variants
129
-
130
127
  // Static class methods
131
-
132
128
  /** Create an x,y Point object with special functions.
133
129
  * @arg {number|PointLike} x - either the x value, or an object with x,y keys
134
130
  * @arg {number} [y] - if x is a number, y must be provided as well
135
131
  * @returns {Point} a new Point object
136
132
  */
137
133
  static point = (x, y) => new Point(x, y)
138
-
139
134
  /** Given a player number, get the color.
140
135
  * @arg {number} playerNumber - the player number, 1 or 2
141
136
  * @returns {Color} the color of that player, w or b
142
137
  */
143
- static colorOf = (playerNumber) => ({ 1: 'w', 2: 'b' }[playerNumber])
144
-
138
+ static colorOf = (playerNumber) => ({ 1: 'w', 2: 'b' })[playerNumber]
145
139
  /** Given a color, get the player number.
146
140
  * @arg {string} color - the color, w or b
147
141
  * @returns {number} the player number, 1 or 2
148
142
  */
149
- static playerNumber = (color) => ({ b: 2, w: 1 }[color])
150
-
143
+ static playerNumber = (color) => ({ b: 2, w: 1 })[color]
151
144
  /** Given a color, get the other color.
152
145
  * @arg {string} color - the color, w or b
153
146
  * @returns {Color} the other color, b or w
154
147
  */
155
- static other = (color) => ({ b: 'w', w: 'b' }[color])
156
-
148
+ static other = (color) => ({ b: 'w', w: 'b' })[color]
157
149
  /** Encode a numeric column number into the Trax notation column letter.
158
150
  * @arg {number} col - the colum number, with 0 just to the left of the tiles
159
151
  * @returns {string} the encoded column letter
@@ -168,7 +160,6 @@ export class Trax {
168
160
 
169
161
  return n || '@'
170
162
  }
171
-
172
163
  /** Decode a Trax notation column letter back to a number.
173
164
  * @arg {string} col - the Trax column letter
174
165
  * @returns {number} the column number
@@ -626,12 +617,12 @@ export class Trax {
626
617
  moves = moves.join(' ')
627
618
  }
628
619
 
629
- moves = moves.replace(/\n/g, ' ').split(/\s+/)
620
+ moves = moves.replaceAll('\n', ' ').split(/\s+/)
630
621
 
631
622
  let moveNumber = 0
632
623
  for (const move of moves) {
633
624
  if (moveNumberRegex.test(move)) {
634
- moveNumber = Number(move.replace(/\D/g, ''))
625
+ moveNumber = Number(move.replaceAll(/\D/g, ''))
635
626
  }
636
627
 
637
628
  if (notationRegex.test(move)) {
@@ -663,7 +654,7 @@ export class Trax {
663
654
  /** An array of the moves made in the game. */
664
655
  get moves() {
665
656
  return this.notation
666
- .replace(/\n/g, ' ')
657
+ .replaceAll('\n', ' ')
667
658
  .split(' ')
668
659
  .filter((n) => Boolean(n) && !n.endsWith('.'))
669
660
  }
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.0'