@gamepark/rules-api 5.23.0 → 5.24.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 (82) hide show
  1. package/dist/Action.d.ts +25 -25
  2. package/dist/Action.js +45 -55
  3. package/dist/Action.js.map +1 -1
  4. package/dist/ApplyAutomaticMoves.d.ts +2 -2
  5. package/dist/ApplyAutomaticMoves.js +18 -24
  6. package/dist/ApplyAutomaticMoves.js.map +1 -1
  7. package/dist/Competitive.d.ts +6 -6
  8. package/dist/Competitive.js +3 -7
  9. package/dist/Competitive.js.map +1 -1
  10. package/dist/Dummy.d.ts +7 -7
  11. package/dist/Dummy.js +22 -25
  12. package/dist/Dummy.js.map +1 -1
  13. package/dist/Eliminations.d.ts +5 -5
  14. package/dist/Eliminations.js +4 -8
  15. package/dist/Eliminations.js.map +1 -1
  16. package/dist/IncompleteInformation.d.ts +14 -14
  17. package/dist/IncompleteInformation.js +30 -37
  18. package/dist/IncompleteInformation.js.map +1 -1
  19. package/dist/LoopWithFuse.d.ts +4 -4
  20. package/dist/LoopWithFuse.js +10 -14
  21. package/dist/LoopWithFuse.js.map +1 -1
  22. package/dist/RandomMove.d.ts +7 -7
  23. package/dist/RandomMove.js +7 -12
  24. package/dist/RandomMove.js.map +1 -1
  25. package/dist/Robot.d.ts +2 -2
  26. package/dist/Robot.js +1 -2
  27. package/dist/Rules.d.ts +14 -14
  28. package/dist/Rules.js +63 -74
  29. package/dist/Rules.js.map +1 -1
  30. package/dist/RulesCreator.d.ts +5 -5
  31. package/dist/RulesCreator.js +1 -2
  32. package/dist/TimeLimit.d.ts +18 -18
  33. package/dist/TimeLimit.js +8 -12
  34. package/dist/TimeLimit.js.map +1 -1
  35. package/dist/Undo.d.ts +6 -6
  36. package/dist/Undo.js +4 -8
  37. package/dist/Undo.js.map +1 -1
  38. package/dist/index.d.ts +22 -22
  39. package/dist/index.js +13 -37
  40. package/dist/index.js.map +1 -1
  41. package/dist/options/EnumOption.d.ts +7 -7
  42. package/dist/options/EnumOption.js +3 -7
  43. package/dist/options/EnumOption.js.map +1 -1
  44. package/dist/options/Option.d.ts +9 -9
  45. package/dist/options/Option.js +1 -2
  46. package/dist/options/OptionSpecOf.d.ts +4 -4
  47. package/dist/options/OptionSpecOf.js +1 -2
  48. package/dist/options/OptionsSpec.d.ts +10 -10
  49. package/dist/options/OptionsSpec.js +1 -2
  50. package/dist/options/OptionsValidationError.d.ts +4 -4
  51. package/dist/options/OptionsValidationError.js +7 -28
  52. package/dist/options/OptionsValidationError.js.map +1 -1
  53. package/dist/options/PlayerIdSpec.d.ts +8 -8
  54. package/dist/options/PlayerIdSpec.js +12 -17
  55. package/dist/options/PlayerIdSpec.js.map +1 -1
  56. package/dist/options/PlayersOptionsSpec.d.ts +8 -8
  57. package/dist/options/PlayersOptionsSpec.js +1 -2
  58. package/dist/options/WithIdOption.d.ts +4 -4
  59. package/dist/options/WithIdOption.js +1 -2
  60. package/dist/options/WithPlayerOptionsSpec.d.ts +5 -5
  61. package/dist/options/WithPlayerOptionsSpec.js +1 -2
  62. package/dist/options/WithPlayersOptions.d.ts +4 -4
  63. package/dist/options/WithPlayersOptions.js +1 -2
  64. package/dist/options/getFallbackPlayerName.d.ts +4 -4
  65. package/dist/options/getFallbackPlayerName.js +9 -15
  66. package/dist/options/getFallbackPlayerName.js.map +1 -1
  67. package/dist/options/index.d.ts +13 -13
  68. package/dist/options/index.js +5 -29
  69. package/dist/options/index.js.map +1 -1
  70. package/dist/options/isWithPlayerIdOptions.d.ts +4 -4
  71. package/dist/options/isWithPlayerIdOptions.js +7 -10
  72. package/dist/options/isWithPlayerIdOptions.js.map +1 -1
  73. package/dist/options/providePlayerIds.d.ts +6 -6
  74. package/dist/options/providePlayerIds.js +22 -37
  75. package/dist/options/providePlayerIds.js.map +1 -1
  76. package/dist/utils/EnumUtils.d.ts +1 -1
  77. package/dist/utils/EnumUtils.js +3 -7
  78. package/dist/utils/EnumUtils.js.map +1 -1
  79. package/dist/utils/index.d.ts +1 -1
  80. package/dist/utils/index.js +1 -17
  81. package/dist/utils/index.js.map +1 -1
  82. package/package.json +3 -2
