tods-competition-factory 1.7.3 → 1.7.4
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/forge/generate.d.ts +7 -2
- package/dist/forge/generate.mjs +332 -214
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +278 -173
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +301 -212
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
|
|
|
362
362
|
};
|
|
363
363
|
|
|
364
364
|
function factoryVersion() {
|
|
365
|
-
return '1.7.
|
|
365
|
+
return '1.7.4';
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/******************************************************************************
|
|
@@ -5511,6 +5511,7 @@ function getMatchUpFormatAverageTimes(_a) {
|
|
|
5511
5511
|
});
|
|
5512
5512
|
}
|
|
5513
5513
|
|
|
5514
|
+
var DYNAMIC = 'DYNAMIC';
|
|
5514
5515
|
var RANKING$1 = 'RANKING';
|
|
5515
5516
|
var RATING$2 = 'RATING';
|
|
5516
5517
|
var SCALE$1 = 'SCALE';
|
|
@@ -14954,21 +14955,27 @@ var _a$g;
|
|
|
14954
14955
|
var ratingsParameters = (_a$g = {},
|
|
14955
14956
|
_a$g[ELO] = { range: [0, 3000], decimalsCount: 0, defaultInitialization: 1500 },
|
|
14956
14957
|
_a$g[NTRP] = {
|
|
14957
|
-
range: [1, 7],
|
|
14958
|
-
decimalsCount: 1,
|
|
14959
|
-
defaultInitialization: 3,
|
|
14960
|
-
accessor: 'dntrpRatingHundredths',
|
|
14961
14958
|
accessors: ['ntrpRating', 'dntrpRatingHundredths'],
|
|
14962
14959
|
attributes: { ustaRatingType: '' },
|
|
14960
|
+
accessor: 'dntrpRatingHundredths',
|
|
14961
|
+
defaultInitialization: 3,
|
|
14962
|
+
decimalsCount: 1,
|
|
14963
|
+
range: [1, 7],
|
|
14963
14964
|
},
|
|
14964
|
-
_a$g[UTR] = {
|
|
14965
|
-
|
|
14966
|
-
|
|
14965
|
+
_a$g[UTR] = {
|
|
14966
|
+
defaultInitialization: 6,
|
|
14967
|
+
accessors: ['utrRating'],
|
|
14968
|
+
accessor: 'utrRating',
|
|
14967
14969
|
decimalsCount: 2,
|
|
14970
|
+
range: [1, 16],
|
|
14971
|
+
},
|
|
14972
|
+
_a$g[WTN] = {
|
|
14973
|
+
attributes: { confidence: { generator: true, range: [60, 100] } },
|
|
14974
|
+
accessors: ['wtnRating', 'confidence'],
|
|
14968
14975
|
defaultInitialization: 23,
|
|
14969
14976
|
accessor: 'wtnRating',
|
|
14970
|
-
|
|
14971
|
-
|
|
14977
|
+
decimalsCount: 2,
|
|
14978
|
+
range: [40, 1],
|
|
14972
14979
|
},
|
|
14973
14980
|
_a$g);
|
|
14974
14981
|
|
|
@@ -43025,7 +43032,7 @@ function feedInLinks(_a) {
|
|
|
43025
43032
|
}
|
|
43026
43033
|
|
|
43027
43034
|
function generateCurtisConsolation(params) {
|
|
43028
|
-
var finishingPositionOffset = params.finishingPositionOffset, _a = params.structureName, structureName = _a === void 0 ? MAIN : _a, _b = params.stageSequence, stageSequence = _b === void 0 ? 1 : _b, staggeredEntry = params.staggeredEntry, _c = params.stage, stage = _c === void 0 ? MAIN : _c, matchUpType = params.matchUpType, structureId = params.structureId, drawSize = params.drawSize, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
|
|
43035
|
+
var finishingPositionOffset = params.finishingPositionOffset, _a = params.structureName, structureName = _a === void 0 ? MAIN : _a, _b = params.stageSequence, stageSequence = _b === void 0 ? 1 : _b, structureNameMap = params.structureNameMap, staggeredEntry = params.staggeredEntry, _c = params.stage, stage = _c === void 0 ? MAIN : _c, matchUpType = params.matchUpType, structureId = params.structureId, drawSize = params.drawSize, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
|
|
43029
43036
|
var mainParams = {
|
|
43030
43037
|
finishingPositionOffset: finishingPositionOffset,
|
|
43031
43038
|
matchUpType: matchUpType,
|
|
@@ -43052,8 +43059,9 @@ function generateCurtisConsolation(params) {
|
|
|
43052
43059
|
var consolationItems = feedRoundOffsets.map(function (roundOffset, index) {
|
|
43053
43060
|
var stageSequence = index + 1;
|
|
43054
43061
|
var consolationStructure = consolationFeedStructure({
|
|
43055
|
-
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
43056
43062
|
idPrefix: idPrefix && "".concat(idPrefix, "-c").concat(index),
|
|
43063
|
+
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
43064
|
+
structureNameMap: structureNameMap,
|
|
43057
43065
|
stageSequence: stageSequence,
|
|
43058
43066
|
roundOffset: roundOffset,
|
|
43059
43067
|
matchUpType: matchUpType,
|
|
@@ -43086,9 +43094,9 @@ function generateCurtisConsolation(params) {
|
|
|
43086
43094
|
isMock: isMock,
|
|
43087
43095
|
}).matchUps;
|
|
43088
43096
|
var playoffStructure = structureTemplate({
|
|
43097
|
+
structureName: (structureNameMap === null || structureNameMap === void 0 ? void 0 : structureNameMap[PLAY_OFF]) || PLAY_OFF,
|
|
43089
43098
|
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
43090
43099
|
matchUps: playoffMatchUps,
|
|
43091
|
-
structureName: PLAY_OFF,
|
|
43092
43100
|
stageSequence: 2,
|
|
43093
43101
|
stage: PLAY_OFF,
|
|
43094
43102
|
matchUpType: matchUpType,
|
|
@@ -43112,7 +43120,7 @@ function generateCurtisConsolation(params) {
|
|
|
43112
43120
|
return __assign({ structures: structures, links: links }, SUCCESS);
|
|
43113
43121
|
}
|
|
43114
43122
|
function consolationFeedStructure(_a) {
|
|
43115
|
-
var _b = _a.stageSequence, stageSequence = _b === void 0 ? 1 : _b, _c = _a.roundOffset, roundOffset = _c === void 0 ? 0 : _c, matchUpType = _a.matchUpType, structureId = _a.structureId, idPrefix = _a.idPrefix, drawSize = _a.drawSize, isMock = _a.isMock, index = _a.index, uuids = _a.uuids;
|
|
43123
|
+
var _b = _a.stageSequence, stageSequence = _b === void 0 ? 1 : _b, structureNameMap = _a.structureNameMap, _c = _a.roundOffset, roundOffset = _c === void 0 ? 0 : _c, matchUpType = _a.matchUpType, structureId = _a.structureId, idPrefix = _a.idPrefix, drawSize = _a.drawSize, isMock = _a.isMock, index = _a.index, uuids = _a.uuids;
|
|
43116
43124
|
var consolationDrawPositions = drawSize / (2 * Math.pow(2, roundOffset));
|
|
43117
43125
|
var _d = feedInMatchUps({
|
|
43118
43126
|
finishingPositionOffset: consolationDrawPositions,
|
|
@@ -43124,7 +43132,8 @@ function consolationFeedStructure(_a) {
|
|
|
43124
43132
|
isMock: isMock,
|
|
43125
43133
|
uuids: uuids,
|
|
43126
43134
|
}), consolationMatchUps = _d.matchUps, consolationRoundsCount = _d.roundsCount;
|
|
43127
|
-
var
|
|
43135
|
+
var defaultName = "".concat(CONSOLATION, " ").concat(index + 1);
|
|
43136
|
+
var structureName = (structureNameMap === null || structureNameMap === void 0 ? void 0 : structureNameMap[defaultName]) || defaultName;
|
|
43128
43137
|
var consolationStructure = structureTemplate({
|
|
43129
43138
|
matchUps: consolationMatchUps,
|
|
43130
43139
|
stage: CONSOLATION,
|
|
@@ -43383,6 +43392,7 @@ function processPlayoffGroups(_a) {
|
|
|
43383
43392
|
}
|
|
43384
43393
|
var params = {
|
|
43385
43394
|
structureId: (_c = playoffGroup.structureId) !== null && _c !== void 0 ? _c : uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
43395
|
+
structureNameMap: playoffGroup.structureNameMap,
|
|
43386
43396
|
structureName: playoffGroup.structureName,
|
|
43387
43397
|
idPrefix: idPrefix && "".concat(idPrefix, "-po"),
|
|
43388
43398
|
appliedPolicies: policyDefinitions,
|
|
@@ -50536,59 +50546,96 @@ function removeDelegatedOutcome$1(_a) {
|
|
|
50536
50546
|
}
|
|
50537
50547
|
|
|
50538
50548
|
function generateCandidate(_a) {
|
|
50539
|
-
var _b = _a.maxIterations, maxIterations = _b === void 0 ?
|
|
50549
|
+
var _b = _a.maxIterations, maxIterations = _b === void 0 ? 4000 : _b, // cap the processing intensity of the candidate generator
|
|
50540
50550
|
valueSortedPairings = _a.valueSortedPairings, // pairings sorted by value from low to high
|
|
50541
|
-
pairingValues = _a.pairingValues, deltaObjects = _a.deltaObjects;
|
|
50542
|
-
var
|
|
50551
|
+
pairingValues = _a.pairingValues, valueObjects = _a.valueObjects, deltaObjects = _a.deltaObjects;
|
|
50552
|
+
var pairingValueMap = Object.assign.apply(Object, __spreadArray([{}], __read(valueSortedPairings.map(function (rm) {
|
|
50543
50553
|
var _a;
|
|
50544
50554
|
return (_a = {}, _a[rm.pairing] = rm.value, _a);
|
|
50545
50555
|
})), false));
|
|
50556
|
+
var actors = Object.keys(pairingValues);
|
|
50557
|
+
var proposedCandidates = [];
|
|
50546
50558
|
// generate an initial candidate value with no stipulated pairings
|
|
50547
|
-
var
|
|
50548
|
-
|
|
50559
|
+
var initialProposal = roundCandidate({
|
|
50560
|
+
actorsCount: actors.length,
|
|
50549
50561
|
valueSortedPairings: valueSortedPairings,
|
|
50562
|
+
pairingValueMap: pairingValueMap,
|
|
50550
50563
|
deltaObjects: deltaObjects,
|
|
50564
|
+
valueObjects: valueObjects,
|
|
50551
50565
|
});
|
|
50552
|
-
var
|
|
50553
|
-
|
|
50566
|
+
var candidateHashes = [candidateHash(initialProposal)];
|
|
50567
|
+
proposedCandidates.push(initialProposal);
|
|
50568
|
+
var lowCandidateValue = initialProposal.value;
|
|
50569
|
+
var deltaCandidate = initialProposal;
|
|
50554
50570
|
// iterations is the number of loops over valueSortedPairings
|
|
50555
50571
|
var candidatesCount = 0;
|
|
50556
|
-
var iterations;
|
|
50557
|
-
// calculate the number of opponents to consider for each participantId
|
|
50572
|
+
var iterations = 0;
|
|
50558
50573
|
var opponentCount = actors.length;
|
|
50574
|
+
var calculatedIterations;
|
|
50575
|
+
// calculate the number of opponents to consider for each participantId
|
|
50559
50576
|
do {
|
|
50560
50577
|
opponentCount -= 1;
|
|
50561
|
-
|
|
50562
|
-
|
|
50563
|
-
|
|
50578
|
+
calculatedIterations = actors.length * pairingValues[actors[0]].length;
|
|
50579
|
+
} while (calculatedIterations > maxIterations && opponentCount > 5);
|
|
50580
|
+
// keep track of proposed pairings
|
|
50564
50581
|
var stipulatedPairs = [];
|
|
50565
50582
|
// for each actor generate a roundCandidate using opponentCount of pairing values
|
|
50566
50583
|
actors.forEach(function (actor) {
|
|
50567
50584
|
var participantIdPairings = pairingValues[actor];
|
|
50568
50585
|
// opponentCount limits the number of opponents to consider
|
|
50569
50586
|
participantIdPairings.slice(0, opponentCount).forEach(function (pairing) {
|
|
50587
|
+
iterations += 1;
|
|
50570
50588
|
var stipulatedPair = pairingHash(actor, pairing.opponent);
|
|
50571
50589
|
if (!stipulatedPairs.includes(stipulatedPair)) {
|
|
50572
50590
|
var proposed = roundCandidate({
|
|
50573
50591
|
// each roundCandidate starts with stipulated pairings
|
|
50574
50592
|
stipulated: [[actor, pairing.opponent]],
|
|
50575
|
-
|
|
50593
|
+
actorsCount: actors.length,
|
|
50576
50594
|
valueSortedPairings: valueSortedPairings,
|
|
50595
|
+
pairingValueMap: pairingValueMap,
|
|
50577
50596
|
deltaObjects: deltaObjects,
|
|
50597
|
+
valueObjects: valueObjects,
|
|
50578
50598
|
});
|
|
50579
|
-
|
|
50580
|
-
|
|
50581
|
-
|
|
50582
|
-
|
|
50583
|
-
|
|
50584
|
-
|
|
50599
|
+
// ensure no duplicate candidates are considered
|
|
50600
|
+
if (!candidateHashes.includes(candidateHash(proposed))) {
|
|
50601
|
+
candidateHashes.push(candidateHash(proposed));
|
|
50602
|
+
proposedCandidates.push(proposed);
|
|
50603
|
+
var maxDelta = proposed.maxDelta, value = proposed.value;
|
|
50604
|
+
if (maxDelta < deltaCandidate.maxDelta)
|
|
50605
|
+
deltaCandidate = proposed;
|
|
50606
|
+
if (value < lowCandidateValue ||
|
|
50607
|
+
(value === lowCandidateValue && Math.round(Math.random())) // randomize if equivalent values
|
|
50608
|
+
) {
|
|
50609
|
+
lowCandidateValue = value;
|
|
50610
|
+
}
|
|
50611
|
+
stipulatedPairs.push(stipulatedPair);
|
|
50612
|
+
candidatesCount += 1;
|
|
50613
|
+
}
|
|
50585
50614
|
}
|
|
50586
50615
|
});
|
|
50616
|
+
proposedCandidates = proposedCandidates.filter(function (proposed) { return Math.abs(proposed.value - lowCandidateValue) < 5; });
|
|
50587
50617
|
});
|
|
50588
|
-
|
|
50618
|
+
proposedCandidates.sort(function (a, b) { return a.maxDiff - b.maxDiff; });
|
|
50619
|
+
var candidate = randomPop(proposedCandidates);
|
|
50620
|
+
return {
|
|
50621
|
+
candidatesCount: candidatesCount,
|
|
50622
|
+
deltaCandidate: deltaCandidate,
|
|
50623
|
+
maxIterations: maxIterations,
|
|
50624
|
+
iterations: iterations,
|
|
50625
|
+
candidate: candidate,
|
|
50626
|
+
};
|
|
50627
|
+
}
|
|
50628
|
+
function candidateHash(candidate) {
|
|
50629
|
+
return candidate.participantIdPairings
|
|
50630
|
+
.map(function (_a) {
|
|
50631
|
+
var participantIds = _a.participantIds;
|
|
50632
|
+
return participantIds.sort().join('|');
|
|
50633
|
+
})
|
|
50634
|
+
.sort()
|
|
50635
|
+
.join('/');
|
|
50589
50636
|
}
|
|
50590
50637
|
function roundCandidate(_a) {
|
|
50591
|
-
var
|
|
50638
|
+
var valueSortedPairings = _a.valueSortedPairings, _b = _a.stipulated, stipulated = _b === void 0 ? [] : _b, pairingValueMap = _a.pairingValueMap, deltaObjects = _a.deltaObjects, valueObjects = _a.valueObjects, actorsCount = _a.actorsCount;
|
|
50592
50639
|
// roundPlayers starts with the stipulated pairing
|
|
50593
50640
|
var roundPlayers = [].concat.apply([], __spreadArray([], __read(stipulated), false));
|
|
50594
50641
|
// aggregates the pairings generated for a roundCandidate
|
|
@@ -50600,13 +50647,19 @@ function roundCandidate(_a) {
|
|
|
50600
50647
|
stipulated.filter(Boolean).forEach(function (participantIds) {
|
|
50601
50648
|
var _a = __read(participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
50602
50649
|
var pairing = pairingHash(p1, p2);
|
|
50603
|
-
var value =
|
|
50650
|
+
var value = pairingValueMap[pairing];
|
|
50604
50651
|
participantIdPairings.push({ participantIds: participantIds, value: value });
|
|
50605
|
-
candidateValue +=
|
|
50652
|
+
candidateValue += pairingValueMap[pairing];
|
|
50606
50653
|
});
|
|
50654
|
+
// valueSortedPairings is an array sorted from lowest value to highest value
|
|
50655
|
+
// introduce random shuffling of chunks of valueSortedPairings
|
|
50656
|
+
var consideredPairings = chunkArray(valueSortedPairings, actorsCount)
|
|
50657
|
+
.map(function (pairings) {
|
|
50658
|
+
return shuffleArray(pairings).map(function (pairing) { return (__assign(__assign({}, pairing), { value: pairing.value + Math.random() * Math.round(Math.random()) })); });
|
|
50659
|
+
})
|
|
50660
|
+
.flat();
|
|
50607
50661
|
// go through the valueSortedPairings (of all possible unique pairings)
|
|
50608
|
-
|
|
50609
|
-
valueSortedPairings.forEach(function (rankedPairing) {
|
|
50662
|
+
consideredPairings.forEach(function (rankedPairing) {
|
|
50610
50663
|
var participantIds = rankedPairing.pairing.split('|');
|
|
50611
50664
|
var opponentExists = participantIds.reduce(function (p, c) { return roundPlayers.includes(c) || p; }, false);
|
|
50612
50665
|
if (!opponentExists) {
|
|
@@ -50625,21 +50678,181 @@ function roundCandidate(_a) {
|
|
|
50625
50678
|
var delta = deltaObjects[hash];
|
|
50626
50679
|
return delta > p ? delta : p;
|
|
50627
50680
|
}, 0);
|
|
50628
|
-
|
|
50681
|
+
// determine the greatest delta in the candidate's pairings
|
|
50682
|
+
var maxDiff = participantIdPairings.reduce(function (p, c) {
|
|
50683
|
+
var _a = __read(c.participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
50684
|
+
var hash = pairingHash(p1, p2);
|
|
50685
|
+
var diff = valueObjects[hash];
|
|
50686
|
+
return diff > p ? diff : p;
|
|
50687
|
+
}, 0);
|
|
50688
|
+
return { value: candidateValue, participantIdPairings: participantIdPairings, maxDelta: maxDelta, maxDiff: maxDiff };
|
|
50629
50689
|
}
|
|
50630
50690
|
function pairingHash(id1, id2) {
|
|
50631
50691
|
return [id1, id2].sort().join('|');
|
|
50632
50692
|
}
|
|
50633
50693
|
|
|
50634
|
-
|
|
50635
|
-
var
|
|
50636
|
-
var
|
|
50694
|
+
function getPairingsData(_a) {
|
|
50695
|
+
var participantIds = _a.participantIds;
|
|
50696
|
+
var possiblePairings = {};
|
|
50697
|
+
var uniquePairings = [];
|
|
50698
|
+
participantIds.forEach(function (participantId) {
|
|
50699
|
+
possiblePairings[participantId] = participantIds.filter(function (id) { return id !== participantId; });
|
|
50700
|
+
possiblePairings[participantId].forEach(function (id) {
|
|
50701
|
+
var pairing = pairingHash(id, participantId);
|
|
50702
|
+
if (!uniquePairings.includes(pairing))
|
|
50703
|
+
uniquePairings.push(pairing);
|
|
50704
|
+
});
|
|
50705
|
+
});
|
|
50706
|
+
var deltaObjects = Object.assign.apply(Object, __spreadArray([{}], __read(uniquePairings.map(function (pairing) {
|
|
50707
|
+
var _a;
|
|
50708
|
+
return (_a = {}, _a[pairing] = 0, _a);
|
|
50709
|
+
})), false));
|
|
50710
|
+
return { uniquePairings: uniquePairings, possiblePairings: possiblePairings, deltaObjects: deltaObjects };
|
|
50711
|
+
}
|
|
50712
|
+
|
|
50713
|
+
function getEncounters(_a) {
|
|
50714
|
+
var e_1, _b;
|
|
50715
|
+
var matchUps = _a.matchUps;
|
|
50716
|
+
var encounters = [];
|
|
50717
|
+
try {
|
|
50718
|
+
for (var matchUps_1 = __values(matchUps), matchUps_1_1 = matchUps_1.next(); !matchUps_1_1.done; matchUps_1_1 = matchUps_1.next()) {
|
|
50719
|
+
var matchUp = matchUps_1_1.value;
|
|
50720
|
+
var participantIds = matchUp.sides.map(extractAttributes('participantId'));
|
|
50721
|
+
if (participantIds.length === 2) {
|
|
50722
|
+
var _c = __read(participantIds, 2), p1 = _c[0], p2 = _c[1];
|
|
50723
|
+
var pairing = pairingHash(p1, p2);
|
|
50724
|
+
if (!encounters.includes(pairing))
|
|
50725
|
+
encounters.push(pairing);
|
|
50726
|
+
}
|
|
50727
|
+
}
|
|
50728
|
+
}
|
|
50729
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
50730
|
+
finally {
|
|
50731
|
+
try {
|
|
50732
|
+
if (matchUps_1_1 && !matchUps_1_1.done && (_b = matchUps_1.return)) _b.call(matchUps_1);
|
|
50733
|
+
}
|
|
50734
|
+
finally { if (e_1) throw e_1.error; }
|
|
50735
|
+
}
|
|
50736
|
+
return { encounters: encounters };
|
|
50737
|
+
}
|
|
50738
|
+
|
|
50739
|
+
function getParticipantPairingValues(_a) {
|
|
50740
|
+
var e_1, _b;
|
|
50741
|
+
var possiblePairings = _a.possiblePairings, valueObjects = _a.valueObjects;
|
|
50742
|
+
var pairingValues = {};
|
|
50743
|
+
var _loop_1 = function (participantId) {
|
|
50744
|
+
var participantValues = possiblePairings[participantId].map(function (opponent) {
|
|
50745
|
+
return pairingValue(participantId, opponent);
|
|
50746
|
+
});
|
|
50747
|
+
pairingValues[participantId] = participantValues.sort(function (a, b) { return a.value - b.value; });
|
|
50748
|
+
};
|
|
50749
|
+
try {
|
|
50750
|
+
for (var _c = __values(Object.keys(possiblePairings)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
50751
|
+
var participantId = _d.value;
|
|
50752
|
+
_loop_1(participantId);
|
|
50753
|
+
}
|
|
50754
|
+
}
|
|
50755
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
50756
|
+
finally {
|
|
50757
|
+
try {
|
|
50758
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
50759
|
+
}
|
|
50760
|
+
finally { if (e_1) throw e_1.error; }
|
|
50761
|
+
}
|
|
50762
|
+
function pairingValue(participantId, opponent) {
|
|
50763
|
+
var key = pairingHash(participantId, opponent);
|
|
50764
|
+
return { opponent: opponent, value: valueObjects[key] };
|
|
50765
|
+
}
|
|
50766
|
+
return { pairingValues: pairingValues };
|
|
50767
|
+
}
|
|
50768
|
+
|
|
50637
50769
|
var DEFAULT_RATING = 0;
|
|
50770
|
+
function getSideRatings(_a) {
|
|
50771
|
+
var _b, _c;
|
|
50772
|
+
var tournamentParticipants = _a.tournamentParticipants, adHocRatings = _a.adHocRatings, eventType = _a.eventType, scaleName = _a.scaleName, pairing = _a.pairing;
|
|
50773
|
+
var defaultRating = (_c = (_b = ratingsParameters[scaleName]) === null || _b === void 0 ? void 0 : _b.defaultInitialization) !== null && _c !== void 0 ? _c : DEFAULT_RATING;
|
|
50774
|
+
return pairing.split('|').map(function (participantId) {
|
|
50775
|
+
var _a;
|
|
50776
|
+
if (eventType === DOUBLES) {
|
|
50777
|
+
var individualParticipantIds = (_a = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; })) === null || _a === void 0 ? void 0 : _a.individualParticipantIds;
|
|
50778
|
+
return !individualParticipantIds
|
|
50779
|
+
? defaultRating * 2
|
|
50780
|
+
: individualParticipantIds === null || individualParticipantIds === void 0 ? void 0 : individualParticipantIds.map(function (participantId) { return adHocRatings[participantId] || defaultRating; });
|
|
50781
|
+
}
|
|
50782
|
+
else {
|
|
50783
|
+
return adHocRatings[participantId] || defaultRating;
|
|
50784
|
+
}
|
|
50785
|
+
});
|
|
50786
|
+
}
|
|
50787
|
+
|
|
50788
|
+
function getPairings(_a) {
|
|
50789
|
+
var tournamentParticipants = _a.tournamentParticipants, _b = _a.adHocRatings, adHocRatings = _b === void 0 ? {} : _b, possiblePairings = _a.possiblePairings, // participant keyed; provides array of possible opponents
|
|
50790
|
+
uniquePairings = _a.uniquePairings, // hashes of all possible participantId pairings
|
|
50791
|
+
maxIterations = _a.maxIterations, deltaObjects = _a.deltaObjects, // difference in rating between paired participants
|
|
50792
|
+
valueObjects = _a.valueObjects, // calculated value of a pairing of participants, used for sorting pairings
|
|
50793
|
+
eventType = _a.eventType, scaleName = _a.scaleName, salted = _a.salted;
|
|
50794
|
+
// modify valueObjects by ratings ratingsDifference squared
|
|
50795
|
+
// update deltaObjects to reflect the current difference between participant's ratings
|
|
50796
|
+
uniquePairings.forEach(function (pairing) {
|
|
50797
|
+
var ratings = getSideRatings({
|
|
50798
|
+
tournamentParticipants: tournamentParticipants,
|
|
50799
|
+
adHocRatings: adHocRatings,
|
|
50800
|
+
scaleName: scaleName,
|
|
50801
|
+
eventType: eventType,
|
|
50802
|
+
pairing: pairing,
|
|
50803
|
+
});
|
|
50804
|
+
var salting = (typeof salted === 'number' && salted) || 0.5;
|
|
50805
|
+
var salt = (salted && (Math.round(Math.random()) ? salting : salting * -1)) || 0;
|
|
50806
|
+
var ratingsDifference = Math.abs(ratings[0] - ratings[1]) + salt;
|
|
50807
|
+
var pairingDelta = Math.abs(ratings[0] - ratings[1]);
|
|
50808
|
+
deltaObjects[pairing] = pairingDelta;
|
|
50809
|
+
if (!valueObjects[pairing])
|
|
50810
|
+
valueObjects[pairing] = 0;
|
|
50811
|
+
valueObjects[pairing] += ratingsDifference
|
|
50812
|
+
? Math.pow(ratingsDifference, 2)
|
|
50813
|
+
: 0;
|
|
50814
|
+
});
|
|
50815
|
+
/**
|
|
50816
|
+
* valueSortedPairings are uniquePairings sorted by the ratings difference of the pairings, lowest to highest
|
|
50817
|
+
*/
|
|
50818
|
+
var valueSortedPairings = uniquePairings
|
|
50819
|
+
.map(function (pairing) { return ({ pairing: pairing, value: valueObjects[pairing] }); })
|
|
50820
|
+
.sort(function (a, b) { return a.value - b.value; });
|
|
50821
|
+
/**
|
|
50822
|
+
* pairingValues is keyed by participantId and provides a value-sorted array of pairings for each participantId
|
|
50823
|
+
* 'actorId': [
|
|
50824
|
+
{ opponent: 'potentialId1', value: 1 },
|
|
50825
|
+
{ opponent: 'potentialId2', value: 1 },
|
|
50826
|
+
*/
|
|
50827
|
+
var pairingValues = getParticipantPairingValues({
|
|
50828
|
+
possiblePairings: possiblePairings,
|
|
50829
|
+
valueObjects: valueObjects,
|
|
50830
|
+
}).pairingValues;
|
|
50831
|
+
var _c = generateCandidate({
|
|
50832
|
+
valueSortedPairings: valueSortedPairings,
|
|
50833
|
+
maxIterations: maxIterations,
|
|
50834
|
+
pairingValues: pairingValues,
|
|
50835
|
+
deltaObjects: deltaObjects,
|
|
50836
|
+
valueObjects: valueObjects,
|
|
50837
|
+
}), candidate = _c.candidate, candidatesCount = _c.candidatesCount, deltaCandidate = _c.deltaCandidate, iterations = _c.iterations;
|
|
50838
|
+
var participantIdPairings = candidate.participantIdPairings;
|
|
50839
|
+
return {
|
|
50840
|
+
participantIdPairings: participantIdPairings,
|
|
50841
|
+
candidatesCount: candidatesCount,
|
|
50842
|
+
deltaCandidate: deltaCandidate,
|
|
50843
|
+
iterations: iterations,
|
|
50844
|
+
candidate: candidate,
|
|
50845
|
+
};
|
|
50846
|
+
}
|
|
50847
|
+
|
|
50848
|
+
// this should be in policyDefinitions
|
|
50849
|
+
var ENCOUNTER_VALUE = 100;
|
|
50850
|
+
var SAME_TEAM_VALUE = 100;
|
|
50638
50851
|
var MAX_ITERATIONS = 5000;
|
|
50639
50852
|
function generateDrawMaticRound(_a) {
|
|
50640
50853
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
50641
50854
|
var _e, _f;
|
|
50642
|
-
var _g = _a.maxIterations, maxIterations = _g === void 0 ? MAX_ITERATIONS : _g, _h = _a.generateMatchUps, generateMatchUps = _h === void 0 ? true : _h, tournamentParticipants = _a.tournamentParticipants, tournamentRecord = _a.tournamentRecord, participantIds = _a.participantIds, addToStructure = _a.addToStructure, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, structureId = _a.structureId, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure;
|
|
50855
|
+
var _g = _a.maxIterations, maxIterations = _g === void 0 ? MAX_ITERATIONS : _g, _h = _a.generateMatchUps, generateMatchUps = _h === void 0 ? true : _h, tournamentParticipants = _a.tournamentParticipants, tournamentRecord = _a.tournamentRecord, participantIds = _a.participantIds, addToStructure = _a.addToStructure, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, structureId = _a.structureId, _j = _a.salted, salted = _j === void 0 ? 0.5 : _j, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure, scaleName = _a.scaleName;
|
|
50643
50856
|
if (!drawDefinition)
|
|
50644
50857
|
return { error: MISSING_DRAW_DEFINITION };
|
|
50645
50858
|
if (!structure && !structureId)
|
|
@@ -50718,9 +50931,9 @@ function generateDrawMaticRound(_a) {
|
|
|
50718
50931
|
// 'P-I-0|P-I-2': 0,
|
|
50719
50932
|
// 'P-I-0|P-I-3': 0
|
|
50720
50933
|
// }
|
|
50721
|
-
var
|
|
50934
|
+
var _k = getPairingsData({
|
|
50722
50935
|
participantIds: participantIds,
|
|
50723
|
-
}), uniquePairings =
|
|
50936
|
+
}), uniquePairings = _k.uniquePairings, possiblePairings = _k.possiblePairings, deltaObjects = _k.deltaObjects;
|
|
50724
50937
|
var params = {
|
|
50725
50938
|
tournamentParticipants: tournamentParticipants,
|
|
50726
50939
|
possiblePairings: possiblePairings,
|
|
@@ -50732,9 +50945,12 @@ function generateDrawMaticRound(_a) {
|
|
|
50732
50945
|
deltaObjects: deltaObjects,
|
|
50733
50946
|
valueObjects: valueObjects,
|
|
50734
50947
|
eventType: eventType,
|
|
50948
|
+
scaleName: scaleName,
|
|
50735
50949
|
structure: structure,
|
|
50950
|
+
salted: salted,
|
|
50736
50951
|
};
|
|
50737
|
-
var
|
|
50952
|
+
var _l = getPairings(params), candidatesCount = _l.candidatesCount, participantIdPairings = _l.participantIdPairings, iterations = _l.iterations;
|
|
50953
|
+
// console.log({ candidatesCount, participantIdPairings, iterations });
|
|
50738
50954
|
if (!candidatesCount)
|
|
50739
50955
|
return { error: NO_CANDIDATES };
|
|
50740
50956
|
var matchUps;
|
|
@@ -50754,144 +50970,11 @@ function generateDrawMaticRound(_a) {
|
|
|
50754
50970
|
}
|
|
50755
50971
|
return __assign(__assign({}, SUCCESS), { participantIdPairings: participantIdPairings, candidatesCount: candidatesCount, iterations: iterations, matchUps: matchUps });
|
|
50756
50972
|
}
|
|
50757
|
-
function getSideRatings(_a) {
|
|
50758
|
-
var tournamentParticipants = _a.tournamentParticipants, adHocRatings = _a.adHocRatings, eventType = _a.eventType, pairing = _a.pairing;
|
|
50759
|
-
return pairing.split('|').map(function (participantId) {
|
|
50760
|
-
var _a;
|
|
50761
|
-
if (eventType === DOUBLES) {
|
|
50762
|
-
var individualParticipantIds = (_a = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; })) === null || _a === void 0 ? void 0 : _a.individualParticipantIds;
|
|
50763
|
-
return !individualParticipantIds
|
|
50764
|
-
? DEFAULT_RATING * 2
|
|
50765
|
-
: individualParticipantIds === null || individualParticipantIds === void 0 ? void 0 : individualParticipantIds.map(function (participantId) { return adHocRatings[participantId || DEFAULT_RATING]; });
|
|
50766
|
-
}
|
|
50767
|
-
else {
|
|
50768
|
-
return adHocRatings[participantId] || DEFAULT_RATING;
|
|
50769
|
-
}
|
|
50770
|
-
});
|
|
50771
|
-
}
|
|
50772
|
-
function getPairings(_a) {
|
|
50773
|
-
var tournamentParticipants = _a.tournamentParticipants, _b = _a.adHocRatings, adHocRatings = _b === void 0 ? {} : _b, possiblePairings = _a.possiblePairings, // participant keyed; provides array of possible opponents
|
|
50774
|
-
uniquePairings = _a.uniquePairings, // hashes of all possible participantId pairings
|
|
50775
|
-
maxIterations = _a.maxIterations, deltaObjects = _a.deltaObjects, // difference in rating between paired participants
|
|
50776
|
-
valueObjects = _a.valueObjects, // calculated value of a pairing of participants, used for sorting pairings
|
|
50777
|
-
eventType = _a.eventType;
|
|
50778
|
-
// modify valueObjects by ratings ratingsDifference squared
|
|
50779
|
-
// update deltaObjects to reflect the current difference between participant's ratings
|
|
50780
|
-
uniquePairings.forEach(function (pairing) {
|
|
50781
|
-
var ratings = getSideRatings({
|
|
50782
|
-
tournamentParticipants: tournamentParticipants,
|
|
50783
|
-
adHocRatings: adHocRatings,
|
|
50784
|
-
eventType: eventType,
|
|
50785
|
-
pairing: pairing,
|
|
50786
|
-
});
|
|
50787
|
-
var ratingsDifference = Math.abs(ratings[0] - ratings[1]) + 1;
|
|
50788
|
-
deltaObjects[pairing] = Math.abs(ratings[0] - ratings[1]);
|
|
50789
|
-
if (!valueObjects[pairing])
|
|
50790
|
-
valueObjects[pairing] = 0;
|
|
50791
|
-
valueObjects[pairing] += Math.pow(ratingsDifference, 2);
|
|
50792
|
-
});
|
|
50793
|
-
/**
|
|
50794
|
-
* valueSortedPairings are uniquePairings sorted by the value of the pairings, lowest to highest
|
|
50795
|
-
*/
|
|
50796
|
-
var valueSortedPairings = uniquePairings
|
|
50797
|
-
.map(function (pairing) { return ({ pairing: pairing, value: valueObjects[pairing] }); })
|
|
50798
|
-
.sort(function (a, b) { return a.value - b.value; });
|
|
50799
|
-
/**
|
|
50800
|
-
* pairingValues is keyed by participantId and provides a value-sorted array of pairings for each participantId
|
|
50801
|
-
* 'actorId': [
|
|
50802
|
-
{ opponent: 'potentialId1', value: 1 },
|
|
50803
|
-
{ opponent: 'potentialId2', value: 1 },
|
|
50804
|
-
*/
|
|
50805
|
-
var pairingValues = getParticipantPairingValues({
|
|
50806
|
-
possiblePairings: possiblePairings,
|
|
50807
|
-
valueObjects: valueObjects,
|
|
50808
|
-
}).pairingValues;
|
|
50809
|
-
var _c = generateCandidate({
|
|
50810
|
-
valueSortedPairings: valueSortedPairings,
|
|
50811
|
-
maxIterations: maxIterations,
|
|
50812
|
-
pairingValues: pairingValues,
|
|
50813
|
-
deltaObjects: deltaObjects,
|
|
50814
|
-
}), candidate = _c.candidate, candidatesCount = _c.candidatesCount, iterations = _c.iterations;
|
|
50815
|
-
var participantIdPairings = candidate.participantIdPairings;
|
|
50816
|
-
return { candidatesCount: candidatesCount, participantIdPairings: participantIdPairings, iterations: iterations };
|
|
50817
|
-
}
|
|
50818
|
-
function getPairingsData(_a) {
|
|
50819
|
-
var participantIds = _a.participantIds;
|
|
50820
|
-
var possiblePairings = {};
|
|
50821
|
-
var uniquePairings = [];
|
|
50822
|
-
participantIds.forEach(function (participantId) {
|
|
50823
|
-
possiblePairings[participantId] = participantIds.filter(function (id) { return id !== participantId; });
|
|
50824
|
-
possiblePairings[participantId].forEach(function (id) {
|
|
50825
|
-
var pairing = pairingHash(id, participantId);
|
|
50826
|
-
if (!uniquePairings.includes(pairing))
|
|
50827
|
-
uniquePairings.push(pairing);
|
|
50828
|
-
});
|
|
50829
|
-
});
|
|
50830
|
-
var deltaObjects = Object.assign.apply(Object, __spreadArray([{}], __read(uniquePairings.map(function (pairing) {
|
|
50831
|
-
var _a;
|
|
50832
|
-
return (_a = {}, _a[pairing] = 0, _a);
|
|
50833
|
-
})), false));
|
|
50834
|
-
return { uniquePairings: uniquePairings, possiblePairings: possiblePairings, deltaObjects: deltaObjects };
|
|
50835
|
-
}
|
|
50836
|
-
function getEncounters(_a) {
|
|
50837
|
-
var e_4, _b;
|
|
50838
|
-
var matchUps = _a.matchUps;
|
|
50839
|
-
var encounters = [];
|
|
50840
|
-
try {
|
|
50841
|
-
for (var matchUps_1 = __values(matchUps), matchUps_1_1 = matchUps_1.next(); !matchUps_1_1.done; matchUps_1_1 = matchUps_1.next()) {
|
|
50842
|
-
var matchUp = matchUps_1_1.value;
|
|
50843
|
-
var participantIds = matchUp.sides.map(getParticipantId);
|
|
50844
|
-
if (participantIds.length === 2) {
|
|
50845
|
-
var _c = __read(participantIds, 2), p1 = _c[0], p2 = _c[1];
|
|
50846
|
-
var pairing = pairingHash(p1, p2);
|
|
50847
|
-
if (!encounters.includes(pairing))
|
|
50848
|
-
encounters.push(pairing);
|
|
50849
|
-
}
|
|
50850
|
-
}
|
|
50851
|
-
}
|
|
50852
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
50853
|
-
finally {
|
|
50854
|
-
try {
|
|
50855
|
-
if (matchUps_1_1 && !matchUps_1_1.done && (_b = matchUps_1.return)) _b.call(matchUps_1);
|
|
50856
|
-
}
|
|
50857
|
-
finally { if (e_4) throw e_4.error; }
|
|
50858
|
-
}
|
|
50859
|
-
return { encounters: encounters };
|
|
50860
|
-
}
|
|
50861
|
-
function getParticipantPairingValues(_a) {
|
|
50862
|
-
var e_5, _b;
|
|
50863
|
-
var possiblePairings = _a.possiblePairings, valueObjects = _a.valueObjects;
|
|
50864
|
-
var pairingValues = {};
|
|
50865
|
-
var _loop_1 = function (participantId) {
|
|
50866
|
-
var participantValues = possiblePairings[participantId].map(function (opponent) {
|
|
50867
|
-
return pairingValue(participantId, opponent);
|
|
50868
|
-
});
|
|
50869
|
-
pairingValues[participantId] = participantValues.sort(function (a, b) { return a.value - b.value; });
|
|
50870
|
-
};
|
|
50871
|
-
try {
|
|
50872
|
-
for (var _c = __values(Object.keys(possiblePairings)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
50873
|
-
var participantId = _d.value;
|
|
50874
|
-
_loop_1(participantId);
|
|
50875
|
-
}
|
|
50876
|
-
}
|
|
50877
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
50878
|
-
finally {
|
|
50879
|
-
try {
|
|
50880
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
50881
|
-
}
|
|
50882
|
-
finally { if (e_5) throw e_5.error; }
|
|
50883
|
-
}
|
|
50884
|
-
function pairingValue(participantId, opponent) {
|
|
50885
|
-
var key = pairingHash(participantId, opponent);
|
|
50886
|
-
return { opponent: opponent, value: valueObjects[key] };
|
|
50887
|
-
}
|
|
50888
|
-
return { pairingValues: pairingValues };
|
|
50889
|
-
}
|
|
50890
50973
|
|
|
50891
50974
|
function drawMatic$1(_a) {
|
|
50892
50975
|
var e_1, _b;
|
|
50893
50976
|
var _c, _d, _e, _f, _g;
|
|
50894
|
-
var tournamentParticipants = _a.tournamentParticipants, restrictEntryStatus = _a.restrictEntryStatus, tournamentRecord = _a.tournamentRecord, generateMatchUps = _a.generateMatchUps, addToStructure = _a.addToStructure, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, scaleAccessor = _a.scaleAccessor, maxIterations = _a.maxIterations, structureId = _a.structureId, matchUpIds = _a.matchUpIds, scaleName = _a.scaleName, // custom rating name to seed dynamic ratings
|
|
50977
|
+
var tournamentParticipants = _a.tournamentParticipants, restrictEntryStatus = _a.restrictEntryStatus, _h = _a.adHocRatings, adHocRatings = _h === void 0 ? {} : _h, tournamentRecord = _a.tournamentRecord, generateMatchUps = _a.generateMatchUps, addToStructure = _a.addToStructure, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, scaleAccessor = _a.scaleAccessor, maxIterations = _a.maxIterations, structureId = _a.structureId, matchUpIds = _a.matchUpIds, scaleName = _a.scaleName, // custom rating name to seed dynamic ratings
|
|
50895
50978
|
eventType = _a.eventType, event = _a.event;
|
|
50896
50979
|
if (typeof drawDefinition !== 'object' ||
|
|
50897
50980
|
(drawDefinition.drawType && drawDefinition.drawType !== AD_HOC)) {
|
|
@@ -50941,11 +51024,15 @@ function drawMatic$1(_a) {
|
|
|
50941
51024
|
return { error: INVALID_DRAW_DEFINITION };
|
|
50942
51025
|
tournamentParticipants =
|
|
50943
51026
|
(_g = tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord.participants) !== null && _g !== void 0 ? _g : [];
|
|
50944
|
-
var adHocRatings = {};
|
|
50945
51027
|
var _loop_1 = function (participantId) {
|
|
50946
51028
|
var participant = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
|
|
50947
51029
|
// first see if there is already a dynamic value
|
|
50948
|
-
var scaleValue = getScaleValue({
|
|
51030
|
+
var scaleValue = getScaleValue({
|
|
51031
|
+
scaleName: "".concat(scaleName, ".").concat(DYNAMIC),
|
|
51032
|
+
scaleAccessor: scaleAccessor,
|
|
51033
|
+
participant: participant,
|
|
51034
|
+
eventType: eventType,
|
|
51035
|
+
});
|
|
50949
51036
|
// if no dynamic value found and a seeding scaleValue is provided...
|
|
50950
51037
|
if (!scaleValue && scaleName) {
|
|
50951
51038
|
scaleValue = getScaleValue({
|
|
@@ -50955,24 +51042,24 @@ function drawMatic$1(_a) {
|
|
|
50955
51042
|
eventType: eventType,
|
|
50956
51043
|
});
|
|
50957
51044
|
}
|
|
50958
|
-
if (scaleValue)
|
|
51045
|
+
if (scaleValue && !adHocRatings[participantId])
|
|
50959
51046
|
adHocRatings[participantId] = scaleValue;
|
|
50960
51047
|
};
|
|
50961
51048
|
try {
|
|
50962
|
-
for (var
|
|
50963
|
-
var participantId =
|
|
51049
|
+
for (var _j = __values(participantIds !== null && participantIds !== void 0 ? participantIds : []), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
51050
|
+
var participantId = _k.value;
|
|
50964
51051
|
_loop_1(participantId);
|
|
50965
51052
|
}
|
|
50966
51053
|
}
|
|
50967
51054
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
50968
51055
|
finally {
|
|
50969
51056
|
try {
|
|
50970
|
-
if (
|
|
51057
|
+
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
50971
51058
|
}
|
|
50972
51059
|
finally { if (e_1) throw e_1.error; }
|
|
50973
51060
|
}
|
|
50974
51061
|
// TODO: update dynamic ratings based on matchUps present from last played round
|
|
50975
|
-
// use scaleEngine.
|
|
51062
|
+
// use scaleEngine.generateDynamicRatings(); see dynamicCalculations.test.ts
|
|
50976
51063
|
return generateDrawMaticRound({
|
|
50977
51064
|
tournamentParticipants: tournamentParticipants,
|
|
50978
51065
|
tournamentRecord: tournamentRecord,
|
|
@@ -50989,10 +51076,10 @@ function drawMatic$1(_a) {
|
|
|
50989
51076
|
}
|
|
50990
51077
|
function getScaleValue(_a) {
|
|
50991
51078
|
var _b;
|
|
50992
|
-
var _c = _a.
|
|
51079
|
+
var _c = _a.scaleType, scaleType = _c === void 0 ? RATING$2 : _c, scaleAccessor = _a.scaleAccessor, participant = _a.participant, scaleName = _a.scaleName, eventType = _a.eventType;
|
|
50993
51080
|
var scaleAttributes = {
|
|
50994
51081
|
eventType: eventType || TypeEnum.Singles,
|
|
50995
|
-
scaleType:
|
|
51082
|
+
scaleType: scaleType,
|
|
50996
51083
|
scaleName: scaleName,
|
|
50997
51084
|
};
|
|
50998
51085
|
var result = participant &&
|
|
@@ -64649,18 +64736,18 @@ function calculateNewRatings(params) {
|
|
|
64649
64736
|
var updatedWinnerRating = invertedScale
|
|
64650
64737
|
? ratingRange[0] - convertedUpdatedWinnerRating
|
|
64651
64738
|
: convertedUpdatedWinnerRating;
|
|
64652
|
-
var newWinnerRating = parseFloat(updatedWinnerRating).toFixed(decimalPlaces);
|
|
64739
|
+
var newWinnerRating = parseFloat(parseFloat(updatedWinnerRating).toFixed(decimalPlaces));
|
|
64653
64740
|
var updatedLoserRating = invertedScale
|
|
64654
64741
|
? ratingRange[0] - convertedUpdatedLoserRating
|
|
64655
64742
|
: convertedUpdatedLoserRating;
|
|
64656
|
-
var newLoserRating = parseFloat(updatedLoserRating).toFixed(decimalPlaces);
|
|
64743
|
+
var newLoserRating = parseFloat(parseFloat(updatedLoserRating).toFixed(decimalPlaces));
|
|
64657
64744
|
// if expected winner && percentageDifference > threshold don't change ratings
|
|
64658
64745
|
var percentageDifference = Math.max.apply(Math, __spreadArray([], __read(ratingRange), false)) ? Math.abs(winnerRating - loserRating) / Math.max.apply(Math, __spreadArray([], __read(ratingRange), false))
|
|
64659
64746
|
: 0;
|
|
64660
64747
|
if ((convertedUpdatedWinnerRating > convertedUpdatedLoserRating &&
|
|
64661
64748
|
percentageDifference > eloConfig.diffThreshold) ||
|
|
64662
|
-
|
|
64663
|
-
|
|
64749
|
+
newWinnerRating < 0 ||
|
|
64750
|
+
newLoserRating < 0) {
|
|
64664
64751
|
newWinnerRating = winnerRating;
|
|
64665
64752
|
newLoserRating = loserRating;
|
|
64666
64753
|
}
|
|
@@ -64675,10 +64762,10 @@ var aggregateSets = function (sets) {
|
|
|
64675
64762
|
}, [0, 0])) || [0, 0]);
|
|
64676
64763
|
};
|
|
64677
64764
|
|
|
64678
|
-
function
|
|
64765
|
+
function generateDynamicRatings(_a) {
|
|
64679
64766
|
var e_1, _b;
|
|
64680
64767
|
var _c, _d;
|
|
64681
|
-
var tournamentRecord = _a.tournamentRecord,
|
|
64768
|
+
var _e = _a.removePriorValues, removePriorValues = _e === void 0 ? true : _e, tournamentRecord = _a.tournamentRecord, _f = _a.ratingType, ratingType = _f === void 0 ? ELO : _f, considerGames = _a.considerGames, matchUpIds = _a.matchUpIds, asDynamic = _a.asDynamic;
|
|
64682
64769
|
if (!tournamentRecord)
|
|
64683
64770
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
64684
64771
|
if (!Array.isArray(matchUpIds))
|
|
@@ -64696,7 +64783,7 @@ function processMatchUps(_a) {
|
|
|
64696
64783
|
inContext: true,
|
|
64697
64784
|
}).matchUps || [];
|
|
64698
64785
|
var _loop_1 = function (matchUp) {
|
|
64699
|
-
var e_2,
|
|
64786
|
+
var e_2, _j, e_3, _k, _l, _m;
|
|
64700
64787
|
var endDate = matchUp.endDate, matchUpFormat = matchUp.matchUpFormat, score = matchUp.score, sides = matchUp.sides, winningSide = matchUp.winningSide;
|
|
64701
64788
|
var matchUpType = matchUp.matchUpType;
|
|
64702
64789
|
var scaleAttributes = {
|
|
@@ -64704,7 +64791,7 @@ function processMatchUps(_a) {
|
|
|
64704
64791
|
scaleName: ratingType,
|
|
64705
64792
|
scaleType: RATING$2,
|
|
64706
64793
|
};
|
|
64707
|
-
var dynamicScaleName = "".concat(ratingType, ".
|
|
64794
|
+
var dynamicScaleName = "".concat(ratingType, ".").concat(DYNAMIC);
|
|
64708
64795
|
var dynamicScaleAttributes = {
|
|
64709
64796
|
scaleName: dynamicScaleName,
|
|
64710
64797
|
eventType: matchUpType,
|
|
@@ -64740,9 +64827,9 @@ function processMatchUps(_a) {
|
|
|
64740
64827
|
return (participantId && (_b = {},
|
|
64741
64828
|
_b[participantId] = (_c = dynamicScaleItem !== null && dynamicScaleItem !== void 0 ? dynamicScaleItem : scaleItem) !== null && _c !== void 0 ? _c : {
|
|
64742
64829
|
scaleName: outputScaleName,
|
|
64743
|
-
scaleType: RATING$2,
|
|
64744
64830
|
eventType: matchUpType,
|
|
64745
64831
|
scaleDate: endDate,
|
|
64832
|
+
scaleType: RATING$2,
|
|
64746
64833
|
scaleValue: scaleValue,
|
|
64747
64834
|
},
|
|
64748
64835
|
_b));
|
|
@@ -64777,31 +64864,33 @@ function processMatchUps(_a) {
|
|
|
64777
64864
|
var loserCountables = winningSide
|
|
64778
64865
|
? countables[3 - winningSide]
|
|
64779
64866
|
: [0, 0];
|
|
64780
|
-
var
|
|
64867
|
+
var _o = calculateNewRatings({
|
|
64781
64868
|
winnerCountables: winnerCountables,
|
|
64782
64869
|
loserCountables: loserCountables,
|
|
64783
64870
|
maxCountables: maxCountables,
|
|
64784
64871
|
winnerRating: winnerRating,
|
|
64785
64872
|
loserRating: loserRating,
|
|
64786
64873
|
ratingType: ratingType,
|
|
64787
|
-
}), newWinnerRating =
|
|
64874
|
+
}), newWinnerRating = _o.newWinnerRating, newLoserRating = _o.newLoserRating;
|
|
64788
64875
|
var newWinnerScaleValue = accessor
|
|
64789
|
-
? __assign(__assign({}, winnerScaleValue), (
|
|
64876
|
+
? __assign(__assign({}, winnerScaleValue), (_l = {}, _l[accessor] = newWinnerRating, _l)) : newWinnerRating;
|
|
64790
64877
|
var newLoserScaleValue = accessor
|
|
64791
|
-
? __assign(__assign({}, loserScaleValue), (
|
|
64878
|
+
? __assign(__assign({}, loserScaleValue), (_m = {}, _m[accessor] = newLoserRating, _m)) : newLoserRating;
|
|
64792
64879
|
scaleItemMap[winnerParticipantId].scaleValue = newWinnerScaleValue;
|
|
64793
64880
|
scaleItemMap[loserParticipantId].scaleValue = newLoserScaleValue;
|
|
64794
64881
|
var result = setParticipantScaleItem({
|
|
64795
|
-
scaleItem: __assign(__assign({}, scaleItemMap[winnerParticipantId]), { scaleName: outputScaleName }),
|
|
64796
64882
|
participantId: winnerParticipantId,
|
|
64883
|
+
removePriorValues: removePriorValues,
|
|
64797
64884
|
tournamentRecord: tournamentRecord,
|
|
64885
|
+
scaleItem: __assign(__assign({}, scaleItemMap[winnerParticipantId]), { scaleName: outputScaleName }),
|
|
64798
64886
|
});
|
|
64799
64887
|
if (result.error)
|
|
64800
64888
|
return { value: result };
|
|
64801
64889
|
result = setParticipantScaleItem({
|
|
64802
|
-
scaleItem: __assign(__assign({}, scaleItemMap[loserParticipantId]), { scaleName: outputScaleName }),
|
|
64803
64890
|
participantId: loserParticipantId,
|
|
64891
|
+
removePriorValues: removePriorValues,
|
|
64804
64892
|
tournamentRecord: tournamentRecord,
|
|
64893
|
+
scaleItem: __assign(__assign({}, scaleItemMap[loserParticipantId]), { scaleName: outputScaleName }),
|
|
64805
64894
|
});
|
|
64806
64895
|
if (result.error)
|
|
64807
64896
|
return { value: result };
|
|
@@ -64810,7 +64899,7 @@ function processMatchUps(_a) {
|
|
|
64810
64899
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
64811
64900
|
finally {
|
|
64812
64901
|
try {
|
|
64813
|
-
if (losingSideParticipantIds_1_1 && !losingSideParticipantIds_1_1.done && (
|
|
64902
|
+
if (losingSideParticipantIds_1_1 && !losingSideParticipantIds_1_1.done && (_k = losingSideParticipantIds_1.return)) _k.call(losingSideParticipantIds_1);
|
|
64814
64903
|
}
|
|
64815
64904
|
finally { if (e_3) throw e_3.error; }
|
|
64816
64905
|
}
|
|
@@ -64819,15 +64908,15 @@ function processMatchUps(_a) {
|
|
|
64819
64908
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
64820
64909
|
finally {
|
|
64821
64910
|
try {
|
|
64822
|
-
if (winningSideParticipantIds_1_1 && !winningSideParticipantIds_1_1.done && (
|
|
64911
|
+
if (winningSideParticipantIds_1_1 && !winningSideParticipantIds_1_1.done && (_j = winningSideParticipantIds_1.return)) _j.call(winningSideParticipantIds_1);
|
|
64823
64912
|
}
|
|
64824
64913
|
finally { if (e_2) throw e_2.error; }
|
|
64825
64914
|
}
|
|
64826
64915
|
Object.assign(modifiedScaleValues, scaleItemMap);
|
|
64827
64916
|
};
|
|
64828
64917
|
try {
|
|
64829
|
-
for (var
|
|
64830
|
-
var matchUp =
|
|
64918
|
+
for (var _g = __values(matchUps.sort(matchUpSort)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
64919
|
+
var matchUp = _h.value;
|
|
64831
64920
|
var state_1 = _loop_1(matchUp);
|
|
64832
64921
|
if (typeof state_1 === "object")
|
|
64833
64922
|
return state_1.value;
|
|
@@ -64836,7 +64925,7 @@ function processMatchUps(_a) {
|
|
|
64836
64925
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64837
64926
|
finally {
|
|
64838
64927
|
try {
|
|
64839
|
-
if (
|
|
64928
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
64840
64929
|
}
|
|
64841
64930
|
finally { if (e_1) throw e_1.error; }
|
|
64842
64931
|
}
|
|
@@ -64849,7 +64938,7 @@ function processMatchUps(_a) {
|
|
|
64849
64938
|
|
|
64850
64939
|
var governor = {
|
|
64851
64940
|
calculateNewRatings: calculateNewRatings,
|
|
64852
|
-
|
|
64941
|
+
generateDynamicRatings: generateDynamicRatings,
|
|
64853
64942
|
};
|
|
64854
64943
|
|
|
64855
64944
|
var scaleEngine = (function () {
|