From 1c22d478401a3a65187b013a5401ff57a17ca0cd Mon Sep 17 00:00:00 2001 From: Thayol Date: Thu, 8 Jul 2021 21:30:30 +0200 Subject: [PATCH] Factored out greedy check --- script.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index 67995dd..8d311a5 100644 --- a/script.js +++ b/script.js @@ -474,13 +474,12 @@ 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 (result.points > 0) { - if (greedyAlgorithm) { - choice.points = result.points; - } - else { - choice.points = cashOut(hands[choice.index], result, false); - } + choice.points = result.points; choice.pattern = result.pattern; choice.cards = result.cards;