diff --git a/app/assets/javascripts/workers/worker_world.js b/app/assets/javascripts/workers/worker_world.js index 171cb0be8..a9d998fac 100644 --- a/app/assets/javascripts/workers/worker_world.js +++ b/app/assets/javascripts/workers/worker_world.js @@ -478,6 +478,7 @@ self.onWorldError = function onWorldError(error) { else { console.log("Non-UserCodeError:", error.toString() + "\n" + error.stack || error.stackTrace); self.postMessage({type: 'non-user-code-problem', problem: {message: error.toString()}}); + return false; } /* We don't actually have the recoverable property any more; hmm if(!error.recoverable) { diff --git a/app/lib/simulator/Simulator.coffee b/app/lib/simulator/Simulator.coffee index 8b8f9f92f..6f86fa6a3 100644 --- a/app/lib/simulator/Simulator.coffee +++ b/app/lib/simulator/Simulator.coffee @@ -5,7 +5,7 @@ GoalManager = require 'lib/world/GoalManager' God = require 'lib/God' {createAetherOptions} = require 'lib/aether_utils' -SIMULATOR_VERSION = 2 +SIMULATOR_VERSION = 3 simulatorInfo = {} if $.browser @@ -334,6 +334,7 @@ module.exports = class Simulator extends CocoClass calculationTime: 500 sessions: [] simulator: @simulator + randomSeed: @task.world.randomSeed for session in @task.getSessions() sessionResult = diff --git a/app/lib/world/world.coffee b/app/lib/world/world.coffee index 538f4976a..37d304f5d 100644 --- a/app/lib/world/world.coffee +++ b/app/lib/world/world.coffee @@ -360,7 +360,7 @@ module.exports = class World #console.log "... world serializing frames from", startFrame, "to", endFrame, "of", @totalFrames [transferableObjects, nontransferableObjects] = [0, 0] delete flag.processed for flag in @flagHistory - o = {totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}, trackedProperties: {}, flagHistory: @flagHistory, difficulty: @difficulty, scores: @getScores()} + o = {totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}, trackedProperties: {}, flagHistory: @flagHistory, difficulty: @difficulty, scores: @getScores(), randomSeed: @randomSeed} o.trackedProperties[prop] = @[prop] for prop in @trackedProperties or [] for thangID, methods of @userCodeMap @@ -467,7 +467,7 @@ module.exports = class World w.userCodeMap[thangID][methodName][aetherStateKey] = serializedAether[aetherStateKey] else w = new World o.userCodeMap, classMap - [w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory, w.flagHistory, w.difficulty, w.scores] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory, o.flagHistory, o.difficulty, o.scores] + [w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory, w.flagHistory, w.difficulty, w.scores, w.randomSeed] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory, o.flagHistory, o.difficulty, o.scores, o.randomSeed] w[prop] = val for prop, val of o.trackedProperties perf.t1 = now() diff --git a/app/schemas/models/level_session.coffee b/app/schemas/models/level_session.coffee index 41f585f43..2d4c74405 100644 --- a/app/schemas/models/level_session.coffee +++ b/app/schemas/models/level_session.coffee @@ -286,6 +286,7 @@ _.extend LevelSessionSchema.properties, type: ['string', 'null'] # 'null' in case an opponent session got corrupted, don't care much here description: 'What submittedCodeLanguage the opponent used during the match' simulator: {type: 'object', description: 'Holds info on who simulated the match, and with what tools.'} + randomSeed: {type: 'integer', description: 'Stores the random seed that was used during this match.'} c.extendBasicProperties LevelSessionSchema, 'level.session' c.extendPermissionsProperties LevelSessionSchema, 'level.session' diff --git a/app/views/ladder/MyMatchesTabView.coffee b/app/views/ladder/MyMatchesTabView.coffee index 873875d27..327335b31 100644 --- a/app/views/ladder/MyMatchesTabView.coffee +++ b/app/views/ladder/MyMatchesTabView.coffee @@ -82,7 +82,7 @@ module.exports = class MyMatchesTabView extends CocoView stale: match.date < submitDate fresh: fresh codeLanguage: match.codeLanguage - simulator: JSON.stringify(match.simulator) + simulator: JSON.stringify(match.simulator) + ' | seed ' + match.randomSeed } for team in @teams diff --git a/headless_client.coffee b/headless_client.coffee index 27fca376b..7db937737 100644 --- a/headless_client.coffee +++ b/headless_client.coffee @@ -95,6 +95,7 @@ GLOBAL.Backbone = require bowerComponentsPath + 'backbone/backbone' unhook() Backbone.$ = $ require bowerComponentsPath + 'validated-backbone-mediator/backbone-mediator' +Backbone.Mediator.setValidationEnabled false GLOBAL.Aether = require 'aether' # Set up new loader. Again. hook() diff --git a/headless_client/worker_world.coffee b/headless_client/worker_world.coffee index 981266376..f32928f28 100644 --- a/headless_client/worker_world.coffee +++ b/headless_client/worker_world.coffee @@ -148,7 +148,9 @@ work = () -> self.postedErrors[errorKey] = error else console.log 'Non-UserCodeError:', error.toString() + "\n" + error.stack or error.stackTrace + self.postMessage type: 'non-user-code-problem', problem: {message: error.toString()} self.cleanUp() + return false return true self.onWorldLoadProgress = onWorldLoadProgress = (progress) -> @@ -178,8 +180,8 @@ work = () -> codeFileContents = [] for codeFile in [ - 'world.js' 'lodash.js' + 'world.js' 'aether.js' 'app/vendor/aether-clojure.js' 'app/vendor/aether-coffeescript.js' diff --git a/server/queues/scoring.coffee b/server/queues/scoring.coffee index c2cf71be4..66a947ce8 100644 --- a/server/queues/scoring.coffee +++ b/server/queues/scoring.coffee @@ -15,7 +15,7 @@ bayes = new (require 'bayesian-battle')() scoringTaskQueue = undefined scoringTaskTimeoutInSeconds = 600 -SIMULATOR_VERSION = 2 +SIMULATOR_VERSION = 3 module.exports.setup = (app) -> connectToScoringQueue() @@ -611,6 +611,7 @@ updateMatchesInSession = (matchObject, sessionID, callback) -> currentMatchObject.opponents = opponentsArray currentMatchObject.codeLanguage = matchObject.opponents[opponentsArray[0].sessionID].codeLanguage currentMatchObject.simulator = @clientResponseObject.simulator + currentMatchObject.randomSeed = @clientResponseObject.randomSeed LevelSession.findOne {'_id': sessionID}, (err, session) -> session = session.toObject() currentMatchObject.playtime = session.playtime ? 0