Fixed league-based simulation randomness.

This commit is contained in:
Nick Winter 2015-08-20 05:54:10 -07:00
parent 9712c95b4a
commit 96b838da03
2 changed files with 3 additions and 1 deletions

View file

@ -74,6 +74,8 @@ updateSessionToSubmit = (transpiledCode, user, sessionToUpdate, callback) ->
league.stats.standardDeviation = 25 / 3
league.stats.numberOfWinsAndTies = 0
league.stats.numberOfLosses = 0
league.stats.meanStrength ?= 25
league.stats.totalScore ?= 10
newLeagues.push(league)
unless _.isEqual newLeagues, sessionToUpdate.leagues
sessionUpdateObject.leagues = sessionToUpdate.leagues = newLeagues

View file

@ -42,7 +42,7 @@ getRandomSessions = (user, callback) ->
leagueIDs = (leagueID + '' for leagueID in leagueIDs) # Make sure to fetch them as strings.
return sampleByLevel callback unless leagueIDs.length and Math.random() > 1 / leagueIDs.length
leagueID = _.sample leagueIDs
findRandomSession {'leagues.leagueID': leagueID, favorRecent: true}, (err, session) ->
findRandomSession {'leagues.leagueID': leagueID}, (err, session) ->
if err then return callback err
unless session then return sampleByLevel callback
otherTeam = scoringUtils.calculateOpposingTeam session.team