js-chess-engine 1.0.3 → 2.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.
Files changed (104) hide show
  1. package/README.md +586 -205
  2. package/dist/adapters/APIAdapter.d.ts +88 -0
  3. package/dist/adapters/APIAdapter.d.ts.map +1 -0
  4. package/dist/adapters/APIAdapter.js +225 -0
  5. package/dist/adapters/APIAdapter.js.map +1 -0
  6. package/dist/ai/AIEngine.d.ts +42 -0
  7. package/dist/ai/AIEngine.d.ts.map +1 -0
  8. package/dist/ai/AIEngine.js +62 -0
  9. package/dist/ai/AIEngine.js.map +1 -0
  10. package/dist/ai/Evaluator.d.ts +48 -0
  11. package/dist/ai/Evaluator.d.ts.map +1 -0
  12. package/dist/ai/Evaluator.js +248 -0
  13. package/dist/ai/Evaluator.js.map +1 -0
  14. package/dist/ai/MoveOrdering.d.ts +60 -0
  15. package/dist/ai/MoveOrdering.d.ts.map +1 -0
  16. package/dist/ai/MoveOrdering.js +173 -0
  17. package/dist/ai/MoveOrdering.js.map +1 -0
  18. package/dist/ai/Search.d.ts +62 -0
  19. package/dist/ai/Search.d.ts.map +1 -0
  20. package/dist/ai/Search.js +340 -0
  21. package/dist/ai/Search.js.map +1 -0
  22. package/dist/ai/TranspositionTable.d.ts +100 -0
  23. package/dist/ai/TranspositionTable.d.ts.map +1 -0
  24. package/dist/ai/TranspositionTable.js +176 -0
  25. package/dist/ai/TranspositionTable.js.map +1 -0
  26. package/dist/core/AttackDetector.d.ts +52 -0
  27. package/dist/core/AttackDetector.d.ts.map +1 -0
  28. package/dist/core/AttackDetector.js +397 -0
  29. package/dist/core/AttackDetector.js.map +1 -0
  30. package/dist/core/Board.d.ts +109 -0
  31. package/dist/core/Board.d.ts.map +1 -0
  32. package/dist/core/Board.js +410 -0
  33. package/dist/core/Board.js.map +1 -0
  34. package/dist/core/MoveGenerator.d.ts +48 -0
  35. package/dist/core/MoveGenerator.d.ts.map +1 -0
  36. package/dist/core/MoveGenerator.js +678 -0
  37. package/dist/core/MoveGenerator.js.map +1 -0
  38. package/dist/core/Position.d.ts +135 -0
  39. package/dist/core/Position.d.ts.map +1 -0
  40. package/dist/core/Position.js +351 -0
  41. package/dist/core/Position.js.map +1 -0
  42. package/dist/core/index.d.ts +9 -0
  43. package/dist/core/index.d.ts.map +1 -0
  44. package/dist/core/index.js +25 -0
  45. package/dist/core/index.js.map +1 -0
  46. package/dist/core/zobrist.d.ts +93 -0
  47. package/dist/core/zobrist.d.ts.map +1 -0
  48. package/dist/core/zobrist.js +273 -0
  49. package/dist/core/zobrist.js.map +1 -0
  50. package/dist/index.d.ts +154 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +353 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/types/ai.types.d.ts +97 -0
  55. package/dist/types/ai.types.d.ts.map +1 -0
  56. package/dist/types/ai.types.js +17 -0
  57. package/dist/types/ai.types.js.map +1 -0
  58. package/dist/types/board.types.d.ts +140 -0
  59. package/dist/types/board.types.d.ts.map +1 -0
  60. package/dist/types/board.types.js +34 -0
  61. package/dist/types/board.types.js.map +1 -0
  62. package/dist/types/index.d.ts +7 -0
  63. package/dist/types/index.d.ts.map +1 -0
  64. package/dist/types/index.js +26 -0
  65. package/dist/types/index.js.map +1 -0
  66. package/dist/types/move.types.d.ts +70 -0
  67. package/dist/types/move.types.d.ts.map +1 -0
  68. package/dist/types/move.types.js +53 -0
  69. package/dist/types/move.types.js.map +1 -0
  70. package/dist/utils/constants.d.ts +123 -0
  71. package/dist/utils/constants.d.ts.map +1 -0
  72. package/dist/utils/constants.js +259 -0
  73. package/dist/utils/constants.js.map +1 -0
  74. package/dist/utils/conversion.d.ts +152 -0
  75. package/dist/utils/conversion.d.ts.map +1 -0
  76. package/dist/utils/conversion.js +288 -0
  77. package/dist/utils/conversion.js.map +1 -0
  78. package/dist/utils/environment.d.ts +33 -0
  79. package/dist/utils/environment.d.ts.map +1 -0
  80. package/dist/utils/environment.js +71 -0
  81. package/dist/utils/environment.js.map +1 -0
  82. package/dist/utils/fen.d.ts +28 -0
  83. package/dist/utils/fen.d.ts.map +1 -0
  84. package/dist/utils/fen.js +203 -0
  85. package/dist/utils/fen.js.map +1 -0
  86. package/package.json +29 -30
  87. package/.eslintrc.json +0 -16
  88. package/.github/workflows/main.yml +0 -20
  89. package/.nvmrc +0 -1
  90. package/CHANGELOG.md +0 -597
  91. package/dist/js-chess-engine.js +0 -1
  92. package/example/aiMatch.mjs +0 -21
  93. package/example/console.mjs +0 -37
  94. package/example/server.mjs +0 -27
  95. package/lib/Board.mjs +0 -946
  96. package/lib/const/board.mjs +0 -838
  97. package/lib/js-chess-engine.mjs +0 -99
  98. package/lib/utils.mjs +0 -154
  99. package/test/.eslintrc.json +0 -11
  100. package/test/ai.test.mjs +0 -132
  101. package/test/badge.svg +0 -1
  102. package/test/importExport.mjs +0 -108
  103. package/test/moves.test.mjs +0 -798
  104. package/webpack.config.js +0 -12
