Fixed a few more issues with the headless simulator.

This commit is contained in:
Nick Winter 2015-02-12 17:07:00 -08:00
parent 1aa738b256
commit 7000048bee
8 changed files with 13 additions and 6 deletions

View file

@ -478,6 +478,7 @@ self.onWorldError = function onWorldError(error) {
else { else {
console.log("Non-UserCodeError:", error.toString() + "\n" + error.stack || error.stackTrace); console.log("Non-UserCodeError:", error.toString() + "\n" + error.stack || error.stackTrace);
self.postMessage({type: 'non-user-code-problem', problem: {message: error.toString()}}); self.postMessage({type: 'non-user-code-problem', problem: {message: error.toString()}});
return false;
} }
/* We don't actually have the recoverable property any more; hmm /* We don't actually have the recoverable property any more; hmm
if(!error.recoverable) { if(!error.recoverable) {

View file

@ -5,7 +5,7 @@ GoalManager = require 'lib/world/GoalManager'
God = require 'lib/God' God = require 'lib/God'
{createAetherOptions} = require 'lib/aether_utils' {createAetherOptions} = require 'lib/aether_utils'
SIMULATOR_VERSION = 2 SIMULATOR_VERSION = 3
simulatorInfo = {} simulatorInfo = {}
if $.browser if $.browser
@ -334,6 +334,7 @@ module.exports = class Simulator extends CocoClass
calculationTime: 500 calculationTime: 500
sessions: [] sessions: []
simulator: @simulator simulator: @simulator
randomSeed: @task.world.randomSeed
for session in @task.getSessions() for session in @task.getSessions()
sessionResult = sessionResult =

View file

@ -360,7 +360,7 @@ module.exports = class World
#console.log "... world serializing frames from", startFrame, "to", endFrame, "of", @totalFrames #console.log "... world serializing frames from", startFrame, "to", endFrame, "of", @totalFrames
[transferableObjects, nontransferableObjects] = [0, 0] [transferableObjects, nontransferableObjects] = [0, 0]
delete flag.processed for flag in @flagHistory 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 [] o.trackedProperties[prop] = @[prop] for prop in @trackedProperties or []
for thangID, methods of @userCodeMap for thangID, methods of @userCodeMap
@ -467,7 +467,7 @@ module.exports = class World
w.userCodeMap[thangID][methodName][aetherStateKey] = serializedAether[aetherStateKey] w.userCodeMap[thangID][methodName][aetherStateKey] = serializedAether[aetherStateKey]
else else
w = new World o.userCodeMap, classMap 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 w[prop] = val for prop, val of o.trackedProperties
perf.t1 = now() perf.t1 = now()

View file

@ -286,6 +286,7 @@ _.extend LevelSessionSchema.properties,
type: ['string', 'null'] # 'null' in case an opponent session got corrupted, don't care much here 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' description: 'What submittedCodeLanguage the opponent used during the match'
simulator: {type: 'object', description: 'Holds info on who simulated the match, and with what tools.'} 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.extendBasicProperties LevelSessionSchema, 'level.session'
c.extendPermissionsProperties LevelSessionSchema, 'level.session' c.extendPermissionsProperties LevelSessionSchema, 'level.session'

View file

@ -82,7 +82,7 @@ module.exports = class MyMatchesTabView extends CocoView
stale: match.date < submitDate stale: match.date < submitDate
fresh: fresh fresh: fresh
codeLanguage: match.codeLanguage codeLanguage: match.codeLanguage
simulator: JSON.stringify(match.simulator) simulator: JSON.stringify(match.simulator) + ' | seed ' + match.randomSeed
} }
for team in @teams for team in @teams

View file

@ -95,6 +95,7 @@ GLOBAL.Backbone = require bowerComponentsPath + 'backbone/backbone'
unhook() unhook()
Backbone.$ = $ Backbone.$ = $
require bowerComponentsPath + 'validated-backbone-mediator/backbone-mediator' require bowerComponentsPath + 'validated-backbone-mediator/backbone-mediator'
Backbone.Mediator.setValidationEnabled false
GLOBAL.Aether = require 'aether' GLOBAL.Aether = require 'aether'
# Set up new loader. Again. # Set up new loader. Again.
hook() hook()

View file

@ -148,7 +148,9 @@ work = () ->
self.postedErrors[errorKey] = error self.postedErrors[errorKey] = error
else else
console.log 'Non-UserCodeError:', error.toString() + "\n" + error.stack or error.stackTrace 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() self.cleanUp()
return false
return true return true
self.onWorldLoadProgress = onWorldLoadProgress = (progress) -> self.onWorldLoadProgress = onWorldLoadProgress = (progress) ->
@ -178,8 +180,8 @@ work = () ->
codeFileContents = [] codeFileContents = []
for codeFile in [ for codeFile in [
'world.js'
'lodash.js' 'lodash.js'
'world.js'
'aether.js' 'aether.js'
'app/vendor/aether-clojure.js' 'app/vendor/aether-clojure.js'
'app/vendor/aether-coffeescript.js' 'app/vendor/aether-coffeescript.js'

View file

@ -15,7 +15,7 @@ bayes = new (require 'bayesian-battle')()
scoringTaskQueue = undefined scoringTaskQueue = undefined
scoringTaskTimeoutInSeconds = 600 scoringTaskTimeoutInSeconds = 600
SIMULATOR_VERSION = 2 SIMULATOR_VERSION = 3
module.exports.setup = (app) -> connectToScoringQueue() module.exports.setup = (app) -> connectToScoringQueue()
@ -611,6 +611,7 @@ updateMatchesInSession = (matchObject, sessionID, callback) ->
currentMatchObject.opponents = opponentsArray currentMatchObject.opponents = opponentsArray
currentMatchObject.codeLanguage = matchObject.opponents[opponentsArray[0].sessionID].codeLanguage currentMatchObject.codeLanguage = matchObject.opponents[opponentsArray[0].sessionID].codeLanguage
currentMatchObject.simulator = @clientResponseObject.simulator currentMatchObject.simulator = @clientResponseObject.simulator
currentMatchObject.randomSeed = @clientResponseObject.randomSeed
LevelSession.findOne {'_id': sessionID}, (err, session) -> LevelSession.findOne {'_id': sessionID}, (err, session) ->
session = session.toObject() session = session.toObject()
currentMatchObject.playtime = session.playtime ? 0 currentMatchObject.playtime = session.playtime ? 0