package/dist/Action.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- import { IncompleteInformation } from './index';
2
- import Rules from './Rules';
3
- declare type Action<Move = any, PlayerId = any> = {
4
- id?: string;
5
- playerId: PlayerId;
6
- move: Move;
7
- consequences: Move[];
8
- };
9
- export default Action;
10
- export declare function playAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, move: Move, playerId: PlayerId, id?: string): Action<Move, PlayerId>;
11
- export declare type ActionWithViews<Move = any, MoveView = Move, PlayerId = any> = {
12
- action: Action<Move, PlayerId>;
13
- views: ActionView<MoveView, PlayerId>[];
14
- };
15
- export declare type ActionView<MoveView = any, PlayerId = any> = {
16
- recipient?: PlayerId;
17
- action: Action<MoveView, PlayerId>;
18
- };
19
- export declare function playActionWithViews<Game, View, Move, MoveView, PlayerId>(rules: Rules<Game, Move, PlayerId> & IncompleteInformation<View, Move, MoveView>, move: Move, playerId: PlayerId, recipients: PlayerId[], id?: string): ActionWithViews<Move, MoveView, PlayerId>;
20
- export declare function replayAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, action: Action<Move, PlayerId>): void;
21
- export declare function replayActions<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, actions: Action<Move, PlayerId>[]): void;
22
- export declare type SecretAction<Move = any, MoveView = Move, PlayerId = any> = Action<Move, PlayerId> & {
23
- secrets: ActionView<MoveView, PlayerId>[];
24
- };
25
- export declare function isSecretAction(action: Action): action is SecretAction;
1
+ import { IncompleteInformation } from './index';
2
+ import Rules from './Rules';
3
+ type Action<Move = any, PlayerId = any> = {
4
+ id?: string;
5
+ playerId: PlayerId;
6
+ move: Move;
7
+ consequences: Move[];
8
+ };
9
+ export default Action;
10
+ export declare function playAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, move: Move, playerId: PlayerId, id?: string): Action<Move, PlayerId>;
11
+ export type ActionWithViews<Move = any, MoveView = Move, PlayerId = any> = {
12
+ action: Action<Move, PlayerId>;
13
+ views: ActionView<MoveView, PlayerId>[];
14
+ };
15
+ export type ActionView<MoveView = any, PlayerId = any> = {
16
+ recipient?: PlayerId;
17
+ action: Action<MoveView, PlayerId>;
18
+ };
19
+ export declare function playActionWithViews<Game, View, Move, MoveView, PlayerId>(rules: Rules<Game, Move, PlayerId> & IncompleteInformation<View, Move, MoveView>, move: Move, playerId: PlayerId, recipients: PlayerId[], id?: string): ActionWithViews<Move, MoveView, PlayerId>;
20
+ export declare function replayAction<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, action: Action<Move, PlayerId>): void;
21
+ export declare function replayActions<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, actions: Action<Move, PlayerId>[]): void;
22
+ export type SecretAction<Move = any, MoveView = Move, PlayerId = any> = Action<Move, PlayerId> & {
23
+ secrets: ActionView<MoveView, PlayerId>[];
24
+ };
25
+ export declare function isSecretAction(action: Action): action is SecretAction;
package/dist/Action.js CHANGED
@@ -1,56 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSecretAction = exports.replayActions = exports.replayAction = exports.playActionWithViews = exports.playAction = void 0;
4
- var index_1 = require("./index");
5
- var RandomMove_1 = require("./RandomMove");
6
- var ApplyAutomaticMoves_1 = require("./ApplyAutomaticMoves");
7
- function playAction(rules, move, playerId, id) {
8
- if ((0, RandomMove_1.hasRandomMove)(rules)) {
9
- move = rules.randomize(move);
10
- }
11
- var action = { id: id, playerId: playerId, move: move, consequences: [] };
12
- var consequences = rules.play(JSON.parse(JSON.stringify(move)));
13
- (0, ApplyAutomaticMoves_1.applyAutomaticMoves)(rules, consequences, function (move) { return action.consequences.push(move); });
14
- return action;
15
- }
16
- exports.playAction = playAction;
17
- function playActionWithViews(rules, move, playerId, recipients, id) {
18
- if ((0, RandomMove_1.hasRandomMove)(rules)) {
19
- move = rules.randomize(move);
20
- }
21
- var actionWithView = {
22
- action: { id: id, playerId: playerId, move: move, consequences: [] },
23
- views: []
24
- };
25
- // Prepare action view for each player
26
- for (var _i = 0, recipients_1 = recipients; _i < recipients_1.length; _i++) {
27
- var recipient = recipients_1[_i];
28
- actionWithView.views.push({ recipient: recipient, action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(rules, move, recipient), consequences: [] } });
29
- }
30
- // Prepare action view for spectators
31
- actionWithView.views.push({ action: { id: id, playerId: playerId, move: (0, index_1.getMoveView)(rules, move), consequences: [] } });
32
- var consequences = rules.play(JSON.parse(JSON.stringify(move)));
33
- (0, ApplyAutomaticMoves_1.applyAutomaticMoves)(rules, consequences, function (move) {
34
- actionWithView.action.consequences.push(move);
35
- for (var _i = 0, _a = actionWithView.views; _i < _a.length; _i++) {
36
- var view = _a[_i];
37
- view.action.consequences.push((0, index_1.getMoveView)(rules, move, view.recipient));
38
- }
39
- });
40
- return actionWithView;
41
- }
42
- exports.playActionWithViews = playActionWithViews;
43
- function replayAction(rules, action) {
44
- rules.play(JSON.parse(JSON.stringify(action.move)));
45
- action.consequences.forEach(function (move) { return rules.play(JSON.parse(JSON.stringify(move))); });
46
- }
47
- exports.replayAction = replayAction;
48
- function replayActions(rules, actions) {
49
- actions.forEach(function (action) { return replayAction(rules, action); });
50
- }
51
- exports.replayActions = replayActions;
52
- function isSecretAction(action) {
53
- return Array.isArray(action.secrets);
54
- }
55
- exports.isSecretAction = isSecretAction;
1
+ import { getMoveView } from './index';
2
+ import { hasRandomMove } from './RandomMove';
3
+ import { applyAutomaticMoves } from './ApplyAutomaticMoves';
4
+ export function playAction(rules, move, playerId, id) {
5
+ if (hasRandomMove(rules)) {
6
+ move = rules.randomize(move);
7
+ }
8
+ const action = { id, playerId, move, consequences: [] };
9
+ const consequences = rules.play(JSON.parse(JSON.stringify(move)));
10
+ applyAutomaticMoves(rules, consequences, move => action.consequences.push(move));
11
+ return action;
12
+ }
13
+ export function playActionWithViews(rules, move, playerId, recipients, id) {
14
+ if (hasRandomMove(rules)) {
15
+ move = rules.randomize(move);
16
+ }
17
+ const actionWithView = {
18
+ action: { id, playerId, move, consequences: [] },
19
+ views: []
20
+ };
21
+ // Prepare action view for each player
22
+ for (const recipient of recipients) {
23
+ actionWithView.views.push({ recipient, action: { id, playerId, move: getMoveView(rules, move, recipient), consequences: [] } });
24
+ }
25
+ // Prepare action view for spectators
26
+ actionWithView.views.push({ action: { id, playerId, move: getMoveView(rules, move), consequences: [] } });
27
+ const consequences = rules.play(JSON.parse(JSON.stringify(move)));
28
+ applyAutomaticMoves(rules, consequences, move => {
29
+ actionWithView.action.consequences.push(move);
30
+ for (const view of actionWithView.views) {
31
+ view.action.consequences.push(getMoveView(rules, move, view.recipient));
32
+ }
33
+ });
34
+ return actionWithView;
35
+ }
36
+ export function replayAction(rules, action) {
37
+ rules.play(JSON.parse(JSON.stringify(action.move)));
38
+ action.consequences.forEach(move => rules.play(JSON.parse(JSON.stringify(move))));
39
+ }
40
+ export function replayActions(rules, actions) {
41
+ actions.forEach(action => replayAction(rules, action));
42
+ }
43
+ export function isSecretAction(action) {
44
+ return Array.isArray(action.secrets);
45
+ }
56
46
  //# sourceMappingURL=Action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Action.js","sourceRoot":"","sources":["../src/Action.ts"],"names":[],"mappings":";;;AAAA,iCAA0D;AAC1D,2CAA0C;AAE1C,6DAAyD;AAWzD,SAAgB,UAAU,CAAuB,KAAkC,EAAE,IAAU,EAAE,QAAkB,EAAE,EAAW;IAC9H,IAAI,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE;QACxB,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;KAC7B;IAED,IAAM,MAAM,GAA2B,EAAC,EAAE,IAAA,EAAE,QAAQ,UAAA,EAAE,IAAI,MAAA,EAAE,YAAY,EAAE,EAAE,EAAC,CAAA;IAE7E,IAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CA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,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACnF,CAAC;AAED,MAAM,UAAU,aAAa,CAAuB,KAAkC,EAAE,OAAiC;IACvH,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;AACxD,CAAC;AAMD,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAE,MAAuB,CAAC,OAAO,CAAC,CAAA;AACxD,CAAC"}
