Archived
Compare commits
10
Commits
437de4882b
...
7b47977598
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b47977598
|
||
|
|
1c22d47840
|
||
|
|
fa6e0806f1
|
||
|
|
8934c35cc2
|
||
|
|
1265205ded
|
||
|
|
6f323c46e2
|
||
|
|
7181753689
|
||
|
|
aa0a23e702
|
||
|
|
1ef838ff88
|
||
|
|
80ad22cbb6
|
@@ -12,8 +12,9 @@ var sameNumberFixed = false; // if this is true, "sameNumberExtra" will be const
|
||||
var seriesExtra = 0; // extra points given for series
|
||||
var seriesFixed = false; // if this is true, "seriesExtra" will be constant instead of additive
|
||||
|
||||
var sameColorExtra = 4; // extra points given for sets of the same color if they are in a series
|
||||
var sameColorFixed = false; // if this is true, "sameColorExtra" will be constant instead of additive
|
||||
// set the "sameColor" to non-fixed and the extra to 4 to reflect the official wiki (for some reason the live game does not work like that)
|
||||
var sameColorExtra = 10; // extra points given for sets of the same color if they are in a series
|
||||
var sameColorFixed = true; // if this is true, "sameColorExtra" will be constant instead of additive
|
||||
|
||||
var autoDraw = false; // whether the script should automatically draw on start and on discard
|
||||
var autoRecommend = true; // whether the script should automatically recommend on change
|
||||
@@ -22,14 +23,10 @@ var allowRedraw = true; // if redrawing a card by hand is allowed (sometimes the
|
||||
|
||||
var defaultDepth = 2; // the default depth of search (0 means single-level, 1 means one extra level, 2 means two extra levels)
|
||||
|
||||
var minimumRecommendations = 3; // the minimum amount of recommended next steps the script should strive for
|
||||
var minimumPoints = 4; // the minimum points the script should consider cashing out
|
||||
var minimumRecommendations = -1; // the minimum amount of recommended next steps the script should strive for
|
||||
var minimumPoints = 2; // the minimum points the script should consider cashing out
|
||||
var preferCashOut = true; // whether the default option should be cashing out even if there is a chance of getting a better opportunity
|
||||
|
||||
|
||||
// fixups (feel free to delete if not needed)
|
||||
sameColorFixed = true; // for some reason the live game does not work like the wiki says
|
||||
sameColorExtra = 10; // it gives 100 for 1-2-3* too
|
||||
var greedyAlgorithm = false; // whether the greedy algorithm should be used (never cash out, always discard for better)
|
||||
|
||||
/* END OF CONFIG */
|
||||
|
||||
@@ -45,8 +42,10 @@ var deckElement = document.getElementById('deck');
|
||||
var handElement = document.getElementById('hand');
|
||||
var recommendElement = document.getElementById('result');
|
||||
var pointsElement = document.getElementById('points');
|
||||
var autoDrawElement = document.getElementById('autoDrawToggle');
|
||||
|
||||
reset();
|
||||
toggleAutoDraw(autoDrawElement);
|
||||
|
||||
function toggleAutoDraw(element) {
|
||||
if (element.checked) {
|
||||
@@ -245,7 +244,6 @@ function drawCard(cardId, thisHand = null, thisDeck = null) {
|
||||
}
|
||||
|
||||
function recommend() {
|
||||
var cardCount = Object.keys(allCards).length
|
||||
recommendOfDepth(defaultDepth);
|
||||
updateUI(true);
|
||||
}
|
||||
@@ -373,7 +371,7 @@ function getPatterns(thisHand = null, thisMinimumPoints = null) {
|
||||
let points = Object.values(patterns).map(pattern => pattern.points);
|
||||
let maxPoints = Math.max(...points);
|
||||
|
||||
if (maxPoints < minimumPoints) {
|
||||
if (maxPoints < thisMinimumPoints) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -401,7 +399,6 @@ function recommendOfDepth(depth = 0) {
|
||||
let current = getHandPoints();
|
||||
if (current.points > 0) {
|
||||
let choice = {
|
||||
points: current,
|
||||
chance: 1,
|
||||
points: current.points,
|
||||
pattern: current.pattern,
|
||||
@@ -477,38 +474,32 @@ function recommendThrowaway(depth = 0, thisHand = null, thisDeck = null, chance
|
||||
|
||||
for (let choice of choices) {
|
||||
let result = getHandPoints(hands[choice.index]);
|
||||
if (!greedyAlgorithm) {
|
||||
result.points = cashOut(hands[choice.index], result, false);
|
||||
if (hands[choice.index].length < handSize) {
|
||||
// create new hands and push all possible permutations
|
||||
// might need a separate loop
|
||||
}
|
||||
}
|
||||
|
||||
if (result.points > 0) {
|
||||
// choice.points = result.points;
|
||||
choice.points = cashOut(hands[choice.index], result, false);
|
||||
choice.points = result.points;
|
||||
|
||||
choice.pattern = result.pattern;
|
||||
choice.cards = result.cards;
|
||||
|
||||
let thisChance = 1;
|
||||
if (thisDeck.length > 0) {
|
||||
thisChance = chance * (1/thisDeck.length);
|
||||
thisChance = chance * (1 / thisDeck.length);
|
||||
}
|
||||
|
||||
choice.chance = thisChance
|
||||
choice.chance = thisChance;
|
||||
choice.cardSignature = choice.cards.join(" ");
|
||||
|
||||
recommendations.push(choice);
|
||||
}
|
||||
}
|
||||
|
||||
// compress recommendations
|
||||
if (choices.length > 0) {
|
||||
// recommendations = [...new Set(recommendations)];
|
||||
|
||||
// only allow one recommendation per pattern
|
||||
let newRecs = [];
|
||||
for (let rec of recommendations) {
|
||||
if (!newRecs.map(newRec => newRec.pattern).includes(rec.pattern)) {
|
||||
newRecs.push(rec);
|
||||
}
|
||||
}
|
||||
|
||||
recommendations = newRecs;
|
||||
}
|
||||
|
||||
for (let choice of choices) {
|
||||
if (!choice.points) {
|
||||
choice.points = 0;
|
||||
@@ -518,7 +509,7 @@ function recommendThrowaway(depth = 0, thisHand = null, thisDeck = null, chance
|
||||
|
||||
// recursive
|
||||
for (let choice of choices) {
|
||||
if (depth > 0 && recommendations.length < minimumRecommendations) {
|
||||
if (depth > 0 && (minimumRecommendations < 0 || recommendations.length < minimumRecommendations)) {
|
||||
recommendThrowaway(depth - 1, hands[choice.index], decks[choice.index], choice.chance, choice.burnedCard, choice.points);
|
||||
}
|
||||
}
|
||||
@@ -563,9 +554,9 @@ function updateUI(skipAuto = false) {
|
||||
if (hand.length >= handSize) {
|
||||
recommend();
|
||||
}
|
||||
else {
|
||||
recommendations = [];
|
||||
}
|
||||
// else {
|
||||
// recommendations = [];
|
||||
// }
|
||||
}
|
||||
recommendationArray = [];
|
||||
for (let recommendation of recommendations) {
|
||||
|
||||
@@ -65,7 +65,7 @@ main-container {
|
||||
main-panel {
|
||||
display: block;
|
||||
max-width: 550px;
|
||||
margin: 10px auto 0 auto;
|
||||
margin: 10px auto 0;
|
||||
padding: 20px;
|
||||
background-color: var(--surface);
|
||||
border-radius: 5px;
|
||||
@@ -73,7 +73,7 @@ main-panel {
|
||||
|
||||
panel-title {
|
||||
display: block;
|
||||
margin: 0 0 0.67em 0;
|
||||
margin: 0 0 0.67em;
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user