mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Fixed a few more issues with the headless simulator.
This commit is contained in:
parent
1aa738b256
commit
7000048bee
8 changed files with 13 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue