dandelany / mrdario

:space_invader: Mr. Dario, a Dr. Mario clone in ES6 http://mrdar.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scoring system

dandelany opened this issue · comments

Keep track of score while playing a level. Scoring system should take into account level & speed, have time bonus for completing the level fast, and should award multiplier points for multiple lines/cascades at once.

Basic scoring is now in place, but likely needs tweaking... Points are achieved each time line(s) are completed, the formula is:

this.score +=
            (Math.pow(destroyedCount, this.cascadeLineCount) * 5) +
            (virusCount * this.cascadeLineCount * 3 * 5);

...where destroyedCount is the number of destroyed cells in the line(s), virusCount is the number of viruses destroyed, and cascadeLineCount is the total cumulative number of lines destroyed in this cascade (ie. if a line cascades and causes two more, this will be 1 at first, then 2, 3). This system heavily incentivizes lines which cascade into more lines, due to the exponent (math.pow) - maybe too heavily? It's possible to achieve some insane scores if you are able to set up insane cascades... but maybe that's a good thing. Might be better to put the exponent on virusCount instead, to favor line cascades which destroy lots of viruses?

Additionally, if you finish the level fast enough, a time bonus is awarded. This is calculated in terms of "ticks" ie. game frames, which should happen 60 times per second. Each level has an "expected time" that it should take, which is 400 * virusCount, meaning you get about 6.6 seconds per virus. This time is only calculated during actual gameplay when you are in control - the time it takes things to destroy/drop/cascade doesn't count - seems more fair this way. If you finish in under the expected # of ticks, the remaining ticks are the time bonus points. This likely needs to be tweaked for valuation and difficulty - should be hard, but not too hard, to get a good time bonus.

Updated scoring algorithm to add even more points for lines with viruses:

this.score +=
            (Math.pow(destroyedCount, this.cascadeLineCount) * 5) +
            (Math.pow(virusCount, this.cascadeLineCount) * 3 * 5);

Also, gave lower levels a bit more expected time, since it's harder to take out multiple viruses at once when they're few and spread far apart:

const expectedTicksPerVirus = 320 + (Math.max(0, 40 - this.origVirusCount) * 3);