This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Prepare for more scoring data. #286
Open
clemens-tolboom
wants to merge
7
commits into
develop
Choose a base branch
from
feature/prepare-score-for-more
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19
−8
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
13b33a3
Fix merged conflict
clemens-tolboom 9cdecaf
Reorder code #286
clemens-tolboom 7d38f69
Use reduce with initial value #286
clemens-tolboom 1144627
Add duration for #286
clemens-tolboom 90f35b0
Fix code review issues #286
clemens-tolboom 9f7c562
Add another startTime #286
clemens-tolboom e3a98a6
Fix code review issues #286
clemens-tolboom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1223,19 +1223,23 @@ var userInterface = window.userInterface = (function() { | |
// Update stats overlay. | ||
updateStats: function() { | ||
var oContent = []; | ||
var median; | ||
|
||
if (bot.scores.length === 0) return; | ||
median = Math.round((bot.scores[Math.floor((bot.scores.length - 1) / 2)] + | ||
bot.scores[Math.ceil((bot.scores.length - 1) / 2)]) / 2); | ||
|
||
var avg = Math.round(bot.scores.reduce(function (a, b) { return a + b.score; }, 0) / | ||
(bot.scores.length)); | ||
|
||
var median = Math.round((bot.scores[Math.floor((bot.scores.length - 1) / 2)].score + | ||
bot.scores[Math.ceil((bot.scores.length - 1) / 2)].score) / 2); | ||
|
||
|
||
oContent.push('games played: ' + bot.scores.length); | ||
oContent.push('a: ' + Math.round( | ||
bot.scores.reduce(function(a, b) { return a + b; }) / (bot.scores.length)) + | ||
oContent.push('a: ' + avg + | ||
' m: ' + median); | ||
|
||
for (var i = 0; i < bot.scores.length && i < 10; i++) { | ||
oContent.push(i + 1 + '. ' + bot.scores[i]); | ||
oContent.push(i + 1 + '. ' + bot.scores[i].score + | ||
' in ' + Math.round(bot.scores[i].duration / 1000) + 's'); | ||
} | ||
|
||
userInterface.overlays.statsOverlay.innerHTML = oContent.join('<br/>'); | ||
|
@@ -1325,14 +1329,20 @@ var userInterface = window.userInterface = (function() { | |
} else if (bot.isBotEnabled && bot.isBotRunning) { | ||
bot.isBotRunning = false; | ||
if (window.lastscore && window.lastscore.childNodes[1]) { | ||
bot.scores.push(parseInt(window.lastscore.childNodes[1].innerHTML)); | ||
var score = parseInt(window.lastscore.childNodes[1].innerHTML); | ||
var duration = Date.now() - bot.startTime; | ||
bot.scores.push({ | ||
score: score, | ||
duration: duration | ||
}); | ||
bot.scores.sort(function(a, b) { | ||
return b - a; | ||
return b.score - a.score; | ||
}); | ||
userInterface.updateStats(); | ||
} | ||
|
||
if (window.autoRespawn) { | ||
bot.startTime = Date.now(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change suggests bad state management. We should have some bot states to check our code against
|
||
window.connect(); | ||
} | ||
} | ||
|
@@ -1456,5 +1466,6 @@ var userInterface = window.userInterface = (function() { | |
setInterval(userInterface.framesPerSecond.fpsTimer, 80); | ||
|
||
// Start! | ||
bot.startTime = Date.now(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate code so guess bad state management |
||
userInterface.oefTimer(); | ||
})(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected space before function parentheses.