@@ -1,2 +1,2 @@
1
- import Rules from './Rules';
2
- export declare function applyAutomaticMoves<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, moves?: Move[], preprocessMove?: (move: Move) => void): void;
1
+ import Rules from './Rules';
2
+ export declare function applyAutomaticMoves<Game, Move, PlayerId>(rules: Rules<Game, Move, PlayerId>, moves?: Move[], preprocessMove?: (move: Move) => void): void;
@@ -1,25 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyAutomaticMoves = void 0;
4
- var RandomMove_1 = require("./RandomMove");
5
- var LoopWithFuse_1 = require("./LoopWithFuse");
6
- function applyAutomaticMoves(rules, moves, preprocessMove) {
7
- if (moves === void 0) { moves = []; }
8
- (0, LoopWithFuse_1.loopWithFuse)(function () {
9
- var _a;
10
- if (moves.length === 0 && rules.getAutomaticMoves) {
11
- moves.push.apply(moves, rules.getAutomaticMoves());
12
- }
13
- var move = moves.shift();
14
- if (!move)
15
- return false;
16
- var randomizedMove = (0, RandomMove_1.hasRandomMove)(rules) ? rules.randomize(move) : move;
17
- if (preprocessMove)
18
- preprocessMove(randomizedMove);
19
- var consequences = (_a = rules.play(JSON.parse(JSON.stringify(randomizedMove)))) !== null && _a !== void 0 ? _a : [];
20
- moves.unshift.apply(moves, consequences);
21
- return true;
22
- }, { errorFn: function () { return new Error("Infinite loop detected while applying move consequences: ".concat(JSON.stringify(rules.getAutomaticMoves()), ")")); } });
23
- }
24
- exports.applyAutomaticMoves = applyAutomaticMoves;
1
+ import { hasRandomMove } from './RandomMove';
2
+ import { loopWithFuse } from './LoopWithFuse';
3
+ export function applyAutomaticMoves(rules, moves = [], preprocessMove) {
4
+ loopWithFuse(() => {
5
+ if (moves.length === 0 && rules.getAutomaticMoves) {
6
+ moves.push(...rules.getAutomaticMoves());
7
+ }
8
+ const move = moves.shift();
9
+ if (!move)
10
+ return false;
11
+ const randomizedMove = hasRandomMove(rules) ? rules.randomize(move) : move;
12
+ if (preprocessMove)
13
+ preprocessMove(randomizedMove);
14
+ const consequences = rules.play(JSON.parse(JSON.stringify(randomizedMove))) ?? [];
15
+ moves.unshift(...consequences);
16
+ return true;
17
+ }, { errorFn: () => new Error(`Infinite loop detected while applying move consequences: ${JSON.stringify(rules.getAutomaticMoves())})`) });
18
+ }
25
19
  //# sourceMappingURL=ApplyAutomaticMoves.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApplyAutomaticMoves.js","sourceRoot":"","sources":["../src/ApplyAutomaticMoves.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,+CAA2C;AAG3C,SAAgB,mBAAmB,CAAuB,KAAkC,EAAE,KAAkB,EAAE,cAAqC;IAAzD,sBAAA,EAAA,UAAkB;IAC9G,IAAA,2BAAY,EAAC;;QACX,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,EAAE;YACjD,KAAK,CAAC,IAAI,OAAV,KAAK,EAAS,KAAK,CAAC,iBAAiB,EAAE,EAAC;SACzC;QACD,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;QAC1B,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QACvB,IAAM,cAAc,GAAG,IAAA,0BAAa,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC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AE,cAAc,CAAC,cAAc,CAAC,CAAA;QAClD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACjF,KAAK,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC,EAAE,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,4DAA4D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAkB,EAAE,CAAC,GAAG,CAAC,EAAC,CAAC,CAAA;AAC3I,CAAC"}
@@ -1,6 +1,6 @@
1
- import Rules from './Rules';
2
- export default interface Competitive<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
3
- rankPlayers(playerA: PlayerId, playerB: PlayerId): number;
4
- getScore?(playerId: PlayerId): number;
5
- }
6
- export declare function isCompetitive<Game, Move, PlayerId>(rules: Rules<any, any, PlayerId>): rules is Competitive<Game, Move, PlayerId>;
1
+ import Rules from './Rules';
2
+ export default interface Competitive<Game, Move = string, PlayerId = number> extends Rules<Game, Move, PlayerId> {
3
+ rankPlayers(playerA: PlayerId, playerB: PlayerId): number;
4
+ getScore?(playerId: PlayerId): number;
5
+ }
6
+ export declare function isCompetitive<Game, Move, PlayerId>(rules: Rules<any, any, PlayerId>): rules is Competitive<Game, Move, PlayerId>;
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCompetitive = void 0;
4
- function isCompetitive(rules) {
5
- return rules.rankPlayers !== undefined;
6
- }
7
- exports.isCompetitive = isCompetitive;
1
+ export function isCompetitive(rules) {
2
+ return rules.rankPlayers !== undefined;
3
+ }
8
4
  //# sourceMappingURL=Competitive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Competitive.js","sourceRoot":"","sources":["../src/Competitive.ts"],"names":[],"mappings":";;;AAOA,SAAgB,aAAa,CAAuB,KAAgC;IAClF,OAAQ,KAA2C,CAAC,WAAW,KAAK,SAAS,CAAA;AAC/E,CAAC;AAFD,sCAEC"}
