@slugbugblue/trax 0.2.0 → 0.5.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.
File without changes
package/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ # @slugbugblue/trax
2
+
3
+ ## 0.4.0 - 2022-01-17
4
+
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:
10
+
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`
14
+
15
+ ### 0.3.1 - 2022-01-07
16
+
17
+ * Make a faster implementation of `trax.possible_locations()`
18
+ * Display updates for tentative moves
19
+
20
+ ## 0.3.0 - 2021-12-29
21
+
22
+ Display a tentative move on the screen
23
+
24
+ * Add `trax.tentative_icon()` function
25
+ * `tty.display()` now accepts a tentative move
26
+
27
+ ## 0.2.0 - 2021-12-28
28
+
29
+ Breaking changes:
30
+
31
+ * Converted from CommonJS to ESM
32
+ * `trax.normalized` now prepends turn information to the string
33
+
34
+ More convenience:
35
+
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
40
+
41
+ ## 0.1.0 - 2021-12-26
42
+
43
+ Initial release:
44
+
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
49
+
50
+ * tty.js
51
+ * display a game with `tty.display(trax)`
package/README.md CHANGED
@@ -14,6 +14,10 @@ is to allow Trax to be played programmatically.
14
14
  It can be used as an engine in a web browser
15
15
  or in nodejs.
16
16
 
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.
20
+
17
21
  ## Installation
18
22
 
19
23
  ```bash
@@ -26,11 +30,21 @@ The main Trax engine is provided as `engine.js`,
26
30
  which can be used as follows:
27
31
 
28
32
  ```javascript
29
- const Trax = require('@slugbugblue/trax')
33
+ import Trax from '@slugbugblue/trax'
30
34
 
35
+ // default constructor gives you a Trax game
31
36
  let trax = new Trax()
32
-
33
37
  trax.play('@0/')
38
+
39
+ // but you can also select Loop Trax
40
+ let loops = new Trax('traxloop')
41
+
42
+ // or 8x8 Trax
43
+ let tiny = new Trax('trax8')
44
+
45
+ // and the constructor lets you start with an initial set of moves
46
+ let puzzle = new Trax('trax', '@0/ a0\\ @2/')
47
+ puzzle.play('@2\\')
34
48
  ```
35
49
 
36
50
  Explore the file `engine.js` for more information
@@ -39,7 +53,6 @@ until I get around to documenting the functionality.
39
53
  ## Roadmap
40
54
 
41
55
  * Documentation
42
- * Test suite
43
56
  * Command line interface
44
57
  * Bot for solo games (?)
45
58
  * Puzzles
@@ -48,7 +61,7 @@ until I get around to documenting the functionality.
48
61
 
49
62
  This project is built by [Chad Transtrum][ctrans]
50
63
  for [slugbugblue.com][sbb].
51
- Issues can be opened on the
64
+ Issues can be opened on the
52
65
  [gitlab project page][repo].
53
66
 
54
67
  ## Contributing
@@ -66,22 +79,25 @@ and for his generosity in allowing me to
66
79
  add the game to [GoldToken.com][goldtoken].
67
80
 
68
81
  Thanks to his widow Colleen Foley-Smith
69
- for extending that generosity
70
- to allow me to include Trax on [slugbugblue.com][sbb].
82
+ for extending that courtesy
83
+ to allow me to include Trax on [slugbugblue.com][sbb]
84
+ as well.
71
85
 
72
86
  I would also like to extend a huge heartfelt appreciation
73
87
  to the magnanimous [Donald G. Bailey][dgb],
74
88
  who, through his excellent [book][traxbook],
75
- taught me the basics (and more!) of Trax
76
- and was always ready to share his insights
89
+ taught me the basics (and more!) of Trax.
90
+ I found him always ready to share his insights
77
91
  on the mechanics of the game,
78
- various approaches to encoding its complexities,
79
- and for his undeserved kindness
80
- in indulging my many questions.
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.
81
97
 
82
98
  ## License
83
99
 
84
- Copyright 2021 Chad Transtrum
100
+ Copyright 2019-2022 Chad Transtrum
85
101
 
86
102
  Licensed under the Apache License, Version 2.0 (the "License");
87
103
  you may not use the files in this project
@@ -98,7 +114,7 @@ limitations under the License.
98
114
 
99
115
  ## Trax rules copyright
100
116
 
101
- In the United States, game mechanics may not be copyrighted,
117
+ In the United States, game mechanics may not be copyrighted;
102
118
  however, the specific wording of game rules does fall under copyright law.
103
119
 
104
120
  The official rules for Trax are found at http://traxgame.com/about_rules.php.
package/docs/engine.md ADDED
@@ -0,0 +1,64 @@
1
+ # engine.js API documentation
2
+
3
+ This module provides the logic to handle interacting with a Trax game, including
4
+ starting a game, making moves in the game, and determining if the game has been
5
+ won.
6
+
7
+ A few other functions/properties are also provided to assist with determining
8
+ the game state and what actions can be taken on the game.
9
+
10
+ ## Example usage
11
+
12
+ ```javascript
13
+ import Trax from '@slugbugblue/trax'
14
+
15
+ let trax = new Trax()
16
+ console.log(trax.possible_moves()) // "[ '@0/', '@0+' ]" -- initial moves
17
+
18
+ trax.play('@0/')
19
+ console.log(trax.turn) // "2" -- it is player 2's turn
20
+
21
+ trax.play('@1\\')
22
+ console.log(trax.color) // "w" -- it is white's turn
23
+
24
+ trax.play('A0/')
25
+ console.log(trax.over) // "true" -- the game is over
26
+ console.log(trax.winner) // "1" -- player 1 wins
27
+ ```
28
+
29
+ ## API
30
+
31
+ ### Trax object
32
+
33
+ The Trax object can be called as a constructor, but it also has the following
34
+ class properties and methods:
35
+
36
+ - `Trax.variants`: an array of the different rule sets the engine supports.
37
+
38
+ - `Trax.column(col)`: a function to turn a numeric column number into the column
39
+ letter used in Trax notation.
40
+
41
+ ### Trax class
42
+
43
+ #### constructor
44
+
45
+ ```javascript
46
+ trax = new Trax(rules, moves, id)
47
+ ```
48
+
49
+ - `rules
50
+
51
+ ## License
52
+
53
+ Copyright 2019-2022 Chad Transtrum
54
+
55
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
56
+ the files in this project except in compliance with the License. You may obtain
57
+ a copy of the License at
58
+
59
+ http://www.apache.org/licenses/LICENSE-2.0
60
+
61
+ Unless required by applicable law or agreed to in writing, software distributed
62
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
63
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
64
+ specific language governing permissions and limitations under the License.