package/CHANGELOG.md DELETED
@@ -1,597 +0,0 @@
1
- ## [1.0.3](https://github.com/josefjadrny/js-chess-engine/compare/v1.0.2...v1.0.3) (2025-09-01)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * Add nodejs 20 support ([559244d](https://github.com/josefjadrny/js-chess-engine/commit/559244d6cd4c67fea15e6bfe6b55c862e728cd62))
7
- * getHistory() check property consistently returning false ([#31](https://github.com/josefjadrny/js-chess-engine/issues/31)) ([05845d1](https://github.com/josefjadrny/js-chess-engine/commit/05845d1506ca377ad7dcbc46afe2bc88608cd127)), closes [#28](https://github.com/josefjadrny/js-chess-engine/issues/28)
8
-
9
-
10
-
11
- ## [1.0.2](https://github.com/josefjadrny/js-chess-engine/compare/v1.0.1...v1.0.2) (2021-10-24)
12
-
13
-
14
- ### Bug Fixes
15
-
16
- * Fixed FEN parsing ([#23](https://github.com/josefjadrny/js-chess-engine/issues/23)) ([14ebe50](https://github.com/josefjadrny/js-chess-engine/commit/14ebe506e300e2a22fed81696f76ef117c00c2d7))
17
-
18
-
19
-
20
- ## [1.0.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.11.3...v1.0.1) (2021-10-16)
21
-
22
-
23
- ### Bug Fixes
24
-
25
- * fixed array sort in firefox ([#21](https://github.com/josefjadrny/js-chess-engine/issues/21)) ([42c5913](https://github.com/josefjadrny/js-chess-engine/commit/42c5913a46faa5eaccf142dfd34cf83adf538435))
26
-
27
-
28
-
29
- # [1.0.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.11.3...v1.0.0) (2021-10-13)
30
-
31
-
32
-
33
- ## [0.11.3](https://github.com/josefjadrny/js-chess-engine/compare/v0.11.2...v0.11.3) (2021-03-29)
34
-
35
-
36
- ### Bug Fixes
37
-
38
- * **AI:** AI configuration and logic improved. Add new level (4) for testing. Add new Example ([bd2261b](https://github.com/josefjadrny/js-chess-engine/commit/bd2261be6b99df8f4de8d5a5326398e33d3015d4))
39
-
40
-
41
-
42
- ## [0.11.2](https://github.com/josefjadrny/js-chess-engine/compare/v0.11.1...v0.11.2) (2021-03-27)
43
-
44
-
45
- ### Bug Fixes
46
-
47
- * **AI:** Calculation time - fixing v0.11.1 ([4d426ae](https://github.com/josefjadrny/js-chess-engine/commit/4d426ae82dd78efbc2cbd370c2dca69dae17bd5d))
48
-
49
-
50
-
51
- ## [0.11.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.11.0...v0.11.1) (2021-03-27)
52
-
53
-
54
- ### Bug Fixes
55
-
56
- * **AI:** Checkmate is not ignored when score is not changed ([56b98d9](https://github.com/josefjadrny/js-chess-engine/commit/56b98d9e04f1ce0f4ab74cf4663aa8958f5b5742))
57
- * **AI:** Do not end with draw ([5000a17](https://github.com/josefjadrny/js-chess-engine/commit/5000a176d443680d05d9de2b981fc51ff064d6cf))
58
-
59
-
60
-
61
- # [0.11.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.10.0...v0.11.0) (2021-03-20)
62
-
63
-
64
- ### Bug Fixes
65
-
66
- * Error message for AI levels ([db2e856](https://github.com/josefjadrny/js-chess-engine/commit/db2e856ddf7ddc96b59755f3325093fc2cb8dadd))
67
-
68
-
69
- ### Features
70
-
71
- * AI calculation time decreased and AI level 3 plays better ([a47bd5f](https://github.com/josefjadrny/js-chess-engine/commit/a47bd5f6045cd781177078e75b1c901ae5ab3224))
72
-
73
-
74
-
75
- # [0.10.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.9.1...v0.10.0) (2021-03-12)
76
-
77
-
78
- ### Features
79
-
80
- * Add response object with performed move to move() and aiMove() ([8d3cbe5](https://github.com/josefjadrny/js-chess-engine/commit/8d3cbe5a367b2bf2330e1e107ee908ed054fd8be))
81
-
82
-
83
-
84
- ## [0.9.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.9.0...v0.9.1) (2021-03-11)
85
-
86
-
87
- ### Bug Fixes
88
-
89
- * Add doc for React app ([bfe53cc](https://github.com/josefjadrny/js-chess-engine/commit/bfe53cc8fd5f3f2d14da80926cd012fbdd2962bf))
90
-
91
-
92
-
93
- # [0.9.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.8.0...v0.9.0) (2021-03-07)
94
-
95
-
96
- ### Features
97
-
98
- * Add chess board configuration to getHistory to retrieve previous in-game configurations ([afc86a8](https://github.com/josefjadrny/js-chess-engine/commit/afc86a8132fc94c0d513b0bb1c675a552f520c3e))
99
-
100
-
101
-
102
- # [0.8.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.7.0...v0.8.0) (2021-03-05)
103
-
104
-
105
- ### Features
106
-
107
- * Add setPiece and removePiece ([5c02db2](https://github.com/josefjadrny/js-chess-engine/commit/5c02db2ba57c4238cefebe2852b724c38939caf5))
108
-
109
-
110
-
111
- # [0.7.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.6.2...v0.7.0) (2021-02-28)
112
-
113
-
114
- ### Features
115
-
116
- * Add getHistory which returns played moves ([#13](https://github.com/josefjadrny/js-chess-engine/issues/13)) ([f6ff267](https://github.com/josefjadrny/js-chess-engine/commit/f6ff26710f74d7256ecd4273261454217e324fcb))
117
-
118
-
119
-
120
- ## [0.6.2](https://github.com/josefjadrny/js-chess-engine/compare/v0.6.1...v0.6.2) (2021-02-26)
121
-
122
-
123
- ### Bug Fixes
124
-
125
- * en passant move recognition when using FEN ([#12](https://github.com/josefjadrny/js-chess-engine/issues/12)) ([c41b2d7](https://github.com/josefjadrny/js-chess-engine/commit/c41b2d7c776ede419d3a8e3d9106580c53683dba))
126
-
127
-
128
-
129
- ## [0.6.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.6.0...v0.6.1) (2021-02-08)
130
-
131
-
132
- ### Bug Fixes
133
-
134
- * Castling for black player (closes [#9](https://github.com/josefjadrny/js-chess-engine/issues/9)) ([e7d3bf3](https://github.com/josefjadrny/js-chess-engine/commit/e7d3bf39b25d94dce57d47e11a4594426449a442))
135
-
136
-
137
-
138
- # [0.6.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.5.2...v0.6.0) (2020-12-30)
139
-
140
-
141
- ### Features
142
-
143
- * Add check indicator to response object ([d6d4fb9](https://github.com/josefjadrny/js-chess-engine/commit/d6d4fb91d3098bd4067284fcd96f5c3b0b4de360))
144
-
145
-
146
-
147
- ## [0.5.2](https://github.com/josefjadrny/js-chess-engine/compare/v0.5.1...v0.5.2) (2020-12-28)
148
-
149
-
150
- ### Bug Fixes
151
-
152
- * Keywords should be an array ([8ced735](https://github.com/josefjadrny/js-chess-engine/commit/8ced7355984e803ad209f560a3afcd2460c3f808))
153
-
154
-
155
-
156
- ## [0.5.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.5.0...v0.5.1) (2020-11-01)
157
-
158
-
159
- ### Bug Fixes
160
-
161
- * small calc fix ([f3d722b](https://github.com/josefjadrny/js-chess-engine/commit/f3d722b4c5e36a6e704cafec9280e84323bb5a18))
162
-
163
-
164
-
165
- # [0.5.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.8...v0.5.0) (2020-07-13)
166
-
167
-
168
- ### Features
169
-
170
- * Add piece location scores to improve AI logic ([7d7db38](https://github.com/josefjadrny/js-chess-engine/commit/7d7db3884ef334d3d731f3f0a07ce66f85463811))
171
- * AI levels updated. Depth is now calculated from situation on the chessboard. ([9d32b7c](https://github.com/josefjadrny/js-chess-engine/commit/9d32b7ce341743b36d428e5f4803ca6763d76eb2))
172
-
173
-
174
-
175
- ## [0.4.8](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.7...v0.4.8) (2020-07-10)
176
-
177
-
178
- ### Features
179
-
180
- * AI speed increased (~5-10), score is now passed from previous move ([10bdf28](https://github.com/josefjadrny/js-chess-engine/commit/10bdf28a94f8aff523351736cb5e9f5a2d07d96f))
181
-
182
-
183
-
184
- ## [0.4.7](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.6...v0.4.7) (2020-07-09)
185
-
186
-
187
- ### Features
188
-
189
- * AI move calculation speed up (~10%) ([ace2820](https://github.com/josefjadrny/js-chess-engine/commit/ace2820a36d71c137d4e7be628fcb38dd4f062f4))
190
-
191
-
192
-
193
- ## [0.4.6](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.5...v0.4.6) (2020-07-09)
194
-
195
-
196
- ### Features
197
-
198
- * AI logic improved - score increased for moves with pawn and castling, score decreased for useless king moves ([935f21f](https://github.com/josefjadrny/js-chess-engine/commit/935f21f473c5efaaddd01fdaa25b5d1795b5132f))
199
-
200
-
201
-
202
- ## [0.4.5](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.4...v0.4.5) (2020-07-08)
203
-
204
-
205
- ### Features
206
-
207
- * AI calculation stopped when max Value is reached ([4f0b070](https://github.com/josefjadrny/js-chess-engine/commit/4f0b070db61760bc1c5c3d3721c49b8eedfa09b3))
208
-
209
-
210
-
211
- ## [0.4.4](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.3...v0.4.4) (2020-07-08)
212
-
213
-
214
- ### Bug Fixes
215
-
216
- * Castling is not possible in check ([7d985aa](https://github.com/josefjadrny/js-chess-engine/commit/7d985aa92af1f4d0ab82ae8d96d0f07f143948e6))
217
-
218
-
219
-
220
- ## [0.4.3](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.2...v0.4.3) (2020-07-06)
221
-
222
-
223
- ### Features
224
-
225
- * AI level is increased with only few pieces left to prevent useless moves ([50e2eb3](https://github.com/josefjadrny/js-chess-engine/commit/50e2eb326f7b2c37386444553f2421b237516bf6))
226
-
227
-
228
-
229
- ## [0.4.2](https://github.com/josefjadrny/js-chess-engine/compare/v0.4.1...v0.4.2) (2020-07-06)
230
-
231
-
232
- ### Features
233
-
234
- * Check is now calculated from King moves with is faster ([3fe35af](https://github.com/josefjadrny/js-chess-engine/commit/3fe35af00831e2456601bb17170882c78a18eeae))
235
-
236
-
237
-
238
- ## [0.4.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.3.0...v0.4.1) (2020-06-11)
239
-
240
-
241
- ### Features
242
-
243
- * Engine has been refactored and optimized ([#1](https://github.com/josefjadrny/js-chess-engine/issues/1)) ([2a2c3c1](https://github.com/josefjadrny/js-chess-engine/commit/2a2c3c15110a40ecce1d81df15bb432061d20fb6))
244
-
245
-
246
-
247
- # [0.4.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.3.0...v0.4.0) (2020-06-11)
248
-
249
-
250
- ### Features
251
-
252
- * Engine has been refactored and optimized ([#1](https://github.com/josefjadrny/js-chess-engine/issues/1)) ([2a2c3c1](https://github.com/josefjadrny/js-chess-engine/commit/2a2c3c15110a40ecce1d81df15bb432061d20fb6))
253
-
254
-
255
-
256
- # [0.3.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.9...v0.3.0) (2020-06-03)
257
-
258
-
259
- ### Features
260
-
261
- * FEN can be now used everywhere instead of JSON. move(config) call has been changed to move(config, from, to). ([c306492](https://github.com/josefjadrny/js-chess-engine/commit/c306492ef62050f026197c231fd0f090c16bbe90))
262
-
263
-
264
-
265
- ## [0.2.9](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.8...v0.2.9) (2020-06-01)
266
-
267
-
268
- ### Features
269
-
270
- * New game could be initialized from FEN ([2b02d34](https://github.com/josefjadrny/js-chess-engine/commit/2b02d34f460478767b6ce85eead39fd4aed4e6cc))
271
-
272
-
273
-
274
- ## [0.2.9](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.8...v0.2.9) (2020-06-01)
275
-
276
-
277
- ### Features
278
-
279
- * New game could be initialized from FEN ([2b02d34](https://github.com/josefjadrny/js-chess-engine/commit/2b02d34f460478767b6ce85eead39fd4aed4e6cc))
280
-
281
-
282
-
283
- ## [0.2.8](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.7...v0.2.8) (2020-05-28)
284
-
285
-
286
- ### Features
287
-
288
- * En passant a special pawn move rules added to pawn moves calculations ([b3516c2](https://github.com/josefjadrny/js-chess-engine/commit/b3516c2666a1e28a026511e6ef072987d98d3c43))
289
- * En passant can be played now ([297c54b](https://github.com/josefjadrny/js-chess-engine/commit/297c54ba641045c94f73890d512fc7e7b64198ec))
290
-
291
-
292
-
293
- ## [0.2.7](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.6...v0.2.7) (2020-05-27)
294
-
295
-
296
- ### Features
297
-
298
- * Add En passant move to FEN export ([0d67c5f](https://github.com/josefjadrny/js-chess-engine/commit/0d67c5f25f0d52f473d7425ff7ba3a43eaa57e5a))
299
- * Add En passant move to JSON import/export. ([0f7a5cd](https://github.com/josefjadrny/js-chess-engine/commit/0f7a5cde548833004d40e5e02dd656b5a72d7997))
300
-
301
-
302
-
303
- ## [0.2.6](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.5...v0.2.6) (2020-05-24)
304
-
305
-
306
-
307
- ## [0.2.5](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.4...v0.2.5) (2020-05-24)
308
-
309
-
310
- ### Features
311
-
312
- * Add FEN export of a chessboard ([b611566](https://github.com/josefjadrny/js-chess-engine/commit/b61156622a3b0af9d237866b40fbbd84a05446e6))
313
-
314
-
315
-
316
- ## [0.2.4](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.3...v0.2.4) (2020-05-13)
317
-
318
-
319
-
320
- ## [0.2.3](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.2...v0.2.3) (2020-05-13)
321
-
322
-
323
- ### Bug Fixes
324
-
325
- * Attacking pieces score decreased about pawn ([7cc4bfa](https://github.com/josefjadrny/js-chess-engine/commit/7cc4bfad6956977dfb9b32d5515ce1c435940774))
326
-
327
-
328
-
329
- ## [0.2.2](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.1...v0.2.2) (2020-05-13)
330
-
331
-
332
- ### Bug Fixes
333
-
334
- * Ingame pieces score is multiplied to reduce depth influence in score calculation ([2f2eb22](https://github.com/josefjadrny/js-chess-engine/commit/2f2eb2216566cc5cce16d290eca2c83f6525a981))
335
-
336
-
337
- ### Features
338
-
339
- * Add attacking pieces to move calculations ([ddf6a06](https://github.com/josefjadrny/js-chess-engine/commit/ddf6a063a54574f83ffedd580812abb607b37faf))
340
-
341
-
342
-
343
- ## [0.2.1](https://github.com/josefjadrny/js-chess-engine/compare/v0.2.0...v0.2.1) (2020-05-12)
344
-
345
-
346
-
347
- # [0.2.0](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.33...v0.2.0) (2020-05-12)
348
-
349
-
350
- ### Features
351
-
352
- * Minimax algorithm implemented for picking best move. Dept calculation can vary and depends on pieces still in game. ([bec0a9f](https://github.com/josefjadrny/js-chess-engine/commit/bec0a9f62c2ea195c061678c9085146f9bea37c9))
353
-
354
-
355
-
356
- ## [0.1.33](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.32...v0.1.33) (2020-05-11)
357
-
358
-
359
- ### Bug Fixes
360
-
361
- * Last move score calculated wrongly ([a3cecb4](https://github.com/josefjadrny/js-chess-engine/commit/a3cecb4234df8f2008eb235c0e68c8823af2df52))
362
-
363
-
364
-
365
- ## [0.1.32](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.31...v0.1.32) (2020-05-11)
366
-
367
-
368
- ### Bug Fixes
369
-
370
- * Board enum rollback ([da6265a](https://github.com/josefjadrny/js-chess-engine/commit/da6265ac3946610f4d948fbf95ff7133be134b65))
371
-
372
-
373
-
374
- ## [0.1.31](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.30...v0.1.31) (2020-05-11)
375
-
376
-
377
- ### Features
378
-
379
- * Checkmate logic improved - part2 ([5e24a05](https://github.com/josefjadrny/js-chess-engine/commit/5e24a05fef9c8e991f2f6387d47949bb65b62297))
380
-
381
-
382
-
383
- ## [0.1.30](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.29...v0.1.30) (2020-05-11)
384
-
385
-
386
- ### Features
387
-
388
- * Checkmate logic improved ([bd4066e](https://github.com/josefjadrny/js-chess-engine/commit/bd4066e648d4fa75e4c5b3766ee162ade47453b3))
389
-
390
-
391
-
392
- ## [0.1.29](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.28...v0.1.29) (2020-05-10)
393
-
394
-
395
- ### Bug Fixes
396
-
397
- * Random decreased, sometimes bad move is picked ([f2071d9](https://github.com/josefjadrny/js-chess-engine/commit/f2071d902a0217598f7bb33d89ba9a8da5623005))
398
-
399
-
400
-
401
- ## [0.1.28](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.27...v0.1.28) (2020-05-09)
402
-
403
-
404
- ### Bug Fixes
405
-
406
- * Examples fix ([a31fbba](https://github.com/josefjadrny/js-chess-engine/commit/a31fbbafd446fa174624d2c628ca6cc0325346c1))
407
-
408
-
409
-
410
- ## [0.1.27](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.26...v0.1.27) (2020-05-08)
411
-
412
-
413
-
414
- ## [0.1.26](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.25...v0.1.26) (2020-05-08)
415
-
416
-
417
-
418
- ## [0.1.25](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.24...v0.1.25) (2020-05-08)
419
-
420
-
421
- ### Bug Fixes
422
-
423
- * White is a default player when none is provided ([7e5701b](https://github.com/josefjadrny/js-chess-engine/commit/7e5701b35acf387f916eb3ff067ce03d526a3563))
424
-
425
-
426
-
427
- ## [0.1.24](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.23...v0.1.24) (2020-05-08)
428
-
429
-
430
-
431
- ## [0.1.23](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.22...v0.1.23) (2020-05-07)
432
-
433
-
434
-
435
- ## [0.1.22](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.21...v0.1.22) (2020-05-07)
436
-
437
-
438
-
439
- ## [0.1.21](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.20...v0.1.21) (2020-05-07)
440
-
441
-
442
-
443
- ## [0.1.20](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.19...v0.1.20) (2020-05-07)
444
-
445
-
446
- ### Features
447
-
448
- * Add randomizer to AI move logic calculation to prevent repeating of moves with same score ([4323e19](https://github.com/josefjadrny/js-chess-engine/commit/4323e193dfaf3141a8b25afd61c9984e5f3138e8))
449
-
450
-
451
-
452
- ## [0.1.19](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.18...v0.1.19) (2020-05-07)
453
-
454
-
455
- ### Features
456
-
457
- * Add level support to Example server ([77a760d](https://github.com/josefjadrny/js-chess-engine/commit/77a760d02759a46292edd82398a2806297f8d0e7))
458
-
459
-
460
-
461
- ## [0.1.18](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.17...v0.1.18) (2020-05-07)
462
-
463
-
464
- ### Features
465
-
466
- * AI speed rapidly increased. ([98a0a6e](https://github.com/josefjadrny/js-chess-engine/commit/98a0a6ebbf5f7f155df248befd6eac0e23082559))
467
-
468
-
469
-
470
- ## [0.1.17](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.16...v0.1.17) (2020-05-06)
471
-
472
-
473
- ### Features
474
-
475
- * Queen replaces a pawn when a pawn reaches an end of a chessboard. ([285e4b9](https://github.com/josefjadrny/js-chess-engine/commit/285e4b93b85730d4a3376e2287f6f5bee5f6a902))
476
-
477
-
478
-
479
- ## [0.1.16](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.15...v0.1.16) (2020-05-06)
480
-
481
-
482
- ### Features
483
-
484
- * Computer logic improved - need optimalizations ([4263220](https://github.com/josefjadrny/js-chess-engine/commit/426322064c4f87bff46987039296396bf864b970))
485
-
486
-
487
-
488
- ## [0.1.15](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.14...v0.1.15) (2020-05-05)
489
-
490
-
491
- ### Features
492
-
493
- * Computer AI improved ([33bfb80](https://github.com/josefjadrny/js-chess-engine/commit/33bfb804cc686e0339910189fee81cac6554b79d))
494
-
495
-
496
-
497
- ## [0.1.14](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.13...v0.1.14) (2020-05-04)
498
-
499
-
500
- ### Bug Fixes
501
-
502
- * Fixed AI move when all moves has same score ([0e77dfa](https://github.com/josefjadrny/js-chess-engine/commit/0e77dfae2c708f7538af765d131ba5da9fcb9d55))
503
-
504
-
505
-
506
- ## [0.1.13](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.12...v0.1.13) (2020-05-04)
507
-
508
-
509
- ### Features
510
-
511
- * AI logic init - it can calculate one move to the future ([08f646f](https://github.com/josefjadrny/js-chess-engine/commit/08f646f305268d755bbbc90dfbe1c2c0f4222df8))
512
-
513
-
514
-
515
- ## [0.1.12](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.11...v0.1.12) (2020-05-03)
516
-
517
-
518
- ### Bug Fixes
519
-
520
- * Castlings - constructor name is transpiled during build ([0218f4a](https://github.com/josefjadrny/js-chess-engine/commit/0218f4ab5351115370f139b2b1ebc706aa41dee6))
521
-
522
-
523
-
524
- ## [0.1.11](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.10...v0.1.11) (2020-05-03)
525
-
526
-
527
-
528
- ## [0.1.10](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.9...v0.1.10) (2020-05-03)
529
-
530
-
531
- ### Features
532
-
533
- * Add Initial computer AI logic (level 0 - random moves) ([d7d46b0](https://github.com/josefjadrny/js-chess-engine/commit/d7d46b0ca9e3b9ac83be3c5facc72140b7d65a2c))
534
-
535
-
536
-
537
- ## [0.1.9](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.8...v0.1.9) (2020-05-02)
538
-
539
-
540
-
541
- ## [0.1.8](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.7...v0.1.8) (2020-05-02)
542
-
543
-
544
-
545
- ## [0.1.7](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.6...v0.1.7) (2020-05-02)
546
-
547
-
548
-
549
- ## [0.1.6](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.5...v0.1.6) (2020-05-02)
550
-
551
-
552
- ### Bug Fixes
553
-
554
- * Typo ([5c525c8](https://github.com/josefjadrny/js-chess-engine/commit/5c525c831ebaca675bbbc3213a669df1de0b83ec))
555
-
556
-
557
-
558
- ## [0.1.5](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.4...v0.1.5) (2020-05-02)
559
-
560
-
561
-
562
- ## [0.1.4](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.3...v0.1.4) (2020-05-02)
563
-
564
-
565
-
566
- ## [0.1.3](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.2...v0.1.3) (2020-05-02)
567
-
568
-
569
- ### Bug Fixes
570
-
571
- * Webpack build ([d04a515](https://github.com/josefjadrny/js-chess-engine/commit/d04a5153285df36174b71c429e300612fe2b2a19))
572
-
573
-
574
-
575
- ## [0.1.2](https://github.com/josefjadrny/js-chess-engine/compare/v0.1.1...v0.1.2) (2020-05-02)
576
-
577
-
578
-
579
- ## [0.1.1](https://github.com/josefjadrny/js-chess-engine/compare/0a7f28466ad3a6f8391c53615bb6e76148737761...v0.1.1) (2020-05-02)
580
-
581
-
582
- ### Bug Fixes
583
-
584
- * Castling functions fix for black player ([3f43949](https://github.com/josefjadrny/js-chess-engine/commit/3f43949dd90a3a46ea41faffd5bf9ea3a3419d9c))
585
- * fixed main module ([41af084](https://github.com/josefjadrny/js-chess-engine/commit/41af084c3f0757a280a3fa0bed85560197a638b6))
586
-
587
-
588
- ### Features
589
-
590
- * Added castling functions ([c5fedf2](https://github.com/josefjadrny/js-chess-engine/commit/c5fedf264b4e631b5247fb5a2d761f0496efe297))
591
- * Added move() function witch check-mate checking ([09288aa](https://github.com/josefjadrny/js-chess-engine/commit/09288aa30b64471fd59acc91c45a3a4b4b1294fb))
592
- * Added status function for retrieve game status info (checkmate, isFinished) ([52566b9](https://github.com/josefjadrny/js-chess-engine/commit/52566b93c46ac8822934be18d88fc3f546774dc1))
593
- * Castling is now sent and parsed in stateless mode ([d76bc05](https://github.com/josefjadrny/js-chess-engine/commit/d76bc055652ae0fdf2d31a3d68ccfc8b9059723f))
594
- * Initial commit with moves calculation engine ([0a7f284](https://github.com/josefjadrny/js-chess-engine/commit/0a7f28466ad3a6f8391c53615bb6e76148737761))
595
-
596
-
597
-
@@ -1 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("js-chess-engine",[],e):"object"==typeof exports?exports["js-chess-engine"]=e():t["js-chess-engine"]=e()}(this,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e),i.d(e,"Game",(function(){return $})),i.d(e,"moves",(function(){return J})),i.d(e,"status",(function(){return V})),i.d(e,"getFen",(function(){return Y})),i.d(e,"move",(function(){return z})),i.d(e,"aiMove",(function(){return X}));const n=["A","B","C","D","E","F","G","H"],o=["1","2","3","4","5","6","7","8"],s={KING_W:"K",QUEEN_W:"Q",ROOK_W:"R",BISHOP_W:"B",KNIGHT_W:"N",PAWN_W:"P",KING_B:"k",QUEEN_B:"q",ROOK_B:"r",BISHOP_B:"b",KNIGHT_B:"n",PAWN_B:"p"},r="black",c="white",l=[0,1,2,3,4],a={0:1,1:2,2:2,3:3,4:3,5:4},u={0:2,1:2,2:4,3:4,4:5,5:5},h={fullMove:1,halfMove:0,enPassant:null,isFinished:!1,checkMate:!1,check:!1,turn:c},g=Object.assign({pieces:{E1:"K",D1:"Q",A1:"R",H1:"R",C1:"B",F1:"B",B1:"N",G1:"N",A2:"P",B2:"P",C2:"P",D2:"P",E2:"P",F2:"P",G2:"P",H2:"P",E8:"k",D8:"q",A8:"r",H8:"r",C8:"b",F8:"b",B8:"n",G8:"n",A7:"p",B7:"p",C7:"p",D7:"p",E7:"p",F7:"p",G7:"p",H7:"p"},castling:{whiteShort:!0,blackShort:!0,whiteLong:!0,blackLong:!0}},h),f={UP:{A1:"A2",A2:"A3",A3:"A4",A4:"A5",A5:"A6",A6:"A7",A7:"A8",A8:null,B1:"B2",B2:"B3",B3:"B4",B4:"B5",B5:"B6",B6:"B7",B7:"B8",B8:null,C1:"C2",C2:"C3",C3:"C4",C4:"C5",C5:"C6",C6:"C7",C7:"C8",C8:null,D1:"D2",D2:"D3",D3:"D4",D4:"D5",D5:"D6",D6:"D7",D7:"D8",D8:null,E1:"E2",E2:"E3",E3:"E4",E4:"E5",E5:"E6",E6:"E7",E7:"E8",E8:null,F1:"F2",F2:"F3",F3:"F4",F4:"F5",F5:"F6",F6:"F7",F7:"F8",F8:null,G1:"G2",G2:"G3",G3:"G4",G4:"G5",G5:"G6",G6:"G7",G7:"G8",G8:null,H1:"H2",H2:"H3",H3:"H4",H4:"H5",H5:"H6",H6:"H7",H7:"H8",H8:null},DOWN:{A1:null,A2:"A1",A3:"A2",A4:"A3",A5:"A4",A6:"A5",A7:"A6",A8:"A7",B1:null,B2:"B1",B3:"B2",B4:"B3",B5:"B4",B6:"B5",B7:"B6",B8:"B7",C1:null,C2:"C1",C3:"C2",C4:"C3",C5:"C4",C6:"C5",C7:"C6",C8:"C7",D1:null,D2:"D1",D3:"D2",D4:"D3",D5:"D4",D6:"D5",D7:"D6",D8:"D7",E1:null,E2:"E1",E3:"E2",E4:"E3",E5:"E4",E6:"E5",E7:"E6",E8:"E7",F1:null,F2:"F1",F3:"F2",F4:"F3",F5:"F4",F6:"F5",F7:"F6",F8:"F7",G1:null,G2:"G1",G3:"G2",G4:"G3",G5:"G4",G6:"G5",G7:"G6",G8:"G7",H1:null,H2:"H1",H3:"H2",H4:"H3",H5:"H4",H6:"H5",H7:"H6",H8:"H7"},LEFT:{A1:null,A2:null,A3:null,A4:null,A5:null,A6:null,A7:null,A8:null,B1:"A1",B2:"A2",B3:"A3",B4:"A4",B5:"A5",B6:"A6",B7:"A7",B8:"A8",C1:"B1",C2:"B2",C3:"B3",C4:"B4",C5:"B5",C6:"B6",C7:"B7",C8:"B8",D1:"C1",D2:"C2",D3:"C3",D4:"C4",D5:"C5",D6:"C6",D7:"C7",D8:"C8",E1:"D1",E2:"D2",E3:"D3",E4:"D4",E5:"D5",E6:"D6",E7:"D7",E8:"D8",F1:"E1",F2:"E2",F3:"E3",F4:"E4",F5:"E5",F6:"E6",F7:"E7",F8:"E8",G1:"F1",G2:"F2",G3:"F3",G4:"F4",G5:"F5",G6:"F6",G7:"F7",G8:"F8",H1:"G1",H2:"G2",H3:"G3",H4:"G4",H5:"G5",H6:"G6",H7:"G7",H8:"G8"},RIGHT:{A1:"B1",A2:"B2",A3:"B3",A4:"B4",A5:"B5",A6:"B6",A7:"B7",A8:"B8",B1:"C1",B2:"C2",B3:"C3",B4:"C4",B5:"C5",B6:"C6",B7:"C7",B8:"C8",C1:"D1",C2:"D2",C3:"D3",C4:"D4",C5:"D5",C6:"D6",C7:"D7",C8:"D8",D1:"E1",D2:"E2",D3:"E3",D4:"E4",D5:"E5",D6:"E6",D7:"E7",D8:"E8",E1:"F1",E2:"F2",E3:"F3",E4:"F4",E5:"F5",E6:"F6",E7:"F7",E8:"F8",F1:"G1",F2:"G2",F3:"G3",F4:"G4",F5:"G5",F6:"G6",F7:"G7",F8:"G8",G1:"H1",G2:"H2",G3:"H3",G4:"H4",G5:"H5",G6:"H6",G7:"H7",G8:"H8",H1:null,H2:null,H3:null,H4:null,H5:null,H6:null,H7:null,H8:null},UP_LEFT:{A1:null,A2:null,A3:null,A4:null,A5:null,A6:null,A7:null,A8:null,B1:"A2",B2:"A3",B3:"A4",B4:"A5",B5:"A6",B6:"A7",B7:"A8",B8:null,C1:"B2",C2:"B3",C3:"B4",C4:"B5",C5:"B6",C6:"B7",C7:"B8",C8:null,D1:"C2",D2:"C3",D3:"C4",D4:"C5",D5:"C6",D6:"C7",D7:"C8",D8:null,E1:"D2",E2:"D3",E3:"D4",E4:"D5",E5:"D6",E6:"D7",E7:"D8",E8:null,F1:"E2",F2:"E3",F3:"E4",F4:"E5",F5:"E6",F6:"E7",F7:"E8",F8:null,G1:"F2",G2:"F3",G3:"F4",G4:"F5",G5:"F6",G6:"F7",G7:"F8",G8:null,H1:"G2",H2:"G3",H3:"G4",H4:"G5",H5:"G6",H6:"G7",H7:"G8",H8:null},DOWN_RIGHT:{A1:null,A2:"B1",A3:"B2",A4:"B3",A5:"B4",A6:"B5",A7:"B6",A8:"B7",B1:null,B2:"C1",B3:"C2",B4:"C3",B5:"C4",B6:"C5",B7:"C6",B8:"C7",C1:null,C2:"D1",C3:"D2",C4:"D3",C5:"D4",C6:"D5",C7:"D6",C8:"D7",D1:null,D2:"E1",D3:"E2",D4:"E3",D5:"E4",D6:"E5",D7:"E6",D8:"E7",E1:null,E2:"F1",E3:"F2",E4:"F3",E5:"F4",E6:"F5",E7:"F6",E8:"F7",F1:null,F2:"G1",F3:"G2",F4:"G3",F5:"G4",F6:"G5",F7:"G6",F8:"G7",G1:null,G2:"H1",G3:"H2",G4:"H3",G5:"H4",G6:"H5",G7:"H6",G8:"H7",H1:null,H2:null,H3:null,H4:null,H5:null,H6:null,H7:null,H8:null},UP_RIGHT:{A1:"B2",A2:"B3",A3:"B4",A4:"B5",A5:"B6",A6:"B7",A7:"B8",A8:null,B1:"C2",B2:"C3",B3:"C4",B4:"C5",B5:"C6",B6:"C7",B7:"C8",B8:null,C1:"D2",C2:"D3",C3:"D4",C4:"D5",C5:"D6",C6:"D7",C7:"D8",C8:null,D1:"E2",D2:"E3",D3:"E4",D4:"E5",D5:"E6",D6:"E7",D7:"E8",D8:null,E1:"F2",E2:"F3",E3:"F4",E4:"F5",E5:"F6",E6:"F7",E7:"F8",E8:null,F1:"G2",F2:"G3",F3:"G4",F4:"G5",F5:"G6",F6:"G7",F7:"G8",F8:null,G1:"H2",G2:"H3",G3:"H4",G4:"H5",G5:"H6",G6:"H7",G7:"H8",G8:null,H1:null,H2:null,H3:null,H4:null,H5:null,H6:null,H7:null,H8:null},DOWN_LEFT:{A1:null,A2:null,A3:null,A4:null,A5:null,A6:null,A7:null,A8:null,B1:null,B2:"A1",B3:"A2",B4:"A3",B5:"A4",B6:"A5",B7:"A6",B8:"A7",C1:null,C2:"B1",C3:"B2",C4:"B3",C5:"B4",C6:"B5",C7:"B6",C8:"B7",D1:null,D2:"C1",D3:"C2",D4:"C3",D5:"C4",D6:"C5",D7:"C6",D8:"C7",E1:null,E2:"D1",E3:"D2",E4:"D3",E5:"D4",E6:"D5",E7:"D6",E8:"D7",F1:null,F2:"E1",F3:"E2",F4:"E3",F5:"E4",F6:"E5",F7:"E6",F8:"E7",G1:null,G2:"F1",G3:"F2",G4:"F3",G5:"F4",G6:"F5",G7:"F6",G8:"F7",H1:null,H2:"G1",H3:"G2",H4:"G3",H5:"G4",H6:"G5",H7:"G6",H8:"G7"}},C=[[0,0,0,0,0,0,0,0],[5,5,5,5,5,5,5,5],[1,1,2,3,3,2,1,1],[.5,.5,1,2.5,2.5,1,.5,.5],[0,0,0,2,2,0,0,0],[.5,0,1,0,0,1,0,.5],[.5,0,0,-2,-2,0,0,.5],[0,0,0,0,0,0,0,0]],P=[[-4,-3,-2,-2,-2,-2,-3,-4],[-3,-2,0,0,0,0,-2,-3],[-2,0,1,1.5,1.5,1,0,-2],[-2,.5,1.5,2,2,1.5,.5,-2],[-2,0,1.5,2,2,1.5,0,-2],[-2,.5,1,1.5,1.5,1,.5,-2],[-3,-2,0,.5,.5,0,-2,-3],[-4,-3,-2,-2,-2,-2,-3,-4]],p=[[-2,-1,-1,-1,-1,-1,-1,-2],[-1,0,0,0,0,0,0,-1],[-1,0,.5,1,1,.5,0,-1],[-1,.5,.5,1,1,.5,.5,-1],[-1,0,1,1,1,1,0,-1],[-1,1,1,1,1,1,1,-1],[-1,.5,0,0,0,0,.5,-1],[-2,-1,-1,-1,-1,-1,-1,-2]],E=[[0,0,0,0,0,0,0,0],[.5,1,1,1,1,1,1,.5],[-.5,0,0,0,0,0,0,-.5],[-.5,0,0,0,0,0,0,-.5],[-.5,0,0,0,0,0,0,-.5],[-.5,0,0,0,0,0,0,-.5],[-.5,0,0,0,0,0,0,-.5],[0,0,0,.5,.5,0,0,0]],B=[[-3,-4,-4,-5,-5,-4,-4,-3],[-3,-4,-4,-5,-5,-4,-4,-3],[-3,-4,-4,-5,-5,-4,-4,-3],[-3,-4,-4,-5,-5,-4,-4,-3],[-2,-3,-3,-4,-4,-3,-3,-2],[-1,-2,-2,-2,-2,-2,-2,-1],[2,2,0,0,0,0,2,2],[2,3,1,0,0,1,3,2]],F=[[-2,-1,-1,-.5,-.5,-1,-1,-2],[-1,0,0,0,0,0,0,-1],[-1,0,.5,.5,.5,.5,0,-1],[-.5,0,.5,.5,.5,.5,0,-.5],[0,0,.5,.5,.5,.5,0,-.5],[-1,.5,.5,.5,.5,.5,0,-1],[-1,0,.5,0,0,0,0,-1],[-2,-1,-1,-.5,-.5,-1,-1,-2]],G={P:C.slice().reverse(),p:C,N:P.slice().reverse(),n:P,B:p.slice().reverse(),b:p,R:E.slice().reverse(),r:E,K:B.slice().reverse(),k:B,Q:F.slice().reverse(),q:F};function D(t){return f.UP[t]}function A(t){return f.DOWN[t]}function H(t){return f.LEFT[t]}function b(t){return f.RIGHT[t]}function d(t){return f.UP_LEFT[t]}function k(t){return f.UP_RIGHT[t]}function v(t){return f.DOWN_LEFT[t]}function y(t){return f.DOWN_RIGHT[t]}function w(t){const e=d(t);return e?D(e):null}function O(t){const e=d(t);return e?H(e):null}function L(t){const e=k(t);return e?D(e):null}function m(t){const e=k(t);return e?b(e):null}function M(t){const e=v(t);return e?A(e):null}function K(t){const e=v(t);return e?H(e):null}function N(t){const e=y(t);return e?A(e):null}function S(t){const e=y(t);return e?b(e):null}function j(t,e){return e===c?f.UP[t]:f.DOWN[t]}function _(t,e){return e===c?f.UP_LEFT[t]:f.DOWN_RIGHT[t]}function W(t,e){return e===c?f.UP_RIGHT[t]:f.DOWN_LEFT[t]}function U(t,e){return e===c?f.DOWN_LEFT[t]:f.UP_RIGHT[t]}function R(t,e){return e===c?f.DOWN_RIGHT[t]:f.UP_LEFT[t]}function T(t){return{k:10,q:9,r:5,b:3,n:3,p:1}[t.toLowerCase()]||0}function I(t){return"string"==typeof t&&t.match("^[a-hA-H]{1}[1-8]{1}$")}const x=-1e3,Q=1e3;class q{constructor(t=JSON.parse(JSON.stringify(g))){if("object"==typeof t)this.configuration=Object.assign({},h,t);else{if("string"!=typeof t)throw new Error(`Unknown configuration type ${typeof config}.`);this.configuration=Object.assign({},h,function(t=""){const[e,i,s,l,a,u]=t.split(" "),h={pieces:Object.fromEntries(e.split("/").flatMap((t,e)=>{let i=0;return t.split("").reduce((t,s)=>{const r=s.match(/k|b|q|n|p|r/i);r&&(t.push([`${n[i]}${o[7-e]}`,r[0]]),i+=1);const c=s.match(/[1-8]/);return c&&(i+=Number(c)),t},[])}))};return h.turn="b"===i?r:c,h.castling={whiteLong:!1,whiteShort:!1,blackLong:!1,blackShort:!1},s.includes("K")&&(h.castling.whiteShort=!0),s.includes("k")&&(h.castling.blackShort=!0),s.includes("Q")&&(h.castling.whiteLong=!0),s.includes("q")&&(h.castling.blackLong=!0),I(l)&&(h.enPassant=l.toUpperCase()),h.halfMove=parseInt(a),h.fullMove=parseInt(u),h}(t))}this.configuration.castling||(this.configuration.castling={whiteShort:!0,blackShort:!0,whiteLong:!0,blackLong:!0}),this.history=[]}getAttackingFields(t=this.getPlayingColor()){let e=[];for(const i in this.configuration.pieces){const n=this.getPiece(i);this.getPieceColor(n)===t&&(e=[...e,...this.getPieceMoves(n,i)])}return e}isAttackingKing(t=this.getPlayingColor()){let e=null;for(const i in this.configuration.pieces){const n=this.getPiece(i);if(this.isKing(n)&&this.getPieceColor(n)!==t){e=i;break}}return this.isPieceUnderAttack(e)}isPieceUnderAttack(t){const e=this.getPieceOnLocationColor(t),i=this.getEnemyColor(e);let n=!1,o=t,s=0;for(;D(o)&&!n;){o=D(o),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isRook(t)||this.isQueen(t)||this.isKing(t)&&1===s)&&(n=!0),t)break}for(o=t,s=0;A(o)&&!n;){o=A(o),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isRook(t)||this.isQueen(t)||this.isKing(t)&&1===s)&&(n=!0),t)break}for(o=t,s=0;H(o)&&!n;){o=H(o),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isRook(t)||this.isQueen(t)||this.isKing(t)&&1===s)&&(n=!0),t)break}for(o=t,s=0;b(o)&&!n;){o=b(o),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isRook(t)||this.isQueen(t)||this.isKing(t)&&1===s)&&(n=!0),t)break}for(o=t,s=0;W(o,e)&&!n;){o=W(o,e),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isBishop(t)||this.isQueen(t)||1===s&&(this.isKing(t)||this.isPawn(t)))&&(n=!0),t)break}for(o=t,s=0;_(o,e)&&!n;){o=_(o,e),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isBishop(t)||this.isQueen(t)||1===s&&(this.isKing(t)||this.isPawn(t)))&&(n=!0),t)break}for(o=t,s=0;R(o,e)&&!n;){o=R(o,e),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isBishop(t)||this.isQueen(t)||this.isKing(t)&&1===s)&&(n=!0),t)break}for(o=t,s=0;U(o,e)&&!n;){o=U(o,e),s++;const t=this.getPiece(o);if(t&&this.getPieceColor(t)===i&&(this.isBishop(t)||this.isQueen(t)||this.isKing(t)&&1===s)&&(n=!0),t)break}o=L(t);let r=this.getPiece(o);return r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=m(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=O(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=w(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=M(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=K(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=N(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),o=S(t),r=this.getPiece(o),r&&this.getPieceColor(r)===i&&this.isKnight(r)&&(n=!0),n}hasPlayingPlayerCheck(){return this.isAttackingKing(this.getNonPlayingColor())}hasNonPlayingPlayerCheck(){return this.isAttackingKing(this.getPlayingColor())}getLowestValuePieceAttackingLocation(t,e=this.getPlayingColor()){let i=null;for(const n in this.configuration.pieces){const o=this.getPiece(n);this.getPieceColor(o)===e&&this.getPieceMoves(o,n).map(e=>{e===t&&(null===i||T(o)<i)&&(i=T(o))})}return i}getMoves(t=this.getPlayingColor(),e=null){const i={};let n=0;for(const e in this.configuration.pieces){const o=this.getPiece(e);if(this.getPieceColor(o)===t){const t=this.getPieceMoves(o,e);t.length&&n++,Object.assign(i,{[e]:t})}}const o=this.getAttackingFields(this.getNonPlayingColor());if(this.isLeftCastlingPossible(o)&&(this.isPlayingWhite()&&i.E1.push("C1"),this.isPlayingBlack()&&i.E8.push("C8")),this.isRightCastlingPossible(o)&&(this.isPlayingWhite()&&i.E1.push("G1"),this.isPlayingBlack()&&i.E8.push("G8")),e&&n>e)return i;const s={};for(const t in i)i[t].map(e=>{const i={pieces:Object.assign({},this.configuration.pieces),castling:Object.assign({},this.configuration.castling)},n=new q(i);n.move(t,e),(this.isPlayingWhite()&&!n.isAttackingKing(r)||this.isPlayingBlack()&&!n.isAttackingKing(c))&&(s[t]||(s[t]=[]),s[t].push(e))});return Object.keys(s).length||(this.configuration.isFinished=!0,this.hasPlayingPlayerCheck()&&(this.configuration.checkMate=!0)),s}isLeftCastlingPossible(t){if(this.isPlayingWhite()&&!this.configuration.castling.whiteLong)return!1;if(this.isPlayingBlack()&&!this.configuration.castling.blackLong)return!1;let e=null;if(this.isPlayingWhite()&&"K"===this.getPiece("E1")&&"R"===this.getPiece("A1")&&!t.includes("E1")?e="E1":this.isPlayingBlack()&&"k"===this.getPiece("E8")&&"r"===this.getPiece("A8")&&!t.includes("E8")&&(e="E8"),!e)return!1;let i=H(e);return!this.getPiece(i)&&!t.includes(i)&&(i=H(i),!this.getPiece(i)&&!t.includes(i)&&(i=H(i),!this.getPiece(i)))}isRightCastlingPossible(t){if(this.isPlayingWhite()&&!this.configuration.castling.whiteShort)return!1;if(this.isPlayingBlack()&&!this.configuration.castling.blackShort)return!1;let e=null;if(this.isPlayingWhite()&&"K"===this.getPiece("E1")&&"R"===this.getPiece("H1")&&!t.includes("E1")?e="E1":this.isPlayingBlack()&&"k"===this.getPiece("E8")&&"r"===this.getPiece("H8")&&!t.includes("E8")&&(e="E8"),!e)return!1;let i=b(e);return!this.getPiece(i)&&!t.includes(i)&&(i=b(i),!this.getPiece(i)&&!t.includes(i))}getPieceMoves(t,e){return this.isPawn(t)?this.getPawnMoves(t,e):this.isKnight(t)?this.getKnightMoves(t,e):this.isRook(t)?this.getRookMoves(t,e):this.isBishop(t)?this.getBishopMoves(t,e):this.isQueen(t)?this.getQueenMoves(t,e):this.isKing(t)?this.getKingMoves(t,e):[]}isPawn(t){return"P"===t.toUpperCase()}isKnight(t){return"N"===t.toUpperCase()}isRook(t){return"R"===t.toUpperCase()}isBishop(t){return"B"===t.toUpperCase()}isQueen(t){return"Q"===t.toUpperCase()}isKing(t){return"K"===t.toUpperCase()}getPawnMoves(t,e){const i=[],n=this.getPieceColor(t);let o=j(e,n);return o&&!this.getPiece(o)&&(i.push(o),o=j(o,n),function(t,e){if(t===c&&"2"===e[1])return!0;if(t===r&&"7"===e[1])return!0;return!1}(n,e)&&o&&!this.getPiece(o)&&i.push(o)),o=_(e,n),o&&(this.getPiece(o)&&this.getPieceOnLocationColor(o)!==n||o===this.configuration.enPassant)&&i.push(o),o=W(e,n),o&&(this.getPiece(o)&&this.getPieceOnLocationColor(o)!==n||o===this.configuration.enPassant)&&i.push(o),i}getKnightMoves(t,e){const i=[],n=this.getPieceColor(t);let o=L(e);return o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=m(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=w(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=O(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=K(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=M(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=S(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=N(e),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),i}getRookMoves(t,e){const i=[],n=this.getPieceColor(t);let o=e;for(;D(o);){o=D(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}for(o=e;A(o);){o=A(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}for(o=e;b(o);){o=b(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}for(o=e;H(o);){o=H(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}return i}getBishopMoves(t,e){const i=[],n=this.getPieceColor(t);let o=e;for(;d(o);){o=d(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}for(o=e;k(o);){o=k(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}for(o=e;v(o);){o=v(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}for(o=e;y(o);){o=y(o);const t=this.getPieceOnLocationColor(o);if(this.getPieceOnLocationColor(o)!==n&&i.push(o),t)break}return i}getQueenMoves(t,e){return[...this.getRookMoves(t,e),...this.getBishopMoves(t,e)]}getKingMoves(t,e){const i=[],n=this.getPieceColor(t);let o=e;return o=D(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=b(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=A(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=H(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=d(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=k(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=v(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),o=e,o=y(o),o&&this.getPieceOnLocationColor(o)!==n&&i.push(o),i}getPieceColor(t){return t.toUpperCase()===t?c:r}getPieceOnLocationColor(t){const e=this.getPiece(t);return e?e.toUpperCase()===e?c:r:null}getPiece(t){return this.configuration.pieces[t]}setPiece(t,e){if(!function(t){return Object.values(s).includes(t)}(e))throw new Error("Invalid piece "+e);if(!I(t))throw new Error("Invalid location "+t);this.configuration.pieces[t.toUpperCase()]=e}removePiece(t){if(!I(t))throw new Error("Invalid location "+t);delete this.configuration.pieces[t.toUpperCase()]}isEmpty(t){if(!I(t))throw new Error("Invalid location "+t);return!this.configuration.pieces[t.toUpperCase()]}getEnemyColor(t){return t===c?r:c}getPlayingColor(){return this.configuration.turn}getNonPlayingColor(){return this.isPlayingWhite()?r:c}isPlayingWhite(){return this.configuration.turn===c}isPlayingBlack(){return this.configuration.turn===r}addMoveToHistory(t,e){const i=JSON.parse(JSON.stringify(this.configuration));i.check=this.hasPlayingPlayerCheck(),this.history.push({from:t,to:e,configuration:i})}move(t,e){const i=this.getPiece(t),n=this.getPiece(e);if(!i)throw new Error("There is no piece at "+t);var o,s;if(Object.assign(this.configuration.pieces,{[e]:i}),delete this.configuration.pieces[t],this.isPlayingWhite()&&this.isPawn(i)&&"8"===e[1]&&Object.assign(this.configuration.pieces,{[e]:"Q"}),this.isPlayingBlack()&&this.isPawn(i)&&"1"===e[1]&&Object.assign(this.configuration.pieces,{[e]:"q"}),this.isPawn(i)&&e===this.configuration.enPassant&&delete this.configuration.pieces[(o=e,s=this.getPlayingColor(),s===c?f.DOWN[o]:f.UP[o])],this.isPawn(i)&&this.isPlayingWhite()&&"2"===t[1]&&"4"===e[1]?this.configuration.enPassant=t[0]+"3":this.isPawn(i)&&this.isPlayingBlack()&&"7"===t[1]&&"5"===e[1]?this.configuration.enPassant=t[0]+"6":this.configuration.enPassant=null,"E1"===t&&Object.assign(this.configuration.castling,{whiteLong:!1,whiteShort:!1}),"E8"===t&&Object.assign(this.configuration.castling,{blackLong:!1,blackShort:!1}),"A1"===t&&Object.assign(this.configuration.castling,{whiteLong:!1}),"H1"===t&&Object.assign(this.configuration.castling,{whiteShort:!1}),"A8"===t&&Object.assign(this.configuration.castling,{blackLong:!1}),"H8"===t&&Object.assign(this.configuration.castling,{blackShort:!1}),this.isKing(i)){if("E1"===t&&"C1"===e)return this.move("A1","D1");if("E8"===t&&"C8"===e)return this.move("A8","D8");if("E1"===t&&"G1"===e)return this.move("H1","F1");if("E8"===t&&"G8"===e)return this.move("H8","F8")}this.configuration.turn=this.isPlayingWhite()?r:c,this.isPlayingWhite()&&this.configuration.fullMove++,this.configuration.halfMove++,(n||this.isPawn(i))&&(this.configuration.halfMove=0)}exportJson(){return{moves:this.getMoves(),pieces:this.configuration.pieces,turn:this.configuration.turn,isFinished:this.configuration.isFinished,check:this.hasPlayingPlayerCheck(),checkMate:this.configuration.checkMate,castling:this.configuration.castling,enPassant:this.configuration.enPassant,halfMove:this.configuration.halfMove,fullMove:this.configuration.fullMove}}calculateAiMove(t){return this.calculateAiMoves(t)[0]}calculateAiMoves(t){if(t=parseInt(t),!l.includes(t))throw new Error(`Invalid level ${t}. You can choose ${l.join(",")}`);this.shouldIncreaseLevel()&&t++;const e=[],i=this.calculateScore(this.getPlayingColor()),n=this.getMoves();for(const o in n)n[o].map(n=>{const s=this.getTestBoard(),r=Boolean(s.getPiece(n));s.move(o,n),e.push({from:o,to:n,score:s.testMoveScores(this.getPlayingColor(),t,r,r?s.calculateScore(this.getPlayingColor()):i,n).score+s.calculateScoreByPiecesLocation(this.getPlayingColor())+Math.floor(Math.random()*(this.configuration.halfMove>10?this.configuration.halfMove-10:1)*10)/10})});return e.sort((t,e)=>t.score<e.score?1:t.score>e.score?-1:0),e}shouldIncreaseLevel(){return this.getIngamePiecesValue()<50}getIngamePiecesValue(){let t=0;for(const e in this.configuration.pieces){t+=T(this.getPiece(e))}return t}getTestBoard(){const t={pieces:Object.assign({},this.configuration.pieces),castling:Object.assign({},this.configuration.castling),turn:this.configuration.turn,enPassant:this.configuration.enPassant};return new q(t)}testMoveScores(t,e,i,n,o,s=1){let r=null;if(s<u[e]&&this.hasPlayingPlayerCheck()?r=this.getMoves(this.getPlayingColor()):(s<a[e]||i&&s<u[e])&&(r=this.getMoves(this.getPlayingColor(),5)),this.configuration.isFinished)return{score:this.calculateScore(t)+(this.getPlayingColor()===t?s:-s),max:!0};if(!r){if(null!==n)return{score:n,max:!1};return{score:this.calculateScore(t),max:!1}}let c=this.getPlayingColor()===t?x:Q,l=!1;for(const i in r)l||r[i].map(o=>{if(l)return;const r=this.getTestBoard(),a=Boolean(r.getPiece(o));if(r.move(i,o),r.hasNonPlayingPlayerCheck())return;const u=r.testMoveScores(t,e,a,a?r.calculateScore(t):n,o,s+1);u.max&&(l=!0),c=this.getPlayingColor()===t?Math.max(c,u.score):Math.min(c,u.score)});return{score:c,max:!1}}calculateScoreByPiecesLocation(t=this.getPlayingColor()){const e={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7};let i=0;for(const n in this.configuration.pieces){const o=this.getPiece(n);if(G[o]){const s=G[o][n[1]-1][e[n[0]]];i+=.5*(this.getPieceColor(o)===t?s:-s)}}return i}calculateScore(t=this.getPlayingColor()){let e=0;if(this.configuration.checkMate)return this.getPlayingColor()===t?x:Q;if(this.configuration.isFinished)return this.getPlayingColor()===t?Q:x;for(const i in this.configuration.pieces){const n=this.getPiece(i);this.getPieceColor(n)===t?e+=10*T(n):e-=10*T(n)}return e}}class ${constructor(t){this.board=new q(t)}move(t,e){t=t.toUpperCase(),e=e.toUpperCase();const i=this.board.getMoves();if(!i[t]||!i[t].includes(e))throw new Error(`Invalid move from ${t} to ${e} for ${this.board.getPlayingColor()}`);return this.board.addMoveToHistory(t,e),this.board.move(t,e),{[t]:e}}moves(t=null){return(t?this.board.getMoves()[t.toUpperCase()]:this.board.getMoves())||[]}setPiece(t,e){this.board.setPiece(t,e)}removePiece(t){this.board.removePiece(t)}aiMove(t=2){const e=this.board.calculateAiMove(t);return this.move(e.from,e.to)}getHistory(t=!1){return t?this.board.history.reverse():this.board.history}printToConsole(){!function(t){process.stdout.write("\n");let e=c;Object.assign([],o).reverse().map(i=>{process.stdout.write(""+i),n.map(n=>{switch(t.pieces[`${n}${i}`]){case"K":process.stdout.write("♚");break;case"Q":process.stdout.write("♛");break;case"R":process.stdout.write("♜");break;case"B":process.stdout.write("♝");break;case"N":process.stdout.write("♞");break;case"P":process.stdout.write("♟");break;case"k":process.stdout.write("♔");break;case"q":process.stdout.write("♕");break;case"r":process.stdout.write("♖");break;case"b":process.stdout.write("♗");break;case"n":process.stdout.write("♘");break;case"p":process.stdout.write("♙");break;default:process.stdout.write(e===c?"█":"░")}e=e===c?r:c}),e=e===c?r:c,process.stdout.write("\n")}),process.stdout.write(" "),n.map(t=>{process.stdout.write(""+t)}),process.stdout.write("\n")}(this.board.configuration)}exportJson(){return this.board.exportJson()}exportFEN(){return function(t){let e="";Object.assign([],o).reverse().map(i=>{let o=0;i<8&&(e+="/"),n.map(n=>{const s=t.pieces[`${n}${i}`];s?(o&&(e+=o.toString(),o=0),e+=s):o++}),e+=""+(o||"")}),e+=t.turn===c?" w ":" b ";const{whiteShort:i,whiteLong:s,blackLong:r,blackShort:l}=t.castling;return s||i||r||l?(i&&(e+="K"),s&&(e+="Q"),l&&(e+="k"),r&&(e+="q")):e+="-",e+=" "+(t.enPassant?t.enPassant.toLowerCase():"-"),e+=" "+t.halfMove,e+=" "+t.fullMove,e}(this.board.configuration)}}function J(t){if(!t)throw new Error("Configuration param required.");return new $(t).moves()}function V(t){if(!t)throw new Error("Configuration param required.");return new $(t).exportJson()}function Y(t){if(!t)throw new Error("Configuration param required.");return new $(t).exportFEN()}function z(t,e,i){if(!t)throw new Error("Configuration param required.");const n=new $(t);return n.move(e,i),"object"==typeof t?n.exportJson():n.exportFEN()}function X(t,e=2){if(!t)throw new Error("Configuration param required.");const i=new $(t).board.calculateAiMove(e);return{[i.from]:i.to}}}])}));