1
+ {"version":3,"file":"Competitive.js","sourceRoot":"","sources":["../src/Competitive.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,aAAa,CAAuB,KAAgC;IAClF,OAAQ,KAA2C,CAAC,WAAW,KAAK,SAAS,CAAA;AAC/E,CAAC"}
package/dist/Dummy.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import RulesCreator from './RulesCreator';
2
- export default class Dummy<Game, Move = string, PlayerId = number> {
3
- Rules: RulesCreator<Game, Move, PlayerId>;
4
- constructor(Rules: RulesCreator<Game, Move, PlayerId>);
5
- getRandomMove(state: Game, playerId: PlayerId): Promise<Move[]>;
6
- getLegalMoves(state: Game, playerId: PlayerId): Move[];
7
- }
1
+ import RulesCreator from './RulesCreator';
2
+ export default class Dummy<Game, Move = string, PlayerId = number> {
3
+ Rules: RulesCreator<Game, Move, PlayerId>;
4
+ constructor(Rules: RulesCreator<Game, Move, PlayerId>);
5
+ getRandomMove(state: Game, playerId: PlayerId): Promise<Move[]>;
6
+ getLegalMoves(state: Game, playerId: PlayerId): Move[];
7
+ }
package/dist/Dummy.js CHANGED
@@ -1,26 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Dummy = /** @class */ (function () {
4
- function Dummy(Rules) {
5
- this.Rules = Rules;
6
- }
7
- Dummy.prototype.getRandomMove = function (state, playerId) {
8
- var moves = this.getLegalMoves(state, playerId);
9
- if (!moves.length)
10
- return Promise.resolve([]);
11
- return Promise.resolve([moves[Math.floor(Math.random() * moves.length)]]);
12
- };
13
- Dummy.prototype.getLegalMoves = function (state, playerId) {
14
- var rules = new this.Rules(state);
15
- if (rules.getLegalMoves) {
16
- return rules.getLegalMoves(playerId);
17
- }
18
- else {
19
- console.error('Dummy player cannot work if getLegalMoves is not implemented!');
20
- return [];
21
- }
22
- };
23
- return Dummy;
24
- }());
25
- exports.default = Dummy;
1
+ export default class Dummy {
2
+ Rules;
3
+ constructor(Rules) {
4
+ this.Rules = Rules;
5
+ }
6
+ getRandomMove(state, playerId) {
7
+ let moves = this.getLegalMoves(state, playerId);
8
+ if (!moves.length)
9
+ return Promise.resolve([]);
10
+ return Promise.resolve([moves[Math.floor(Math.random() * moves.length)]]);
11
+ }
12
+ getLegalMoves(state, playerId) {
13
+ const rules = new this.Rules(state);
14
+ if (rules.getLegalMoves) {
15
+ return rules.getLegalMoves(playerId);
16
+ }
17
+ else {
18
+ console.error('Dummy player cannot work if getLegalMoves is not implemented!');
19
+ return [];
20
+ }
21
+ }
22
+ }
26
23
  //# sourceMappingURL=Dummy.js.map
package/dist/Dummy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Dummy.js","sourceRoot":"","sources":["../src/Dummy.ts"],"names":[],"mappings":";;AAEA;IAIE,eAAY,KAAyC;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,6BAAa,GAAb,UAAc,KAAW,EAAE,QAAkB;QAC3C,IAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;SACrC;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAC9E,OAAO,EAAE,CAAA;SACV;IACH,CAAC;IACH,YAAC;AAAD,CAAC,AAvBD,IAuBC"}
1
+ {"version":3,"file":"Dummy.js","sourceRoot":"","sources":["../src/Dummy.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,KAAK;IAExB,KAAK,CAAoC;IAEzC,YAAY,KAAyC;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,aAAa,CAAC,KAAW,EAAE,QAAkB;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,aAAa,CAAC,KAAW,EAAE,QAAkB;QAC3C,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAA;YAC9E,OAAO,EAAE,CAAA;QACX,CAAC;IACH,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
- export default interface Eliminations<Move = string, PlayerId = number> {
2
- isEliminated(playerId: PlayerId): boolean;
3
- giveUpMove?(playerId: PlayerId): Move | undefined;
4
- }
5
- export declare function hasEliminations<Move, PlayerId>(rules: Object): rules is Eliminations<Move, PlayerId>;
1
+ export default interface Eliminations<Move = string, PlayerId = number> {
2
+ isEliminated(playerId: PlayerId): boolean;
3
+ giveUpMove?(playerId: PlayerId): Move | undefined;
4
+ }
5
+ export declare function hasEliminations<Move, PlayerId>(rules: Object): rules is Eliminations<Move, PlayerId>;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasEliminations = void 0;
4
- function hasEliminations(rules) {
5
- var test = rules;
6
- return typeof test.isEliminated === 'function';
7
- }
8
- exports.hasEliminations = hasEliminations;
1
+ export function hasEliminations(rules) {
2
+ const test = rules;
3
+ return typeof test.isEliminated === 'function';
4
+ }
9
5
  //# sourceMappingURL=Eliminations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":";;;AAMA,SAAgB,eAAe,CAAiB,KAAa;IAC3D,IAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC;AAHD,0CAGC"}
1
+ {"version":3,"file":"Eliminations.js","sourceRoot":"","sources":["../src/Eliminations.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,eAAe,CAAiB,KAAa;IAC3D,MAAM,IAAI,GAAG,KAAqC,CAAA;IAClD,OAAO,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAA;AAChD,CAAC"}
@@ -1,14 +1,14 @@
1
- import Rules from './Rules';
2
- export default interface IncompleteInformation<GameView = any, Move = any, MoveView = any> {
3
- getView(): GameView;
4
- getMoveView(move: Move): MoveView;
5
- }
6
- export declare function hasIncompleteInformation<GameView = any, Move = any, MoveView = any>(rules: Object): rules is IncompleteInformation<GameView, Move, MoveView>;
7
- export interface SecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any> extends IncompleteInformation<GameView, Move, MoveView> {
8
- getPlayerView(playerId: PlayerId): GameView;
9
- getPlayerMoveView?(move: Move, playerId: PlayerId): MoveView;
10
- keepMoveSecret?(move: Move, playerId: PlayerId): boolean;
11
- }
12
- export declare function hasSecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any>(rules: Object): rules is SecretInformation<GameView, Move, MoveView, PlayerId>;
13
- export declare function getGameView<Game, GameView, PlayerId>(rules: Rules<Game, any, PlayerId>, playerId?: PlayerId): GameView;
14
- export declare function getMoveView<GameView, Move, MoveView, PlayerId>(rules: Rules<any, Move, PlayerId>, move: Move, playerId?: PlayerId): MoveView;
1
+ import Rules from './Rules';
2
+ export default interface IncompleteInformation<GameView = any, Move = any, MoveView = any> {
3
+ getView(): GameView;
4
+ getMoveView(move: Move): MoveView;
5
+ }
6
+ export declare function hasIncompleteInformation<GameView = any, Move = any, MoveView = any>(rules: Object): rules is IncompleteInformation<GameView, Move, MoveView>;
7
+ export interface SecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any> extends IncompleteInformation<GameView, Move, MoveView> {
8
+ getPlayerView(playerId: PlayerId): GameView;
9
+ getPlayerMoveView?(move: Move, playerId: PlayerId): MoveView;
10
+ keepMoveSecret?(move: Move, playerId: PlayerId): boolean;
11
+ }
12
+ export declare function hasSecretInformation<GameView = any, Move = any, MoveView = any, PlayerId = any>(rules: Object): rules is SecretInformation<GameView, Move, MoveView, PlayerId>;
13
+ export declare function getGameView<Game, GameView, PlayerId>(rules: Rules<Game, any, PlayerId>, playerId?: PlayerId): GameView;
14
+ export declare function getMoveView<GameView, Move, MoveView, PlayerId>(rules: Rules<any, Move, PlayerId>, move: Move, playerId?: PlayerId): MoveView;
@@ -1,38 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMoveView = exports.getGameView = exports.hasSecretInformation = exports.hasIncompleteInformation = void 0;
4
- function hasIncompleteInformation(rules) {
5
- var test = rules;
6
- return typeof test.getView === 'function' && typeof test.getMoveView === 'function';
7
- }
8
- exports.hasIncompleteInformation = hasIncompleteInformation;
9
- function hasSecretInformation(rules) {
10
- var test = rules;
11
- return typeof test.getPlayerView === 'function';
12
- }
13
- exports.hasSecretInformation = hasSecretInformation;
14
- function getGameView(rules, playerId) {
15
- if (hasSecretInformation(rules) && playerId !== undefined) {
16
- return rules.getPlayerView(playerId);
17
- }
18
- else if (hasIncompleteInformation(rules)) {
19
- return rules.getView();
20
- }
21
- else {
22
- return rules.game;
23
- }
24
- }
25
- exports.getGameView = getGameView;
26
- function getMoveView(rules, move, playerId) {
27
- if (hasSecretInformation(rules) && rules.getPlayerMoveView && playerId !== undefined) {
28
- return JSON.parse(JSON.stringify(rules.getPlayerMoveView(move, playerId)));
29
- }
30
- else if (hasIncompleteInformation(rules)) {
31
- return JSON.parse(JSON.stringify(rules.getMoveView(move)));
32
- }
33
- else {
34
- return move;
35
- }
36
- }
37
- exports.getMoveView = getMoveView;
1
+ export function hasIncompleteInformation(rules) {
2
+ const test = rules;
3
+ return typeof test.getView === 'function' && typeof test.getMoveView === 'function';
4
+ }
5
+ export function hasSecretInformation(rules) {
6
+ const test = rules;
7
+ return typeof test.getPlayerView === 'function';
8
+ }
9
+ export function getGameView(rules, playerId) {
10
+ if (hasSecretInformation(rules) && playerId !== undefined) {
11
+ return rules.getPlayerView(playerId);
12
+ }
13
+ else if (hasIncompleteInformation(rules)) {
14
+ return rules.getView();
15
+ }
16
+ else {
17
+ return rules.game;
18
+ }
19
+ }
20
+ export function getMoveView(rules, move, playerId) {
21
+ if (hasSecretInformation(rules) && rules.getPlayerMoveView && playerId !== undefined) {
22
+ return JSON.parse(JSON.stringify(rules.getPlayerMoveView(move, playerId)));
23
+ }
24
+ else if (hasIncompleteInformation(rules)) {
25
+ return JSON.parse(JSON.stringify(rules.getMoveView(move)));
26
+ }
27
+ else {
28
+ return move;
29
+ }
30
+ }
38
31
  //# sourceMappingURL=IncompleteInformation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IncompleteInformation.js","sourceRoot":"","sources":["../src/IncompleteInformation.ts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AAC,CAAC,CAAC,CAAA;IAC5D,CAAC;SAAM,CAAC;QACN,OAAO,IAAuB,CAAA;IAChC,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare function loopWithFuse(repeat: () => boolean, options?: {
2
- attempts?: number;
3
- errorFn?: () => Error;
4
- }): void;
1
+ export declare function loopWithFuse(repeat: () => boolean, options?: {
2
+ attempts?: number;
3
+ errorFn?: () => Error;
4
+ }): void;
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loopWithFuse = void 0;
4
- function loopWithFuse(repeat, options) {
5
- var attempts = (options === null || options === void 0 ? void 0 : options.attempts) || (process.env.NODE_ENV === 'development' ? 100 : 1000);
6
- var errorFn = (options === null || options === void 0 ? void 0 : options.errorFn) || (function () { return new Error('Infinite loop detected'); });
7
- while (repeat()) {
8
- if (attempts == 0) {
9
- throw errorFn();
10
- }
11
- attempts--;
12
- }
13
- }
14
- exports.loopWithFuse = loopWithFuse;
1
+ export function loopWithFuse(repeat, options) {
2
+ let attempts = options?.attempts || (process.env.NODE_ENV === 'development' ? 100 : 1000);
3
+ const errorFn = options?.errorFn || (() => new Error('Infinite loop detected'));
4
+ while (repeat()) {
5
+ if (attempts == 0) {
6
+ throw errorFn();
7
+ }
8
+ attempts--;
9
+ }
10
+ }
15
11
  //# sourceMappingURL=LoopWithFuse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoopWithFuse.js","sourceRoot":"","sources":["../src/LoopWithFuse.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,MAAqB,EAAE,OAAsD;IACxG,IAAI,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACzF,IAAM,OAAO,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,CAAC,cAAM,OAAA,IAAI,KAAK,CAAC,wBAAwB,CAAC,EAAnC,CAAmC,CAAC,CAAA;IAC/E,OAAO,MAAM,EAAE,EAAE;QACf,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,MAAM,OAAO,EAAE,CAAA;SAChB;QACD,QAAQ,EAAE,CAAA;KACX;AACH,CAAC;AATD,oCASC"}
1
+ {"version":3,"file":"LoopWithFuse.js","sourceRoot":"","sources":["../src/LoopWithFuse.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,MAAqB,EAAE,OAAsD;IACxG,IAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACzF,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAA;IAC/E,OAAO,MAAM,EAAE,EAAE,CAAC;QAChB,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,OAAO,EAAE,CAAA;QACjB,CAAC;QACD,QAAQ,EAAE,CAAA;IACZ,CAAC;AACH,CAAC"}
@@ -1,7 +1,7 @@
1
- import Rules from './Rules';
2
- export default interface RandomMove<Move = string, RandomizedMove = string> {
3
- randomize(move: Move): Move & RandomizedMove;
4
- play(move: Move & RandomizedMove): Move[];
5
- }
6
- export declare function hasRandomMove<Game, Move, RandomizedMove>(rules: Rules<Game, Move>): rules is Rules<Game, Move> & RandomMove<Move, RandomizedMove>;
7
- export declare function randomizeMoves<Game, Move, RandomizedMove = Move>(rules: Rules<Game, Move>, moves: Move[]): (Move & RandomizedMove)[];
1
+ import Rules from './Rules';
2
+ export default interface RandomMove<Move = string, RandomizedMove = string> {
3
+ randomize(move: Move): Move & RandomizedMove;
4
+ play(move: Move & RandomizedMove): Move[];
5
+ }
6
+ export declare function hasRandomMove<Game, Move, RandomizedMove>(rules: Rules<Game, Move>): rules is Rules<Game, Move> & RandomMove<Move, RandomizedMove>;
7
+ export declare function randomizeMoves<Game, Move, RandomizedMove = Move>(rules: Rules<Game, Move>, moves: Move[]): (Move & RandomizedMove)[];
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randomizeMoves = exports.hasRandomMove = void 0;
4
- function hasRandomMove(rules) {
5
- var test = rules;
6
- return typeof test.randomize === 'function';
7
- }
8
- exports.hasRandomMove = hasRandomMove;
9
- function randomizeMoves(rules, moves) {
10
- return hasRandomMove(rules) ? moves.map(function (move) { return rules.randomize(move); }) : moves;
11
- }
12
- exports.randomizeMoves = randomizeMoves;
1
+ export function hasRandomMove(rules) {
2
+ const test = rules;
3
+ return typeof test.randomize === 'function';
4
+ }
5
+ export function randomizeMoves(rules, moves) {
6
+ return hasRandomMove(rules) ? moves.map(move => rules.randomize(move)) : moves;
7
+ }
13
8
  //# sourceMappingURL=RandomMove.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RandomMove.js","sourceRoot":"","sources":["../src/RandomMove.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,CAA6B,KAAwB;IAChF,IAAM,IAAI,GAAG,KAA6D,CAAA;IAC1E,OAAO,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,CAAA;AAC7C,CAAC;AAHD,sCAGC;AAED,SAAgB,cAAc,CAAoC,KAAwB,EAAE,KAAa;IACvG,OAAO,aAAa,CAA6B,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC,CAAC,CAAC,CAAE,KAAmC,CAAA;AAC3I,CAAC;AAFD,wCAEC"}
1
+ {"version":3,"file":"RandomMove.js","sourceRoot":"","sources":["../src/RandomMove.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,aAAa,CAA6B,KAAwB;IAChF,MAAM,IAAI,GAAG,KAA6D,CAAA;IAC1E,OAAO,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,CAAA;AAC7C,CAAC;AAED,MAAM,UAAU,cAAc,CAAoC,KAAwB,EAAE,KAAa;IACvG,OAAO,aAAa,CAA6B,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAE,KAAmC,CAAA;AAC3I,CAAC"}
package/dist/Robot.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare type Robot<Game, Move = string, PlayerId = number> = (state: Game, playerId: PlayerId) => Promise<Move[]>;
2
- export default Robot;
1
+ type Robot<Game, Move = string, PlayerId = number> = (state: Game, playerId: PlayerId) => Promise<Move[]>;
2
+ export default Robot;
package/dist/Robot.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=Robot.js.map