@konoui/mjimage 0.0.13 → 0.0.15
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/dist/mjs/index.d.ts +5 -9
- package/dist/mjs/index.js +5 -9
- package/dist/mjs/lib/calculator/calc.d.ts +263 -0
- package/dist/mjs/lib/calculator/calc.js +1386 -0
- package/dist/mjs/lib/calculator/efficiency.d.ts +19 -0
- package/dist/mjs/lib/calculator/efficiency.js +86 -0
- package/dist/mjs/lib/calculator/index.d.ts +2 -263
- package/dist/mjs/lib/calculator/index.js +14 -1382
- package/dist/mjs/lib/controller/controller.d.ts +4 -4
- package/dist/mjs/lib/controller/controller.js +34 -34
- package/dist/mjs/lib/controller/events.d.ts +3 -4
- package/dist/mjs/lib/controller/index.d.ts +1 -1
- package/dist/mjs/lib/controller/index.js +1 -1
- package/dist/mjs/lib/controller/managers.d.ts +2 -2
- package/dist/mjs/lib/controller/managers.js +1 -1
- package/dist/mjs/lib/controller/{efficiency.d.ts → player-efficiency.d.ts} +3 -20
- package/dist/mjs/lib/controller/{efficiency.js → player-efficiency.js} +3 -80
- package/dist/mjs/lib/controller/player.d.ts +1 -1
- package/dist/mjs/lib/controller/player.js +4 -4
- package/dist/mjs/lib/controller/river.d.ts +2 -2
- package/dist/mjs/lib/controller/state-machine.d.ts +2 -2
- package/dist/mjs/lib/controller/state-machine.js +2 -2
- package/dist/mjs/lib/controller/wall.d.ts +1 -1
- package/dist/mjs/lib/controller/wall.js +2 -2
- package/dist/mjs/lib/{constants.d.ts → core/constants.d.ts} +2 -0
- package/dist/mjs/lib/{constants.js → core/constants.js} +6 -1
- package/dist/mjs/lib/{image.d.ts → core/image.d.ts} +5 -5
- package/dist/mjs/lib/{image.js → core/image.js} +109 -111
- package/dist/mjs/lib/core/index.d.ts +3 -0
- package/dist/mjs/lib/core/index.js +19 -0
- package/dist/mjs/lib/{parser.d.ts → core/parser.d.ts} +10 -1
- package/dist/mjs/lib/{parser.js → core/parser.js} +28 -17
- package/dist/mjs/lib/{measure-text.js → measure-text/index.js} +1 -1
- package/dist/mjs/lib/mjai/event.d.ts +1 -1
- package/dist/mjs/lib/mjai/event.js +2 -2
- package/dist/mjs/lib/mjimage.d.ts +2 -1
- package/dist/mjs/lib/mjimage.js +9 -9
- package/dist/mjs/lib/table/index.d.ts +2 -0
- package/dist/mjs/lib/table/index.js +18 -0
- package/dist/mjs/lib/{table-parser.d.ts → table/table-parser.d.ts} +2 -2
- package/dist/mjs/lib/{table-parser.js → table/table-parser.js} +2 -2
- package/dist/mjs/lib/{table.d.ts → table/table.d.ts} +5 -3
- package/dist/mjs/lib/{table.js → table/table.js} +11 -4
- package/dist/mjs/svg/_0.svg +1 -1
- package/dist/mjs/svg/m0.svg +1 -1
- package/dist/mjs/svg/m1.svg +1 -1
- package/dist/mjs/svg/m2.svg +1 -1
- package/dist/mjs/svg/m3.svg +1 -1
- package/dist/mjs/svg/m4.svg +1 -1
- package/dist/mjs/svg/m5.svg +1 -1
- package/dist/mjs/svg/m6.svg +1 -1
- package/dist/mjs/svg/m7.svg +1 -1
- package/dist/mjs/svg/m8.svg +1 -1
- package/dist/mjs/svg/m9.svg +1 -1
- package/dist/mjs/svg/p0.svg +1 -1
- package/dist/mjs/svg/p1.svg +1 -1
- package/dist/mjs/svg/p2.svg +1 -1
- package/dist/mjs/svg/p3.svg +1 -1
- package/dist/mjs/svg/p4.svg +1 -1
- package/dist/mjs/svg/p5.svg +1 -1
- package/dist/mjs/svg/p6.svg +1 -1
- package/dist/mjs/svg/p7.svg +1 -1
- package/dist/mjs/svg/p8.svg +1 -1
- package/dist/mjs/svg/p9.svg +1 -1
- package/dist/mjs/svg/s0.svg +1 -1
- package/dist/mjs/svg/s1.svg +1 -1
- package/dist/mjs/svg/s2.svg +1 -1
- package/dist/mjs/svg/s3.svg +1 -1
- package/dist/mjs/svg/s4.svg +1 -1
- package/dist/mjs/svg/s5.svg +1 -1
- package/dist/mjs/svg/s6.svg +1 -1
- package/dist/mjs/svg/s7.svg +1 -1
- package/dist/mjs/svg/s8.svg +1 -1
- package/dist/mjs/svg/s9.svg +1 -1
- package/dist/mjs/svg/stick100.svg +1 -1
- package/dist/mjs/svg/stick1000.svg +1 -1
- package/dist/mjs/svg/z1.svg +1 -1
- package/dist/mjs/svg/z2.svg +1 -1
- package/dist/mjs/svg/z3.svg +1 -1
- package/dist/mjs/svg/z4.svg +1 -1
- package/dist/mjs/svg/z5.svg +1 -1
- package/dist/mjs/svg/z6.svg +1 -1
- package/dist/mjs/svg/z7.svg +1 -1
- package/package.json +6 -3
- /package/dist/mjs/lib/{lexer.d.ts → core/lexer.d.ts} +0 -0
- /package/dist/mjs/lib/{lexer.js → core/lexer.js} +0 -0
- /package/dist/mjs/lib/{measure-text.d.ts → measure-text/index.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Wind, Round } from "../
|
|
2
|
-
import { BoardParams, Hand, WinResult } from "../calculator";
|
|
3
|
-
import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../parser";
|
|
1
|
+
import { Wind, Round } from "../core/";
|
|
2
|
+
import { BoardParams, Hand, WinResult, Candidate } from "../calculator";
|
|
3
|
+
import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../core/parser";
|
|
4
4
|
import { PlayerEvent, EventHandler, DistributeEvent } from "./events";
|
|
5
|
-
import { Wall, WallProps, River, PlaceManager, ScoreManager, Counter
|
|
5
|
+
import { Wall, WallProps, River, PlaceManager, ScoreManager, Counter } from ".";
|
|
6
6
|
export interface History {
|
|
7
7
|
round: Round;
|
|
8
8
|
scores: {
|
|
@@ -32,9 +32,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.replaceTileBlock = exports.Observer = exports.BaseActor = exports.Controller = void 0;
|
|
33
33
|
var assert_1 = __importDefault(require("assert"));
|
|
34
34
|
var xstate_1 = require("xstate");
|
|
35
|
-
var
|
|
35
|
+
var core_1 = require("../core/");
|
|
36
36
|
var calculator_1 = require("../calculator");
|
|
37
|
-
var parser_1 = require("../parser");
|
|
37
|
+
var parser_1 = require("../core/parser");
|
|
38
38
|
var state_machine_1 = require("./state-machine");
|
|
39
39
|
var events_1 = require("./events");
|
|
40
40
|
var _1 = require(".");
|
|
@@ -207,7 +207,7 @@ var Controller = (function () {
|
|
|
207
207
|
(0, assert_1.default)(tiles, "".concat(selected.type, " choice is none"));
|
|
208
208
|
this.actor.send({
|
|
209
209
|
type: selected.type,
|
|
210
|
-
tile: tiles[0].remove(
|
|
210
|
+
tile: tiles[0].remove(core_1.OPERATOR.TSUMO),
|
|
211
211
|
iam: w,
|
|
212
212
|
});
|
|
213
213
|
break;
|
|
@@ -349,7 +349,7 @@ var Controller = (function () {
|
|
|
349
349
|
if (ret.points.length == 0)
|
|
350
350
|
return false;
|
|
351
351
|
if (hand.draw == null) {
|
|
352
|
-
var c_1 =
|
|
352
|
+
var c_1 = calculator_1.Efficiency.candidateTiles(this.hand(w)).candidates;
|
|
353
353
|
var tiles = this.river.discards(w).map(function (v) { return v.t; });
|
|
354
354
|
if (tiles.some(function (t) { return c_1.some(function (ct) { return ct.equals(t, true); }); }))
|
|
355
355
|
return false;
|
|
@@ -366,7 +366,7 @@ var Controller = (function () {
|
|
|
366
366
|
return false;
|
|
367
367
|
if (hand.hands.length < 3)
|
|
368
368
|
return false;
|
|
369
|
-
var fake = t.clone().remove(
|
|
369
|
+
var fake = t.clone().remove(core_1.OPERATOR.HORIZONTAL);
|
|
370
370
|
if (t.isNum() && t.n == 0)
|
|
371
371
|
fake.n = 5;
|
|
372
372
|
if (hand.get(t.t, fake.n) < 2)
|
|
@@ -380,7 +380,7 @@ var Controller = (function () {
|
|
|
380
380
|
if (idx == 1)
|
|
381
381
|
idx = 2;
|
|
382
382
|
var b = new parser_1.BlockPon([fake.clone(), fake.clone(), fake.clone()]);
|
|
383
|
-
b.tiles[idx] = t.clone().add(
|
|
383
|
+
b.tiles[idx] = t.clone().add(core_1.OPERATOR.HORIZONTAL);
|
|
384
384
|
if (t.isNum() && fake.n == 5 && hand.get(t.t, 0) > 0)
|
|
385
385
|
b.tiles[(idx % 2) + 1].n = 0;
|
|
386
386
|
blocks.push(b);
|
|
@@ -410,7 +410,7 @@ var Controller = (function () {
|
|
|
410
410
|
var left = fake.n - 2 >= 1 &&
|
|
411
411
|
hand.get(t.t, fake.n - 2) > 0 &&
|
|
412
412
|
hand.get(t.t, fake.n - 1) > 0;
|
|
413
|
-
var cloned = t.clone().add(
|
|
413
|
+
var cloned = t.clone().add(core_1.OPERATOR.HORIZONTAL).remove(core_1.OPERATOR.TSUMO);
|
|
414
414
|
if (left)
|
|
415
415
|
blocks.push(new parser_1.BlockChi([
|
|
416
416
|
cloned,
|
|
@@ -484,7 +484,7 @@ var Controller = (function () {
|
|
|
484
484
|
var s = new calculator_1.ShantenCalculator(hand).calc();
|
|
485
485
|
if (s > 0)
|
|
486
486
|
return false;
|
|
487
|
-
var r =
|
|
487
|
+
var r = calculator_1.Efficiency.calcCandidates(hand, hand.hands);
|
|
488
488
|
return r;
|
|
489
489
|
};
|
|
490
490
|
Controller.prototype.doDiscard = function (w, called) {
|
|
@@ -520,7 +520,7 @@ var Controller = (function () {
|
|
|
520
520
|
var blocks = [];
|
|
521
521
|
if (hand.reached)
|
|
522
522
|
return false;
|
|
523
|
-
for (var _i = 0, _a = Object.values(
|
|
523
|
+
for (var _i = 0, _a = Object.values(core_1.TYPE); _i < _a.length; _i++) {
|
|
524
524
|
var t = _a[_i];
|
|
525
525
|
for (var n = 1; n < hand.getArrayLen(t); n++) {
|
|
526
526
|
if (hand.get(t, n) == 4) {
|
|
@@ -530,7 +530,7 @@ var Controller = (function () {
|
|
|
530
530
|
new parser_1.Tile(t, n),
|
|
531
531
|
new parser_1.Tile(t, n),
|
|
532
532
|
];
|
|
533
|
-
if (t !=
|
|
533
|
+
if (t != core_1.TYPE.Z && n == 5)
|
|
534
534
|
tiles[0].n = 0;
|
|
535
535
|
blocks.push(new parser_1.BlockAnKan(tiles));
|
|
536
536
|
}
|
|
@@ -540,7 +540,7 @@ var Controller = (function () {
|
|
|
540
540
|
return false;
|
|
541
541
|
for (var _b = 0, blocks_1 = blocks; _b < blocks_1.length; _b++) {
|
|
542
542
|
var b = blocks_1[_b];
|
|
543
|
-
(0, assert_1.default)(b.tiles.filter(function (t) { return t.has(
|
|
543
|
+
(0, assert_1.default)(b.tiles.filter(function (t) { return t.has(core_1.OPERATOR.HORIZONTAL); }).length == 0, "h op ".concat(b.toString()));
|
|
544
544
|
}
|
|
545
545
|
return blocks;
|
|
546
546
|
};
|
|
@@ -557,7 +557,7 @@ var Controller = (function () {
|
|
|
557
557
|
var pick = c.tiles[0];
|
|
558
558
|
if (hand.get(pick.t, pick.n) == 1) {
|
|
559
559
|
var cb = c.clone();
|
|
560
|
-
cb.tiles.push(new parser_1.Tile(pick.t, pick.n, [
|
|
560
|
+
cb.tiles.push(new parser_1.Tile(pick.t, pick.n, [core_1.OPERATOR.HORIZONTAL]));
|
|
561
561
|
if (pick.n == 5 && hand.get(pick.t, 0) == 1)
|
|
562
562
|
cb.tiles[3].n == 0;
|
|
563
563
|
blocks.push(new parser_1.BlockShoKan(cb.tiles));
|
|
@@ -567,7 +567,7 @@ var Controller = (function () {
|
|
|
567
567
|
return false;
|
|
568
568
|
for (var _a = 0, blocks_2 = blocks; _a < blocks_2.length; _a++) {
|
|
569
569
|
var b = blocks_2[_a];
|
|
570
|
-
(0, assert_1.default)(b.tiles.filter(function (t) { return t.has(
|
|
570
|
+
(0, assert_1.default)(b.tiles.filter(function (t) { return t.has(core_1.OPERATOR.HORIZONTAL); }).length == 2, "h op ".concat(b.toString()));
|
|
571
571
|
}
|
|
572
572
|
return blocks;
|
|
573
573
|
};
|
|
@@ -577,7 +577,7 @@ var Controller = (function () {
|
|
|
577
577
|
return false;
|
|
578
578
|
if (w == whoDiscarded)
|
|
579
579
|
return false;
|
|
580
|
-
var fake = t.clone().remove(
|
|
580
|
+
var fake = t.clone().remove(core_1.OPERATOR.HORIZONTAL);
|
|
581
581
|
if (fake.isNum() && fake.n == 0)
|
|
582
582
|
fake.n = 5;
|
|
583
583
|
if (hand.get(fake.t, fake.n) != 3)
|
|
@@ -593,37 +593,37 @@ var Controller = (function () {
|
|
|
593
593
|
idx = 0;
|
|
594
594
|
if (idx == 1)
|
|
595
595
|
idx = 3;
|
|
596
|
-
b.tiles[idx] = t.clone().add(
|
|
596
|
+
b.tiles[idx] = t.clone().add(core_1.OPERATOR.HORIZONTAL);
|
|
597
597
|
if (fake.isNum() && fake.n == 5 && t.n == 5)
|
|
598
598
|
b.tiles[(idx % 3) + 1].n = 0;
|
|
599
|
-
(0, assert_1.default)(b.tiles.filter(function (t) { return t.has(
|
|
599
|
+
(0, assert_1.default)(b.tiles.filter(function (t) { return t.has(core_1.OPERATOR.HORIZONTAL); }).length == 1, "h op ".concat(b.toString()));
|
|
600
600
|
return b;
|
|
601
601
|
};
|
|
602
602
|
Controller.prototype.canDrawnGame = function (w) {
|
|
603
603
|
if (this.river.discards(w).length != 0)
|
|
604
604
|
return false;
|
|
605
605
|
var h = this.hand(w);
|
|
606
|
-
var num = h.get(
|
|
607
|
-
h.get(
|
|
608
|
-
h.get(
|
|
609
|
-
h.get(
|
|
610
|
-
h.get(
|
|
611
|
-
h.get(
|
|
612
|
-
for (var i = 0; i < h.getArrayLen(
|
|
613
|
-
num += h.get(
|
|
606
|
+
var num = h.get(core_1.TYPE.M, 1) +
|
|
607
|
+
h.get(core_1.TYPE.M, 9) +
|
|
608
|
+
h.get(core_1.TYPE.S, 1) +
|
|
609
|
+
h.get(core_1.TYPE.S, 9) +
|
|
610
|
+
h.get(core_1.TYPE.P, 1) +
|
|
611
|
+
h.get(core_1.TYPE.P, 9);
|
|
612
|
+
for (var i = 0; i < h.getArrayLen(core_1.TYPE.Z); i++)
|
|
613
|
+
num += h.get(core_1.TYPE.Z, i);
|
|
614
614
|
return num >= 9;
|
|
615
615
|
};
|
|
616
616
|
Controller.prototype.initialHands = function () {
|
|
617
617
|
var m = (0, _1.createWindMap)("");
|
|
618
618
|
for (var i = 0; i < 3; i++) {
|
|
619
|
-
for (var _i = 0, _a = Object.values(
|
|
619
|
+
for (var _i = 0, _a = Object.values(core_1.WIND); _i < _a.length; _i++) {
|
|
620
620
|
var w = _a[_i];
|
|
621
621
|
for (var j = 0; j < 4; j++) {
|
|
622
622
|
m[w] += this.wall.draw().toString();
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
for (var _b = 0, _c = Object.values(
|
|
626
|
+
for (var _b = 0, _c = Object.values(core_1.WIND); _b < _c.length; _b++) {
|
|
627
627
|
var w = _c[_b];
|
|
628
628
|
m[w] += this.wall.draw().toString();
|
|
629
629
|
}
|
|
@@ -664,7 +664,7 @@ var BaseActor = (function () {
|
|
|
664
664
|
this.scoreManager = new _1.ScoreManager(structuredClone(e.scores));
|
|
665
665
|
this.doraMarkers = [e.doraMarker];
|
|
666
666
|
this.counter.dec(e.doraMarker);
|
|
667
|
-
for (var _i = 0, _d = Object.values(
|
|
667
|
+
for (var _i = 0, _d = Object.values(core_1.WIND); _i < _d.length; _i++) {
|
|
668
668
|
var w = _d[_i];
|
|
669
669
|
if (w != e.wind)
|
|
670
670
|
continue;
|
|
@@ -681,7 +681,7 @@ var BaseActor = (function () {
|
|
|
681
681
|
if (e.iam != e.wind) {
|
|
682
682
|
this.counter.dec(e.tile);
|
|
683
683
|
this.counter.addTileToSafeMap(e.tile, e.iam);
|
|
684
|
-
for (var _e = 0, _f = Object.values(
|
|
684
|
+
for (var _e = 0, _f = Object.values(core_1.WIND); _e < _f.length; _e++) {
|
|
685
685
|
var w = _f[_e];
|
|
686
686
|
if (this.hand(w).reached)
|
|
687
687
|
this.counter.addTileToSafeMap(e.tile, w);
|
|
@@ -694,13 +694,13 @@ var BaseActor = (function () {
|
|
|
694
694
|
this.hands[e.iam].call(e.block);
|
|
695
695
|
this.river.markCalled();
|
|
696
696
|
if (e.iam != e.wind)
|
|
697
|
-
(_b = this.counter).dec.apply(_b, e.block.tiles.filter(function (t) { return !t.has(
|
|
697
|
+
(_b = this.counter).dec.apply(_b, e.block.tiles.filter(function (t) { return !t.has(core_1.OPERATOR.HORIZONTAL); }));
|
|
698
698
|
break;
|
|
699
699
|
case "SHO_KAN":
|
|
700
700
|
case "AN_KAN":
|
|
701
701
|
this.hands[e.iam].kan(e.block);
|
|
702
702
|
if (e.iam != e.wind)
|
|
703
|
-
(_c = this.counter).dec.apply(_c, e.block.tiles.filter(function (t) { return !t.has(
|
|
703
|
+
(_c = this.counter).dec.apply(_c, e.block.tiles.filter(function (t) { return !t.has(core_1.OPERATOR.HORIZONTAL); }));
|
|
704
704
|
break;
|
|
705
705
|
case "REACH":
|
|
706
706
|
var pid = this.placeManager.playerID(e.iam);
|
|
@@ -775,14 +775,14 @@ var Observer = (function (_super) {
|
|
|
775
775
|
switch (e.type) {
|
|
776
776
|
case "DISTRIBUTE":
|
|
777
777
|
var ready = true;
|
|
778
|
-
for (var _i = 0, _a = Object.values(
|
|
778
|
+
for (var _i = 0, _a = Object.values(core_1.WIND); _i < _a.length; _i++) {
|
|
779
779
|
var w = _a[_i];
|
|
780
|
-
ready && (ready = this.hand(w).get(
|
|
780
|
+
ready && (ready = this.hand(w).get(core_1.TYPE.BACK, 0) == 0);
|
|
781
781
|
}
|
|
782
782
|
if (!ready)
|
|
783
783
|
break;
|
|
784
784
|
console.debug("DISTRIBUTE:", "round: ".concat(this.placeManager.round), "scores: ".concat(JSON.stringify(this.scoreManager.summary, null, 2)), "map: ".concat(JSON.stringify(this.placeManager.playerMap, null, 2)), "sticks: ".concat(JSON.stringify(this.placeManager.sticks, null, 2)));
|
|
785
|
-
for (var _b = 0, _c = Object.values(
|
|
785
|
+
for (var _b = 0, _c = Object.values(core_1.WIND); _b < _c.length; _b++) {
|
|
786
786
|
var w = _c[_b];
|
|
787
787
|
console.debug(this.placeManager.playerID(w), "init hand: ".concat(this.hand(w).toString()));
|
|
788
788
|
}
|
|
@@ -808,7 +808,7 @@ var Observer = (function (_super) {
|
|
|
808
808
|
console.debug(this.placeManager.playerID(e.iam), "ron/tsumo: ".concat(JSON.stringify(e.ret, null, 2)), "hand: ".concat(this.hand(e.iam).toString()));
|
|
809
809
|
break;
|
|
810
810
|
case "END_GAME":
|
|
811
|
-
for (var _d = 0, _e = Object.values(
|
|
811
|
+
for (var _d = 0, _e = Object.values(core_1.WIND); _d < _e.length; _d++) {
|
|
812
812
|
var w = _e[_d];
|
|
813
813
|
console.debug(this.placeManager.playerID(w), "end hand: ".concat(this.hand(w).toString()));
|
|
814
814
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Wind, Round } from "../constants";
|
|
2
|
-
import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../parser";
|
|
3
|
-
import { Candidate } from "
|
|
4
|
-
import { WinResult } from "../calculator";
|
|
1
|
+
import { Wind, Round } from "../core/constants";
|
|
2
|
+
import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../core/parser";
|
|
3
|
+
import { WinResult, Candidate } from "../calculator";
|
|
5
4
|
type Event = CallEvent | "DRAW" | "CHOICE_AFTER_DRAWN" | "CHOICE_AFTER_DISCARDED" | "CHOICE_AFTER_CALLED" | "CHOICE_FOR_CHAN_KAN" | "DISTRIBUTE" | "NEW_DORA" | "END_GAME";
|
|
6
5
|
type ChoiceEvent = "PON" | "CHI" | "RON" | "DISCARD" | "TSUMO" | "REACH" | "AN_KAN" | "SHO_KAN" | "DAI_KAN" | "DRAWN_GAME_BY_NINE_TILES";
|
|
7
6
|
export interface DistributeEvent {
|
|
@@ -23,4 +23,4 @@ __exportStar(require("./controller"), exports);
|
|
|
23
23
|
__exportStar(require("./player"), exports);
|
|
24
24
|
__exportStar(require("./replay"), exports);
|
|
25
25
|
__exportStar(require("./game"), exports);
|
|
26
|
-
__exportStar(require("./efficiency"), exports);
|
|
26
|
+
__exportStar(require("./player-efficiency"), exports);
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Counter = exports.shuffle = exports.createWindMap = exports.prevWind = exports.nextWind = exports.prevRound = exports.nextRound = exports.PlaceManager = exports.ScoreManager = void 0;
|
|
7
7
|
var assert_1 = __importDefault(require("assert"));
|
|
8
|
-
var constants_1 = require("../constants");
|
|
8
|
+
var constants_1 = require("../core/constants");
|
|
9
9
|
var ScoreManager = (function () {
|
|
10
10
|
function ScoreManager(initial) {
|
|
11
11
|
this.reachValue = 1000;
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import { Wind } from "../constants";
|
|
2
|
-
import { Tile } from "../parser";
|
|
3
|
-
import {
|
|
1
|
+
import { Wind } from "../core/constants";
|
|
2
|
+
import { Tile } from "../core/parser";
|
|
3
|
+
import { Candidate } from "../calculator";
|
|
4
4
|
import { Counter } from "./managers";
|
|
5
|
-
export interface Candidate {
|
|
6
|
-
tile: Tile;
|
|
7
|
-
candidates: Tile[];
|
|
8
|
-
shanten: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class Efficiency {
|
|
11
|
-
static calcCandidates(hand: Hand, choices: Tile[]): Candidate[];
|
|
12
|
-
static candidateTiles(hand: Hand): {
|
|
13
|
-
shanten: number;
|
|
14
|
-
candidates: Tile[];
|
|
15
|
-
};
|
|
16
|
-
static partialCandidateTiles(input: string): {
|
|
17
|
-
shanten: number;
|
|
18
|
-
candidates: Tile[];
|
|
19
|
-
};
|
|
20
|
-
static partialShanten(input: string): number;
|
|
21
|
-
}
|
|
22
5
|
export interface PlayerCandidate {
|
|
23
6
|
tile: Tile;
|
|
24
7
|
sum: number;
|
|
@@ -3,87 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RiskRank = exports.PlayerEfficiency =
|
|
6
|
+
exports.RiskRank = exports.PlayerEfficiency = void 0;
|
|
7
7
|
var assert_1 = __importDefault(require("assert"));
|
|
8
|
-
var constants_1 = require("../constants");
|
|
9
|
-
var parser_1 = require("../parser");
|
|
10
|
-
var calculator_1 = require("../calculator");
|
|
11
|
-
var Efficiency = (function () {
|
|
12
|
-
function Efficiency() {
|
|
13
|
-
}
|
|
14
|
-
Efficiency.calcCandidates = function (hand, choices) {
|
|
15
|
-
(0, assert_1.default)(choices.length > 0, "choices to discard is zero");
|
|
16
|
-
var ret = [];
|
|
17
|
-
for (var _i = 0, choices_1 = choices; _i < choices_1.length; _i++) {
|
|
18
|
-
var t = choices_1[_i];
|
|
19
|
-
var tiles = hand.dec([t]);
|
|
20
|
-
var c = Efficiency.candidateTiles(hand);
|
|
21
|
-
hand.inc(tiles);
|
|
22
|
-
if (ret.length == 0 || c.shanten < ret[0].shanten) {
|
|
23
|
-
ret = [
|
|
24
|
-
{
|
|
25
|
-
shanten: c.shanten,
|
|
26
|
-
candidates: c.candidates,
|
|
27
|
-
tile: t,
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
else if (c.shanten == ret[0].shanten) {
|
|
32
|
-
ret.push({
|
|
33
|
-
candidates: c.candidates,
|
|
34
|
-
shanten: c.shanten,
|
|
35
|
-
tile: t,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return ret;
|
|
40
|
-
};
|
|
41
|
-
Efficiency.candidateTiles = function (hand) {
|
|
42
|
-
var r = Number.POSITIVE_INFINITY;
|
|
43
|
-
var candidates = [];
|
|
44
|
-
var sc = new calculator_1.ShantenCalculator(hand);
|
|
45
|
-
for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
|
|
46
|
-
var t = _a[_i];
|
|
47
|
-
if (t == constants_1.TYPE.BACK)
|
|
48
|
-
continue;
|
|
49
|
-
for (var n = 1; n < hand.getArrayLen(t); n++) {
|
|
50
|
-
if (hand.get(t, n) >= 4)
|
|
51
|
-
continue;
|
|
52
|
-
var tile = new parser_1.Tile(t, n);
|
|
53
|
-
var tiles = hand.inc([tile]);
|
|
54
|
-
var s = sc.calc();
|
|
55
|
-
hand.dec(tiles);
|
|
56
|
-
if (s < r) {
|
|
57
|
-
r = s;
|
|
58
|
-
candidates = [tile];
|
|
59
|
-
}
|
|
60
|
-
else if (s == r)
|
|
61
|
-
candidates.push(tile);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
shanten: r,
|
|
66
|
-
candidates: candidates,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
Efficiency.partialCandidateTiles = function (input) {
|
|
70
|
-
var h = new calculator_1.Hand(input, true);
|
|
71
|
-
Array(13 - h.hands.length)
|
|
72
|
-
.fill(undefined)
|
|
73
|
-
.map(function () { return h.inc([new parser_1.Tile(constants_1.TYPE.BACK, 0)]); });
|
|
74
|
-
return Efficiency.candidateTiles(h);
|
|
75
|
-
};
|
|
76
|
-
Efficiency.partialShanten = function (input) {
|
|
77
|
-
var h = new calculator_1.Hand(input, true);
|
|
78
|
-
Array(13 - h.hands.length)
|
|
79
|
-
.fill(undefined)
|
|
80
|
-
.map(function () { return h.inc([new parser_1.Tile(constants_1.TYPE.BACK, 0)]); });
|
|
81
|
-
var sc = new calculator_1.ShantenCalculator(h);
|
|
82
|
-
return sc.calc();
|
|
83
|
-
};
|
|
84
|
-
return Efficiency;
|
|
85
|
-
}());
|
|
86
|
-
exports.Efficiency = Efficiency;
|
|
8
|
+
var constants_1 = require("../core/constants");
|
|
9
|
+
var parser_1 = require("../core/parser");
|
|
87
10
|
var weight = function (t, doras) {
|
|
88
11
|
var base = 1;
|
|
89
12
|
var v = base;
|
|
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.Player = void 0;
|
|
19
|
-
var
|
|
19
|
+
var core_1 = require("../core/");
|
|
20
20
|
var _1 = require("./");
|
|
21
21
|
var calculator_1 = require("../calculator");
|
|
22
22
|
var Player = (function (_super) {
|
|
@@ -38,14 +38,14 @@ var Player = (function (_super) {
|
|
|
38
38
|
configurable: true
|
|
39
39
|
});
|
|
40
40
|
Player.prototype.setHands = function (e) {
|
|
41
|
-
for (var _i = 0, _a = Object.values(
|
|
41
|
+
for (var _i = 0, _a = Object.values(core_1.WIND); _i < _a.length; _i++) {
|
|
42
42
|
var w = _a[_i];
|
|
43
43
|
this.hands[w] = new calculator_1.Hand(e.hands[w]);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
Player.prototype.handleDiscard = function (tiles) {
|
|
47
47
|
var _this = this;
|
|
48
|
-
var reachUsers = Object.values(
|
|
48
|
+
var reachUsers = Object.values(core_1.WIND).filter(function (w) {
|
|
49
49
|
return w == _this.myWind ? false : _this.hand(w).reached;
|
|
50
50
|
});
|
|
51
51
|
var shanten = new calculator_1.ShantenCalculator(this.hand(this.myWind)).calc();
|
|
@@ -53,7 +53,7 @@ var Player = (function (_super) {
|
|
|
53
53
|
var t = _1.RiskRank.selectTile(this.counter, reachUsers, tiles);
|
|
54
54
|
return t;
|
|
55
55
|
}
|
|
56
|
-
var c =
|
|
56
|
+
var c = calculator_1.Efficiency.calcCandidates(this.hand(this.myWind), tiles);
|
|
57
57
|
var candidates = _1.PlayerEfficiency.calcPlayerCandidates(this.counter, c);
|
|
58
58
|
var sorted = candidates.sort(function (a, b) { return b.sum - a.sum; });
|
|
59
59
|
var filtered = sorted.filter(function (v) { return v.sum == sorted[0].sum; });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Wind } from "../constants";
|
|
1
|
+
import { Wind } from "../core/constants";
|
|
2
2
|
import { Controller } from "./index";
|
|
3
|
-
import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../parser";
|
|
3
|
+
import { BlockAnKan, BlockChi, BlockDaiKan, BlockPon, BlockShoKan, Tile } from "../core/parser";
|
|
4
4
|
import { WinResult } from "./../calculator";
|
|
5
5
|
type ControllerContext = {
|
|
6
6
|
currentWind: Wind;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.incrementalIDGenerator = exports.createControllerMachine = void 0;
|
|
4
|
-
var constants_1 = require("../constants");
|
|
5
|
-
var parser_1 = require("../parser");
|
|
4
|
+
var constants_1 = require("../core/constants");
|
|
5
|
+
var parser_1 = require("../core/parser");
|
|
6
6
|
var calculator_1 = require("./../calculator");
|
|
7
7
|
var managers_1 = require("./managers");
|
|
8
8
|
var xstate_1 = require("xstate");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Wall = void 0;
|
|
4
|
-
var constants_1 = require("../constants");
|
|
5
|
-
var parser_1 = require("../parser");
|
|
4
|
+
var constants_1 = require("../core/constants");
|
|
5
|
+
var parser_1 = require("../core/parser");
|
|
6
6
|
var managers_1 = require("./managers");
|
|
7
7
|
var Wall = (function () {
|
|
8
8
|
function Wall(backup) {
|
|
@@ -3,7 +3,12 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.WIND_MAP = exports.ROUND_MAP = exports.WIND = exports.BLOCK = exports.OPERATOR = exports.TYPE = exports.INPUT_SEPARATOR = exports.TABLE_CONTEXT = exports.TILE_CONTEXT = exports.FONT_FAMILY = void 0;
|
|
5
5
|
exports.FONT_FAMILY = "MS Gothic, sans-serif";
|
|
6
|
-
exports.TILE_CONTEXT = {
|
|
6
|
+
exports.TILE_CONTEXT = {
|
|
7
|
+
WIDTH: 66,
|
|
8
|
+
HEIGHT: 90,
|
|
9
|
+
TEXT_SCALE: 0.8,
|
|
10
|
+
BLOCK_MARGIN_SCALE: 0.3,
|
|
11
|
+
};
|
|
7
12
|
exports.TABLE_CONTEXT = { BASE: 40 };
|
|
8
13
|
exports.INPUT_SEPARATOR = ",";
|
|
9
14
|
exports.TYPE = {
|
|
@@ -9,17 +9,15 @@ export interface ImageHelperConfig {
|
|
|
9
9
|
declare class BaseHelper {
|
|
10
10
|
readonly tileWidth: number;
|
|
11
11
|
readonly tileHeight: number;
|
|
12
|
-
readonly diffTileHeightWidth: number;
|
|
13
|
-
readonly textWidth: number;
|
|
14
12
|
readonly image_host_path: string;
|
|
15
13
|
readonly image_host_url: string;
|
|
16
14
|
readonly scale: number;
|
|
17
15
|
readonly svgSprite: boolean;
|
|
18
16
|
constructor(props?: ImageHelperConfig);
|
|
17
|
+
protected getDiffTileHeightWidth(t: Tile): number;
|
|
19
18
|
private image;
|
|
20
19
|
createImage(tile: Tile, x: number, y: number): Image | Use;
|
|
21
20
|
createTextImage(tile: Tile, x: number, y: number, t: string): G;
|
|
22
|
-
createStackImage(baseTile: Tile, upTile: Tile, x: number, y: number): G;
|
|
23
21
|
createRotate90Image(tile: Tile, x: number, y: number, adjustY?: boolean): G;
|
|
24
22
|
createStick(v: 100 | 1000): Image | Use;
|
|
25
23
|
static buildID(tile: Tile | 100 | 1000): string;
|
|
@@ -27,7 +25,7 @@ declare class BaseHelper {
|
|
|
27
25
|
}
|
|
28
26
|
export declare class ImageHelper extends BaseHelper {
|
|
29
27
|
readonly blockMargin: number;
|
|
30
|
-
createBlockHandDiscard(
|
|
28
|
+
createBlockHandDiscard(block: Block): G;
|
|
31
29
|
createBlockPonChiKan(block: Block): G;
|
|
32
30
|
}
|
|
33
31
|
export declare const createHand: (helper: ImageHelper, blocks: Block[]) => {
|
|
@@ -35,6 +33,8 @@ export declare const createHand: (helper: ImageHelper, blocks: Block[]) => {
|
|
|
35
33
|
width: number;
|
|
36
34
|
height: number;
|
|
37
35
|
};
|
|
38
|
-
export declare const drawBlocks: (svg: Svg, blocks: Block[], config?: ImageHelperConfig
|
|
36
|
+
export declare const drawBlocks: (svg: Svg, blocks: Block[], config?: ImageHelperConfig, params?: {
|
|
37
|
+
responsive: boolean;
|
|
38
|
+
}) => void;
|
|
39
39
|
export declare const optimizeSVG: (draw: Svg) => void;
|
|
40
40
|
export {};
|