根据尝试次数、花费的时间和剩余的牌计算 "Memory Game's" 分数
Calculate "Memory Game's" score, based on the number of attempts, time spent and cards left
我正在 javascript 中开发记忆游戏(基于本教程:http://www.developphp.com/view.php?tid=1393),现在我需要根据以下条件计算公平分数:
- 游戏由 4x4 张卡片组成(这意味着有 16 张卡片)因此,它至少需要 8 次尝试(每翻转 2 张卡片算作一次尝试)
- 游戏倒计时为 45 秒
所以,简而言之,最好的最终成绩将是:
- 8 次尝试,耗时约 10 秒,剩下 0 张牌待找。
每进一步尝试,剩余时间 or/and 张牌,得分将减少
我怎样才能完成这样的事情?
下面是我到目前为止编写的代码:
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;
}
这些数字只是一个建议,您可以修改它们以更改特定因素的得分。
我正在 javascript 中开发记忆游戏(基于本教程:http://www.developphp.com/view.php?tid=1393),现在我需要根据以下条件计算公平分数: - 游戏由 4x4 张卡片组成(这意味着有 16 张卡片)因此,它至少需要 8 次尝试(每翻转 2 张卡片算作一次尝试) - 游戏倒计时为 45 秒
所以,简而言之,最好的最终成绩将是: - 8 次尝试,耗时约 10 秒,剩下 0 张牌待找。 每进一步尝试,剩余时间 or/and 张牌,得分将减少
我怎样才能完成这样的事情?
下面是我到目前为止编写的代码:
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;
}
这些数字只是一个建议,您可以修改它们以更改特定因素的得分。