mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Fixed league-based simulation randomness.
This commit is contained in:
parent
9712c95b4a
commit
96b838da03
2 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue