根据尝试次数、花费的时间和剩余的卡片计算“记忆游戏”的分数

Calculate "Memory Game's" score, based on the number of attempts, time spent and cards left

本文关键字:记忆游戏 计算 时间      更新时间:2023-09-26

我正在用javascript开发内存游戏(基于本教程:http://www.developphp.com/view.php?tid=1393),现在我需要根据以下条件计算一个公平的分数:- 游戏由 4x4 张牌组成(这意味着有 16 张牌),因此,它至少需要 8 次尝试(每翻转 2 张牌算作一次尝试)- 游戏有45秒的倒数计时器

因此,简而言之,最佳最终分数将具有:- 8次尝试,~10秒时间,剩余0张牌。每进一步尝试,经过的时间或/和剩余的牌,分数将降低

我怎样才能完成这样的事情?

下面是我到目前为止编写的代码:

nrTries =8;
time = 35;
tilesLeft = 0;
function calcScore(){
  var triesBonus = (nrTries * 700) / 8;
  var timeBonus = ((45 - time) == 0) ? 10 : (45 - time);
  //timeBonus = (timeBonus*500) / 10;
  console.log((triesBonus+'|'+timeBonus));
    //score += score - ((tilesLeft / 2)*6);
    //return score;
}
//console.log(calcScore());
calcScore();

提前感谢!

假设一个完美的游戏在 10 秒内进行了 8 次尝试,并且没有剩余的瓷砖,并且满分的价值为 1000 分。然后你可以这样做:

function calcScore(){
    var tilesbonus = (16 - tilesleft) * 20; // 20 points for each successful tile=320 pts
    var timebonus = (45 - time) * 8;  // 8 points for each second = 280 pts
    var triesbonus = (48 - nrTries) * 10;  // (deduct) 10 points for each try = 400 pts
    if (tilesbonus <0) { tilesbonus = 0; }
    if (timebonus <0) { timebonus = 0; }
    if (triesbonus <0) { triesbonus = 0; }
    return tilesbonus + timebonus + triesbonus;
}

这些数字只是一个建议,您可以弄乱它们以更改特定因素的分数。