Skip to content

Commit

Permalink
recalculated score to be more pointy (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
marlanperumal authored Sep 28, 2024
1 parent d82d7f9 commit 2e0ee9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@ function calculateSplit(start, end) {

// Calculate the score
const targetAbove = 80;
const targetBelow = 20;
const diffAbove = Math.abs(percentageAbove - targetAbove);
const diffBelow = Math.abs(percentageBelow - targetBelow);
const baseScore = 100 - diffAbove
// Scale the score such that an undersplit is penalized as much as an oversplit
const score = 100 - (diffAbove + diffBelow) / 2;
const score = ((baseScore/100)**16)*1000;

document.getElementById('result').innerText = `Dots Above: ${percentageAbove.toFixed(2)}%, Dots Below: ${percentageBelow.toFixed(2)}%, Score: ${score.toFixed(2)}`;
document.getElementById('result').innerText = `Dots Above: ${percentageAbove.toFixed(2)}%, Dots Below: ${percentageBelow.toFixed(2)}%, Score: ${score.toFixed(0)}`;
}

// Initialize the game
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3>Instructions</h3>
<li>Practice your skills for now. The real game starts soon...</li>
</ul>
<canvas id="gameCanvas" width="809" height="500"></canvas>
<div id="result">Dots Above: 00.00%, Dots Below: 00.00%, Score: 00.00</div>
<div id="result">Dots Above: 00.00%, Dots Below: 00.00%, Score: 0</div>

<script src="app.js"></script>

Expand Down

0 comments on commit 2e0ee9b

Please sign in to comment.