diff --git a/crib-count.html b/crib-count.html
index 1921317..82f4d1b 100644
--- a/crib-count.html
+++ b/crib-count.html
@@ -114,6 +114,24 @@
margin-bottom: 5px;
font-size: 1.1em;
}
+
+ #optionsContainer {
+ margin: 15px 0;
+ font-size: 1.1em;
+ }
+
+ #optionsContainer input {
+ width: 16px;
+ height: 16px;
+ vertical-align: middle;
+ margin-right: 5px;
+ cursor: pointer;
+ }
+
+ #optionsContainer label {
+ vertical-align: middle;
+ cursor: pointer;
+ }
@@ -123,6 +141,10 @@
+
+
+
+
@@ -143,6 +165,7 @@
// --- DOM Elements ---
const dealButton = document.getElementById('dealButton');
const revealButton = document.getElementById('revealButton');
+ const highScoreCheckbox = document.getElementById('highScoreCheckbox');
const handContainer = document.getElementById('hand');
const starterContainer = document.getElementById('starter');
const scoreContainer = document.getElementById('scoreContainer');
@@ -176,19 +199,52 @@
}
}
- function dealNewHand() {
- const deck = createDeck();
- shuffleDeck(deck);
-
- currentHand = deck.slice(0, 4);
- starterCard = deck[4];
+ async function dealNewHand() {
+ dealButton.disabled = true;
+ revealButton.style.display = 'none';
+ scoreContainer.style.display = 'none';
+
+ if (highScoreCheckbox.checked) {
+ await findHighScoreHand();
+ } else {
+ const deck = createDeck();
+ shuffleDeck(deck);
+ currentHand = deck.slice(0, 4);
+ starterCard = deck[4];
+ }
displayCards(currentHand, starterCard);
-
- scoreContainer.style.display = 'none';
+
+ dealButton.disabled = false;
revealButton.style.display = 'inline-block';
}
+ async function findHighScoreHand() {
+ let bestHand = [];
+ let bestStarter = null;
+ let maxScore = -1;
+ const deck = createDeck();
+ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
+
+ for (let i = 0; i < 100; i++) {
+ shuffleDeck(deck);
+ const hand = deck.slice(0, 4);
+ const starter = deck[4];
+
+ displayCards(hand, starter);
+ await sleep(10);
+
+ const { score } = calculateScore(hand, starter);
+ if (score > maxScore) {
+ maxScore = score;
+ bestHand = hand;
+ bestStarter = starter;
+ }
+ }
+ currentHand = bestHand;
+ starterCard = bestStarter;
+ }
+
// --- UI Functions ---
function createCardElement(card) {
const cardEl = document.createElement('div');