shogiops 0.2.8 → 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.
- package/attacks.js +32 -48
- package/attacks.js.map +1 -1
- package/board.d.ts +3 -0
- package/board.js +60 -33
- package/board.js.map +1 -1
- package/compat.d.ts +6 -24
- package/compat.js +20 -185
- package/compat.js.map +1 -1
- package/debug.js +37 -72
- package/debug.js.map +1 -1
- package/hand.d.ts +38 -0
- package/hand.js +69 -0
- package/hand.js.map +1 -0
- package/hash.d.ts +4 -3
- package/hash.js +12 -20
- package/hash.js.map +1 -1
- package/index.d.ts +13 -10
- package/index.js +22 -64
- package/index.js.map +1 -1
- package/{csa.d.ts → notation/csa/csa.d.ts} +9 -9
- package/notation/csa/csa.js +213 -0
- package/notation/csa/csa.js.map +1 -0
- package/notation/japanese.d.ts +3 -0
- package/notation/japanese.js +61 -0
- package/notation/japanese.js.map +1 -0
- package/{kif.d.ts → notation/kif/kif.d.ts} +10 -9
- package/notation/kif/kif.js +232 -0
- package/notation/kif/kif.js.map +1 -0
- package/{kifHandicaps.d.ts → notation/kif/kifHandicaps.d.ts} +0 -0
- package/{kifHandicaps.js → notation/kif/kifHandicaps.js} +7 -7
- package/notation/kif/kifHandicaps.js.map +1 -0
- package/notation/kitaoKawasaki.d.ts +3 -0
- package/notation/kitaoKawasaki.js +26 -0
- package/notation/kitaoKawasaki.js.map +1 -0
- package/notation/kitaokawasaki.d.ts +0 -0
- package/notation/kitaokawasaki.js +2 -0
- package/notation/kitaokawasaki.js.map +1 -0
- package/notation/notationUtil.d.ts +12 -0
- package/{kifUtil.js → notation/notationUtil.js} +39 -40
- package/notation/notationUtil.js.map +1 -0
- package/notation/western.d.ts +3 -0
- package/notation/western.js +23 -0
- package/notation/western.js.map +1 -0
- package/notation/westernEngine.d.ts +3 -0
- package/notation/westernEngine.js +23 -0
- package/notation/westernEngine.js.map +1 -0
- package/package.json +54 -37
- package/setup.d.ts +2 -32
- package/setup.js +5 -80
- package/setup.js.map +1 -1
- package/sfen.d.ts +33 -0
- package/sfen.js +188 -0
- package/sfen.js.map +1 -0
- package/shogi.d.ts +14 -7
- package/shogi.js +138 -141
- package/shogi.js.map +1 -1
- package/squareSet.d.ts +1 -5
- package/squareSet.js +1 -18
- package/squareSet.js.map +1 -1
- package/src/board.ts +34 -0
- package/src/compat.ts +18 -197
- package/src/debug.ts +26 -56
- package/src/hand.ts +94 -0
- package/src/hash.ts +8 -7
- package/src/index.ts +16 -12
- package/src/{csa.ts → notation/csa/csa.ts} +53 -52
- package/src/notation/japanese.ts +74 -0
- package/src/{kif.ts → notation/kif/kif.ts} +77 -78
- package/src/{kifHandicaps.ts → notation/kif/kifHandicaps.ts} +5 -0
- package/src/notation/kitaoKawasaki.ts +24 -0
- package/src/{kifUtil.ts → notation/notationUtil.ts} +37 -28
- package/src/notation/western.ts +21 -0
- package/src/notation/westernEngine.ts +21 -0
- package/src/setup.ts +4 -91
- package/src/sfen.ts +190 -0
- package/src/shogi.ts +75 -75
- package/src/squareSet.ts +1 -18
- package/src/transform.ts +3 -1
- package/src/types.ts +13 -16
- package/src/util.ts +8 -73
- package/src/variant.ts +44 -3
- package/src/variantUtil.ts +160 -0
- package/transform.js +18 -24
- package/transform.js.map +1 -1
- package/types.d.ts +3 -7
- package/types.js +18 -24
- package/types.js.map +1 -1
- package/util.d.ts +4 -7
- package/util.js +24 -96
- package/util.js.map +1 -1
- package/variant.d.ts +12 -1
- package/variant.js +42 -16
- package/variant.js.map +1 -1
- package/variantUtil.d.ts +13 -0
- package/variantUtil.js +147 -0
- package/variantUtil.js.map +1 -0
- package/csa.js +0 -229
- package/csa.js.map +0 -1
- package/csaUtil.d.ts +0 -3
- package/csaUtil.js +0 -21
- package/csaUtil.js.map +0 -1
- package/fen.d.ts +0 -32
- package/fen.js +0 -197
- package/fen.js.map +0 -1
- package/kif.js +0 -247
- package/kif.js.map +0 -1
- package/kifHandicaps.js.map +0 -1
- package/kifUtil.d.ts +0 -9
- package/kifUtil.js.map +0 -1
- package/san.d.ts +0 -6
- package/san.js +0 -135
- package/san.js.map +0 -1
- package/src/csaUtil.ts +0 -15
- package/src/fen.ts +0 -183
- package/src/san.ts +0 -136
package/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.js","sourceRoot":"","sources":["src/compat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["src/compat.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAQ,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvD,MAAM,UAAU,gBAAgB,CAAC,GAAa;IAC5C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC/C,IAAI,OAAO,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;SACjC;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAa,EAAE,IAAW;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,IAAI,IAAI,EAAE;QACR,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,CAAC,GAAG,KAAK,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,CAAC;IAC3B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAU;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,QAAQ,OAAO,EAAE;QACf,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,OAAO,CAAC;KAClB;AACH,CAAC"}
|
package/debug.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const util_1 = require("./util");
|
|
6
|
-
const fen_1 = require("./fen");
|
|
7
|
-
const squareSet_1 = require("./squareSet");
|
|
8
|
-
function squareSet(squares) {
|
|
1
|
+
import { makeSquare, makeUsi } from './util';
|
|
2
|
+
import { makePiece } from './sfen';
|
|
3
|
+
import { pieceCanPromote, pieceInDeadZone } from './variantUtil';
|
|
4
|
+
export function squareSet(squares) {
|
|
9
5
|
const r = [];
|
|
10
6
|
for (let y = 8; y >= 0; y--) {
|
|
11
7
|
for (let x = 0; x < 9; x++) {
|
|
@@ -16,12 +12,10 @@ function squareSet(squares) {
|
|
|
16
12
|
}
|
|
17
13
|
return r.join('');
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return fen_1.makePiece(piece);
|
|
15
|
+
export function piece(piece) {
|
|
16
|
+
return makePiece(piece);
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
function board(board) {
|
|
18
|
+
export function board(board) {
|
|
25
19
|
const r = [];
|
|
26
20
|
for (let y = 8; y >= 0; y--) {
|
|
27
21
|
for (let x = 0; x < 9; x++) {
|
|
@@ -34,84 +28,55 @@ function board(board) {
|
|
|
34
28
|
}
|
|
35
29
|
return r.join('');
|
|
36
30
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return util_1.makeSquare(sq);
|
|
31
|
+
export function square(sq) {
|
|
32
|
+
return makeSquare(sq);
|
|
40
33
|
}
|
|
41
|
-
|
|
42
|
-
function dests(dests) {
|
|
34
|
+
export function dests(dests) {
|
|
43
35
|
const lines = [];
|
|
44
36
|
for (const [from, to] of dests) {
|
|
45
|
-
lines.push(`${
|
|
37
|
+
lines.push(`${makeSquare(from)}: ${Array.from(to, square).join(' ')}`);
|
|
46
38
|
}
|
|
47
39
|
return lines.join('\n');
|
|
48
40
|
}
|
|
49
|
-
|
|
50
|
-
function perft(pos, depth, log = false) {
|
|
41
|
+
export function perft(pos, depth, log = false) {
|
|
51
42
|
if (depth < 1)
|
|
52
43
|
return 1;
|
|
53
44
|
const ctx = pos.ctx();
|
|
54
45
|
const dropDests = pos.allDropDests(ctx);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? to
|
|
64
|
-
: to.intersect(squareSet_1.SquareSet.promotionZone(pos.turn));
|
|
65
|
-
const forceProm = role === 'pawn' || role === 'lance'
|
|
66
|
-
? squareSet_1.SquareSet.backrank(pos.turn)
|
|
67
|
-
: role === 'knight'
|
|
68
|
-
? squareSet_1.SquareSet.backrank2(pos.turn)
|
|
69
|
-
: squareSet_1.SquareSet.empty();
|
|
70
|
-
nodes += promMoves.diff(forceProm).size();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return nodes;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
let nodes = 0;
|
|
77
|
-
for (const [from, dests] of pos.allDests(ctx)) {
|
|
78
|
-
for (const to of dests) {
|
|
79
|
-
const promotions = [];
|
|
80
|
-
const role = pos.board.get(from).role;
|
|
81
|
-
const canPromote = types_1.PROMOTABLE_ROLES.includes(role) &&
|
|
82
|
-
(squareSet_1.SquareSet.promotionZone(pos.turn).has(to) || squareSet_1.SquareSet.promotionZone(pos.turn).has(from));
|
|
83
|
-
if (canPromote) {
|
|
84
|
-
promotions.push(true);
|
|
85
|
-
if (!(((role === 'pawn' || role === 'lance') && squareSet_1.SquareSet.backrank(pos.turn).has(to)) ||
|
|
86
|
-
(role === 'knight' && squareSet_1.SquareSet.backrank2(pos.turn).has(to))))
|
|
87
|
-
promotions.push(false);
|
|
88
|
-
}
|
|
89
|
-
else
|
|
46
|
+
let nodes = 0;
|
|
47
|
+
for (const [from, dests] of pos.allDests(ctx)) {
|
|
48
|
+
for (const to of dests) {
|
|
49
|
+
const promotions = [];
|
|
50
|
+
const piece = pos.board.get(from);
|
|
51
|
+
if (pieceCanPromote(pos.rules)(piece, from, to)) {
|
|
52
|
+
promotions.push(true);
|
|
53
|
+
if (!pieceInDeadZone(pos.rules)(piece, to))
|
|
90
54
|
promotions.push(false);
|
|
91
|
-
for (const promotion of promotions) {
|
|
92
|
-
const child = pos.clone();
|
|
93
|
-
const move = { from, to, promotion };
|
|
94
|
-
child.play(move);
|
|
95
|
-
const children = perft(child, depth - 1, false);
|
|
96
|
-
if (log)
|
|
97
|
-
console.log(util_1.makeUsi(move), children);
|
|
98
|
-
nodes += children;
|
|
99
|
-
}
|
|
100
55
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
for (const
|
|
56
|
+
else
|
|
57
|
+
promotions.push(false);
|
|
58
|
+
for (const promotion of promotions) {
|
|
104
59
|
const child = pos.clone();
|
|
105
|
-
const move = {
|
|
60
|
+
const move = { from, to, promotion };
|
|
106
61
|
child.play(move);
|
|
107
62
|
const children = perft(child, depth - 1, false);
|
|
108
63
|
if (log)
|
|
109
|
-
console.log(
|
|
64
|
+
console.log(makeUsi(move), children, '(', depth, ')');
|
|
110
65
|
nodes += children;
|
|
111
66
|
}
|
|
112
67
|
}
|
|
113
|
-
return nodes;
|
|
114
68
|
}
|
|
69
|
+
for (const [role, dropDestsOfRole] of dropDests) {
|
|
70
|
+
for (const to of dropDestsOfRole) {
|
|
71
|
+
const child = pos.clone();
|
|
72
|
+
const move = { role, to };
|
|
73
|
+
child.play(move);
|
|
74
|
+
const children = perft(child, depth - 1, false);
|
|
75
|
+
if (log)
|
|
76
|
+
console.log(makeUsi(move), children, '(', depth, ')');
|
|
77
|
+
nodes += children;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return nodes;
|
|
115
81
|
}
|
|
116
|
-
exports.perft = perft;
|
|
117
82
|
//# sourceMappingURL=debug.js.map
|
package/debug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["src/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["src/debug.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,UAAU,SAAS,CAAC,OAAkB;IAC1C,MAAM,CAAC,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,G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|
7
|
+
gold: number;
|
|
8
|
+
bishop: number;
|
|
9
|
+
rook: number;
|
|
10
|
+
tokin: number;
|
|
11
|
+
promotedlance: number;
|
|
12
|
+
promotedknight: number;
|
|
13
|
+
promotedsilver: number;
|
|
14
|
+
horse: number;
|
|
15
|
+
dragon: number;
|
|
16
|
+
king: number;
|
|
17
|
+
private constructor();
|
|
18
|
+
static empty(): Hand;
|
|
19
|
+
clone(): Hand;
|
|
20
|
+
equals(other: Hand): boolean;
|
|
21
|
+
add(other: Hand): Hand;
|
|
22
|
+
nonEmpty(): boolean;
|
|
23
|
+
isEmpty(): boolean;
|
|
24
|
+
count(): number;
|
|
25
|
+
[Symbol.iterator](): Iterator<[Role, number]>;
|
|
26
|
+
}
|
|
27
|
+
export declare class Hands {
|
|
28
|
+
gote: Hand;
|
|
29
|
+
sente: Hand;
|
|
30
|
+
constructor(gote: Hand, sente: Hand);
|
|
31
|
+
static empty(): Hands;
|
|
32
|
+
clone(): Hands;
|
|
33
|
+
equals(other: Hands): boolean;
|
|
34
|
+
add(other: Hands): Hands;
|
|
35
|
+
count(): number;
|
|
36
|
+
isEmpty(): boolean;
|
|
37
|
+
nonEmpty(): boolean;
|
|
38
|
+
}
|
package/hand.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ROLES } from './types';
|
|
2
|
+
// Hand alone can store anything
|
|
3
|
+
// let the variants decide what to store and what not
|
|
4
|
+
export class Hand {
|
|
5
|
+
constructor() { }
|
|
6
|
+
static empty() {
|
|
7
|
+
const m = new Hand();
|
|
8
|
+
for (const role of ROLES)
|
|
9
|
+
m[role] = 0;
|
|
10
|
+
return m;
|
|
11
|
+
}
|
|
12
|
+
clone() {
|
|
13
|
+
const m = new Hand();
|
|
14
|
+
for (const role of ROLES)
|
|
15
|
+
m[role] = this[role];
|
|
16
|
+
return m;
|
|
17
|
+
}
|
|
18
|
+
equals(other) {
|
|
19
|
+
return ROLES.every(role => this[role] === other[role]);
|
|
20
|
+
}
|
|
21
|
+
add(other) {
|
|
22
|
+
const m = new Hand();
|
|
23
|
+
for (const role of ROLES)
|
|
24
|
+
m[role] = this[role] + other[role];
|
|
25
|
+
return m;
|
|
26
|
+
}
|
|
27
|
+
nonEmpty() {
|
|
28
|
+
return ROLES.some(role => this[role] > 0);
|
|
29
|
+
}
|
|
30
|
+
isEmpty() {
|
|
31
|
+
return !this.nonEmpty();
|
|
32
|
+
}
|
|
33
|
+
count() {
|
|
34
|
+
return ROLES.map(role => this[role]).reduce((acc, cur) => acc + cur);
|
|
35
|
+
}
|
|
36
|
+
*[Symbol.iterator]() {
|
|
37
|
+
for (const role of ROLES.filter(r => this[r] > 0)) {
|
|
38
|
+
yield [role, this[role]];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class Hands {
|
|
43
|
+
constructor(gote, sente) {
|
|
44
|
+
this.gote = gote;
|
|
45
|
+
this.sente = sente;
|
|
46
|
+
}
|
|
47
|
+
static empty() {
|
|
48
|
+
return new Hands(Hand.empty(), Hand.empty());
|
|
49
|
+
}
|
|
50
|
+
clone() {
|
|
51
|
+
return new Hands(this.gote.clone(), this.sente.clone());
|
|
52
|
+
}
|
|
53
|
+
equals(other) {
|
|
54
|
+
return this.gote.equals(other.gote) && this.sente.equals(other.sente);
|
|
55
|
+
}
|
|
56
|
+
add(other) {
|
|
57
|
+
return new Hands(this.gote.add(other.gote), this.sente.add(other.sente));
|
|
58
|
+
}
|
|
59
|
+
count() {
|
|
60
|
+
return this.gote.count() + this.sente.count();
|
|
61
|
+
}
|
|
62
|
+
isEmpty() {
|
|
63
|
+
return this.gote.isEmpty() && this.sente.isEmpty();
|
|
64
|
+
}
|
|
65
|
+
nonEmpty() {
|
|
66
|
+
return !this.isEmpty();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=hand.js.map
|
package/hand.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hand.js","sourceRoot":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AAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAChD,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACrD,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF"}
|
package/hash.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Board } from './board';
|
|
2
|
-
import { Setup
|
|
2
|
+
import { Setup } from './setup';
|
|
3
|
+
import { Hand, Hands } from './hand';
|
|
3
4
|
export declare function fxhash32(word: number, state?: number): number;
|
|
4
5
|
export declare function hashBoard(board: Board, state?: number): number;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function hashHand(hand: Hand, state?: number): number;
|
|
7
|
+
export declare function hashHands(hands: Hands, state?: number): number;
|
|
7
8
|
export declare function hashSetup(setup: Setup, state?: number): number;
|
package/hash.js
CHANGED
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hashSetup = exports.hashMaterial = exports.hashMaterialSide = exports.hashBoard = exports.fxhash32 = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
1
|
+
import { COLORS, ROLES } from './types';
|
|
5
2
|
function rol32(n, left) {
|
|
6
3
|
return (n << left) | (n >>> (32 - left));
|
|
7
4
|
}
|
|
8
|
-
function fxhash32(word, state = 0) {
|
|
5
|
+
export function fxhash32(word, state = 0) {
|
|
9
6
|
return Math.imul(rol32(state, 5) ^ word, 0x9e3779b9);
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
function hashBoard(board, state = 0) {
|
|
8
|
+
export function hashBoard(board, state = 0) {
|
|
13
9
|
state = fxhash32(board.gote.lo, fxhash32(board.gote.mid, fxhash32(board.gote.hi, state)));
|
|
14
|
-
for (const role of
|
|
10
|
+
for (const role of ROLES)
|
|
15
11
|
state = fxhash32(board[role].lo, fxhash32(board[role].mid, fxhash32(board[role].hi, state)));
|
|
16
12
|
return state;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
state = fxhash32(side[role], state);
|
|
14
|
+
export function hashHand(hand, state = 0) {
|
|
15
|
+
for (const role of ROLES)
|
|
16
|
+
state = fxhash32(hand[role], state);
|
|
22
17
|
return state;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
state = hashMaterialSide(material[color], state);
|
|
19
|
+
export function hashHands(hands, state = 0) {
|
|
20
|
+
for (const color of COLORS)
|
|
21
|
+
state = hashHand(hands[color], state);
|
|
28
22
|
return state;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
|
-
function hashSetup(setup, state = 0) {
|
|
24
|
+
export function hashSetup(setup, state = 0) {
|
|
32
25
|
state = hashBoard(setup.board, state);
|
|
33
|
-
state =
|
|
26
|
+
state = hashHands(setup.hands, state);
|
|
34
27
|
if (setup.turn === 'sente')
|
|
35
28
|
state = fxhash32(1, state);
|
|
36
29
|
return state;
|
|
37
30
|
}
|
|
38
|
-
exports.hashSetup = hashSetup;
|
|
39
31
|
//# sourceMappingURL=hash.js.map
|
package/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["src/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKxC,SAAS,KAAK,CAAC,CAAS,EAAE,IAAY;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,QAAQ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K,EAAE,KAAK,CAAC,CAAC;IACtC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,KAAK,GAAG,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
export { FILE_NAMES, RANK_NAMES, FileName, RankName, Square, SquareName, BySquare, Color, COLORS, ByColor, Role, ROLES,
|
|
2
|
-
export {
|
|
1
|
+
export { FILE_NAMES, RANK_NAMES, FileName, RankName, Square, SquareName, BySquare, Color, COLORS, ByColor, Role, ROLES, ByRole, Piece, NormalMove, DropMove, Move, isDrop, isNormal, Rules, RULES, Outcome, } from './types';
|
|
2
|
+
export { stringToRole, defined, makeSquare, makeUsi, opposite, parseSquare, parseUsi, roleToString, squareFile, squareRank, } from './util';
|
|
3
3
|
export { SquareSet } from './squareSet';
|
|
4
4
|
export { attacks, between, bishopAttacks, kingAttacks, knightAttacks, pawnAttacks, lanceAttacks, silverAttacks, goldAttacks, horseAttacks, dragonAttacks, ray, rookAttacks, } from './attacks';
|
|
5
5
|
export { Board } from './board';
|
|
6
|
-
export {
|
|
6
|
+
export { Setup, defaultSetup } from './setup';
|
|
7
7
|
export { IllegalSetup, Shogi, Position, PositionError, Context } from './shogi';
|
|
8
8
|
export * as compat from './compat';
|
|
9
9
|
export * as debug from './debug';
|
|
10
|
-
export * as
|
|
11
|
-
export * as handicaps from './kifHandicaps';
|
|
10
|
+
export * as sfen from './sfen';
|
|
11
|
+
export * as handicaps from './notation/kif/kifHandicaps';
|
|
12
|
+
export * as hand from './hand';
|
|
12
13
|
export * as hash from './hash';
|
|
13
|
-
export * as
|
|
14
|
-
export * as
|
|
15
|
-
export * as
|
|
16
|
-
export * as
|
|
17
|
-
export * as
|
|
14
|
+
export * as japanese from './notation/japanese';
|
|
15
|
+
export * as kitaoKawasaki from './notation/kitaoKawasaki';
|
|
16
|
+
export * as western from './notation/western';
|
|
17
|
+
export * as westernEngine from './notation/westernEngine';
|
|
18
|
+
export * as kif from './notation/kif/kif';
|
|
19
|
+
export * as csa from './notation/csa/csa';
|
|
18
20
|
export * as transform from './transform';
|
|
19
21
|
export * as variant from './variant';
|
|
22
|
+
export * as variantUtil from './variantUtil';
|
package/index.js
CHANGED
|
@@ -1,65 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(exports, "roleToChar", { enumerable: true, get: function () { return util_1.roleToChar; } });
|
|
24
|
-
Object.defineProperty(exports, "squareFile", { enumerable: true, get: function () { return util_1.squareFile; } });
|
|
25
|
-
Object.defineProperty(exports, "squareRank", { enumerable: true, get: function () { return util_1.squareRank; } });
|
|
26
|
-
var squareSet_1 = require("./squareSet");
|
|
27
|
-
Object.defineProperty(exports, "SquareSet", { enumerable: true, get: function () { return squareSet_1.SquareSet; } });
|
|
28
|
-
var attacks_1 = require("./attacks");
|
|
29
|
-
Object.defineProperty(exports, "attacks", { enumerable: true, get: function () { return attacks_1.attacks; } });
|
|
30
|
-
Object.defineProperty(exports, "between", { enumerable: true, get: function () { return attacks_1.between; } });
|
|
31
|
-
Object.defineProperty(exports, "bishopAttacks", { enumerable: true, get: function () { return attacks_1.bishopAttacks; } });
|
|
32
|
-
Object.defineProperty(exports, "kingAttacks", { enumerable: true, get: function () { return attacks_1.kingAttacks; } });
|
|
33
|
-
Object.defineProperty(exports, "knightAttacks", { enumerable: true, get: function () { return attacks_1.knightAttacks; } });
|
|
34
|
-
Object.defineProperty(exports, "pawnAttacks", { enumerable: true, get: function () { return attacks_1.pawnAttacks; } });
|
|
35
|
-
Object.defineProperty(exports, "lanceAttacks", { enumerable: true, get: function () { return attacks_1.lanceAttacks; } });
|
|
36
|
-
Object.defineProperty(exports, "silverAttacks", { enumerable: true, get: function () { return attacks_1.silverAttacks; } });
|
|
37
|
-
Object.defineProperty(exports, "goldAttacks", { enumerable: true, get: function () { return attacks_1.goldAttacks; } });
|
|
38
|
-
Object.defineProperty(exports, "horseAttacks", { enumerable: true, get: function () { return attacks_1.horseAttacks; } });
|
|
39
|
-
Object.defineProperty(exports, "dragonAttacks", { enumerable: true, get: function () { return attacks_1.dragonAttacks; } });
|
|
40
|
-
Object.defineProperty(exports, "ray", { enumerable: true, get: function () { return attacks_1.ray; } });
|
|
41
|
-
Object.defineProperty(exports, "rookAttacks", { enumerable: true, get: function () { return attacks_1.rookAttacks; } });
|
|
42
|
-
var board_1 = require("./board");
|
|
43
|
-
Object.defineProperty(exports, "Board", { enumerable: true, get: function () { return board_1.Board; } });
|
|
44
|
-
var setup_1 = require("./setup");
|
|
45
|
-
Object.defineProperty(exports, "Material", { enumerable: true, get: function () { return setup_1.Material; } });
|
|
46
|
-
Object.defineProperty(exports, "MaterialSide", { enumerable: true, get: function () { return setup_1.MaterialSide; } });
|
|
47
|
-
Object.defineProperty(exports, "defaultSetup", { enumerable: true, get: function () { return setup_1.defaultSetup; } });
|
|
48
|
-
var shogi_1 = require("./shogi");
|
|
49
|
-
Object.defineProperty(exports, "IllegalSetup", { enumerable: true, get: function () { return shogi_1.IllegalSetup; } });
|
|
50
|
-
Object.defineProperty(exports, "Shogi", { enumerable: true, get: function () { return shogi_1.Shogi; } });
|
|
51
|
-
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return shogi_1.Position; } });
|
|
52
|
-
Object.defineProperty(exports, "PositionError", { enumerable: true, get: function () { return shogi_1.PositionError; } });
|
|
53
|
-
exports.compat = require("./compat");
|
|
54
|
-
exports.debug = require("./debug");
|
|
55
|
-
exports.fen = require("./fen");
|
|
56
|
-
exports.handicaps = require("./kifHandicaps");
|
|
57
|
-
exports.hash = require("./hash");
|
|
58
|
-
exports.kif = require("./kif");
|
|
59
|
-
exports.kifUtil = require("./kifUtil");
|
|
60
|
-
exports.csa = require("./csa");
|
|
61
|
-
exports.csaUtil = require("./csaUtil");
|
|
62
|
-
exports.san = require("./san");
|
|
63
|
-
exports.transform = require("./transform");
|
|
64
|
-
exports.variant = require("./variant");
|
|
1
|
+
export { FILE_NAMES, RANK_NAMES, COLORS, ROLES, isDrop, isNormal, RULES, } from './types';
|
|
2
|
+
export { stringToRole, defined, makeSquare, makeUsi, opposite, parseSquare, parseUsi, roleToString, squareFile, squareRank, } from './util';
|
|
3
|
+
export { SquareSet } from './squareSet';
|
|
4
|
+
export { attacks, between, bishopAttacks, kingAttacks, knightAttacks, pawnAttacks, lanceAttacks, silverAttacks, goldAttacks, horseAttacks, dragonAttacks, ray, rookAttacks, } from './attacks';
|
|
5
|
+
export { Board } from './board';
|
|
6
|
+
export { defaultSetup } from './setup';
|
|
7
|
+
export { IllegalSetup, Shogi, Position, PositionError } from './shogi';
|
|
8
|
+
export * as compat from './compat';
|
|
9
|
+
export * as debug from './debug';
|
|
10
|
+
export * as sfen from './sfen';
|
|
11
|
+
export * as handicaps from './notation/kif/kifHandicaps';
|
|
12
|
+
export * as hand from './hand';
|
|
13
|
+
export * as hash from './hash';
|
|
14
|
+
export * as japanese from './notation/japanese';
|
|
15
|
+
export * as kitaoKawasaki from './notation/kitaoKawasaki';
|
|
16
|
+
export * as western from './notation/western';
|
|
17
|
+
export * as westernEngine from './notation/westernEngine';
|
|
18
|
+
export * as kif from './notation/kif/kif';
|
|
19
|
+
export * as csa from './notation/csa/csa';
|
|
20
|
+
export * as transform from './transform';
|
|
21
|
+
export * as variant from './variant';
|
|
22
|
+
export * as variantUtil from './variantUtil';
|
|
65
23
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAOV,MAAM,EAGN,KAAK,EAML,MAAM,EACN,QAAQ,EAER,KAAK,GAEN,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,YAAY,EACZ,OAAO,EACP,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACL,OAAO,EACP,OAAO,EACP,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,GAAG,EACH,WAAW,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAS,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAW,MAAM,SAAS,CAAC;AAEhF,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,SAAS,MAAM,6BAA6B,CAAC;AAEzD,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { Result } from '@badrap/result';
|
|
2
|
-
import { Board } from '
|
|
3
|
-
import {
|
|
4
|
-
import { Position } from '
|
|
5
|
-
import { Move } from '
|
|
2
|
+
import { Board } from '../../board';
|
|
3
|
+
import { Setup } from '../../setup';
|
|
4
|
+
import { Position } from '../../shogi';
|
|
5
|
+
import { Move } from '../../types';
|
|
6
|
+
import { Hand } from '../../hand';
|
|
6
7
|
export declare enum InvalidCsa {
|
|
7
8
|
CSA = "ERR_CSA",
|
|
8
9
|
Board = "ERR_BOARD",
|
|
9
10
|
Handicap = "ERR_HANDICAP",
|
|
10
|
-
|
|
11
|
+
Hands = "ERR_HANDS",
|
|
11
12
|
AdditionalInfo = "ERR_ADDITIONAL"
|
|
12
13
|
}
|
|
13
14
|
export declare class CsaError extends Error {
|
|
14
15
|
}
|
|
15
16
|
export declare function makeCsaHeader(setup: Setup): string;
|
|
16
17
|
export declare function makeCsaBoard(board: Board): string;
|
|
17
|
-
export declare function
|
|
18
|
+
export declare function makeCsaHand(hand: Hand, prefix: string): string;
|
|
18
19
|
export declare function parseCsaHeader(csa: string): Result<Setup, CsaError>;
|
|
19
20
|
export declare function parseCsaHandicap(handicap: string): Result<Board, CsaError>;
|
|
20
21
|
export declare function parseTags(csa: string): [string, string][];
|
|
22
|
+
export declare function normalizedCsaLines(csa: string): string[];
|
|
21
23
|
export declare function parseCsaMove(pos: Position, csaMove: string): Move | undefined;
|
|
22
24
|
export declare function parseCsaMoves(pos: Position, csaMoves: string[]): Move[];
|
|
23
|
-
export declare function makeCsaMove(pos: Position, move: Move): string;
|
|
24
|
-
export declare function makeCsaVariation(pos: Position, variation: Move[]): string;
|
|
25
|
-
export declare function normalizedCsaLines(csa: string): string[];
|
|
25
|
+
export declare function makeCsaMove(pos: Position, move: Move): string | undefined;
|