Enable Esper by default in certain cases; improve verifier a bit; misc cleanup

This commit is contained in:
Nick Winter 2016-05-05 16:56:58 -07:00
parent e4c904463c
commit 32f74531e4
8 changed files with 50 additions and 50 deletions

View file

@ -113,7 +113,6 @@ module.exports = class God extends CocoClass
for thangID, spellThang of spell.thangs
continue if spellThang.thang?.programmableMethods[spell.name].cloneOf
(userCodeMap[thangID] ?= {})[spell.name] = spellThang.aether.serialize()
console.log 'got UCM', userCodeMap
userCodeMap

View file

@ -115,7 +115,7 @@ module.exports = class LevelLoader extends CocoClass
if @sessionID
url = "/db/level.session/#{@sessionID}"
url += "?interpret=true" if @spectateMode or utils.getQueryVariable 'esper'
url += "?interpret=true" if @spectateMode
else
url = "/db/level/#{@levelID}/session"
url += "?team=#{@team}" if @team

View file

@ -7,6 +7,14 @@ module.exports.createAetherOptions = (options) ->
throw new Error 'Specify a function name to create an Aether instance' unless options.functionName
throw new Error 'Specify a code language to create an Aether instance' unless options.codeLanguage
useInterpreter = options.useInterpreter
defaultToEsper = switch options.codeLanguage
when 'python' then me.level() < 15 # Esper currently works well until using range()
when 'javascript' then me.level() < 22 # Esper currently works well until using hero.myFn = function() pattern
when 'lua' then me.level() < 10 # Functions don't work in Esper yet, can't play forest function levels
when 'coffeescript' then false # CoffeeScript has a toNative error if it ever finishes plan(), and also @fn = -> pattern doesn't work
when 'clojure' then false # No Clojure support
useInterpreter ?= !!utils.getQueryVariable 'esper', defaultToEsper
aetherOptions =
functionName: options.functionName
protectAPI: not options.skipProtectAPI
@ -29,7 +37,7 @@ module.exports.createAetherOptions = (options) ->
#functionParameters: # TODOOOOO
executionLimit: 3 * 1000 * 1000
language: options.codeLanguage
useInterpreter: options.useInterpreter ? !!utils.getQueryVariable('esper')
useInterpreter: useInterpreter
parameters = functionParameters[options.functionName]
unless parameters
console.warn "Unknown method #{options.functionName}: please add function parameters to lib/aether_utils.coffee."

View file

@ -621,6 +621,7 @@
clojure_blurb: "A modern Lisp."
lua_blurb: "Game scripting language."
io_blurb: "Simple but obscure."
java_blurb: "(Subscriber Only) Android and enterprise."
status: "Status"
hero_type: "Type"
weapons: "Weapons"

View file

@ -24,24 +24,27 @@ block content
each test, id in view.tests
- if (test.state == 'no-solution')
- continue;
if test.level
.pull-right
- var last = test.level.get('slug') + view.linksQueryString
a.btn.btn-primary(href="/editor/verifier/" + last) Focus
a.btn.btn-success(href="/play/level/" + last) Play
a.btn.btn-warning(href="/editor/level/" + last ) Edit
- var last = test.level.get('slug') + view.linksQueryString
a.btn.btn-primary(href="/editor/verifier/" + last) Focus
a.btn.btn-success(href="/play/level/" + last) Play
a.btn.btn-warning(href="/editor/level/" + last) Edit
a.btn.btn-default(data-target='#verifier-test-' + id, data-toggle="collapse") Toggle
if !test.goals
h2(style='color: orange')= test.level.get('name')
small= ' in ' + test.language + ''
else if test.isSucessful()
else if test.isSuccessful()
h2(style='color: green')= test.level.get('name')
small= ' in ' + test.language + ''
else
h2(style='color: red')= test.level.get('name')
small= ' in ' + test.language + ''
div.row(class=(test.isSucessful() && id > 1 ? 'collapse' : 'collapse in'))
div.row(class=(test.isSuccessful() && id > 1 ? 'collapse' : 'collapse in'), id='verifier-test-' + id)
div.col-xs-8
if test.solution
pre #{test.solution.source}

View file

@ -14,7 +14,7 @@ module.exports = class VerifierTest extends CocoClass
# TODO: listen to the progress report from Angel to show a simulation progress bar (maybe even out of the number of frames we actually know it'll take)
@supermodel ?= new SuperModel()
if utils.getQueryVariable('dev')
if utils.getQueryVariable('dev')
@supermodel.shouldSaveBackups = (model) -> # Make sure to load possibly changed things from localStorage.
model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem', 'ThangType']
@ -33,8 +33,8 @@ module.exports = class VerifierTest extends CocoClass
unless @solution
@error = 'No solution present...'
@state = 'error'
@updateCallback? state: 'error'
@state = 'no-solution'
@updateCallback? state: 'no-solution'
return
me.team = @team = 'humans'
@setupGod()
@ -96,7 +96,7 @@ module.exports = class VerifierTest extends CocoClass
@updateCallback? state: @state
@scheduleCleanup()
isSucessful: () ->
isSuccessful: () ->
return false unless @solution?
return false unless @frames == @solution.frameCount
if @goals and @solution.goals
@ -116,7 +116,7 @@ module.exports = class VerifierTest extends CocoClass
@scheduleCleanup()
fail: (e) ->
@error = 'Failed due to infinate loop.'
@error = 'Failed due to infinite loop.'
@state = 'error'
@updateCallback? state: @state
@scheduleCleanup()
@ -138,9 +138,7 @@ module.exports = class VerifierTest extends CocoClass
cleanup: =>
if @god
console.log "Destorying God"
@stopListening @god
@god.destroy()
console.log "Destoryed"
@world = null

View file

@ -10,7 +10,6 @@ module.exports = class VerifierView extends RootView
constructor: (options, @levelID) ->
super options
# TODO: rework to handle N at a time instead of all at once
# TODO: sort tests by unexpected result first
@passed = 0
@failed = 0
@ -31,24 +30,20 @@ module.exports = class VerifierView extends RootView
'stillness-in-motion', 'the-agrippa-defense', 'backwoods-bombardier', 'coinucopia', 'copper-meadows',
'drop-the-flag', 'mind-the-trap', 'signal-corpse', 'rich-forager',
"the-mighty-sand-yak", "oasis", "sarven-road", "sarven-gaps", "thunderhooves", "minesweeper",
"medical-attention", "sarven-sentry", "keeping-time", "hoarding-gold", "decoy-drill", "continuous-alchemy",
"dust", "desert-combat", "sarven-savior", "lurkers", "preferential-treatment", "sarven-shepherd",
"shine-getter"
#"the-dunes", "the-mighty-sand-yak", "oasis", "basin-stampede", "sarven-road", "sarven-gaps",
#"crossroads", "thunderhooves", "operation-killdeer", "medical-attention", "the-great-yak-stampede",
#"minesweeper", "sarven-sentry", "keeping-time", "hoarding-gold", "bookkeeper", "decoy-drill",
#"continuous-alchemy", "yakstraction", "sarven-brawl", "desert-combat", "dust", "dont-rush-be-quiet",
#"sarven-rescue", "sacred-statue", "mirage-maker", "sarven-savior", "odd-sandstorm", "lurkers",
#"preferential-treatment", "bash-em-all", "sarven-shepherd", "shine-getter", "sand-snakes",
#"the-trials", "mad-maxer", "mad-maxer-strikes-back", "mad-maxer-sells-out", "mad-maxer-gets-greedy",
#"mad-maxer-redemption", "sarven-treasure", "harrowland", "sarven-siege", "goalkeeper",
#"clash-of-clones", "stranded-in-the-dunes", "sarven-sum", "golden-mirage", "diamond-dozen",
#"brittle-morale", "zig-zag-and-zoom", "cubic-minefield"
'the-mighty-sand-yak', 'oasis', 'sarven-road', 'sarven-gaps', 'thunderhooves', 'minesweeper',
'medical-attention', 'sarven-sentry', 'keeping-time', 'hoarding-gold', 'decoy-drill', 'continuous-alchemy',
'dust', 'desert-combat', 'sarven-savior', 'lurkers', 'preferential-treatment', 'sarven-shepherd',
'shine-getter',
'a-fine-mint', 'borrowed-sword', 'cloudrip-commander', 'crag-tag',
'hunters-and-prey', 'hunting-party',
'leave-it-to-cleaver', 'library-tactician', 'mad-maxer', 'mad-maxer-strikes-back',
'mirage-maker', 'mixed-unit-tactics', 'mountain-mercenaries',
'noble-sacrifice', 'odd-sandstorm', 'ogre-gorge-gouger', 'reaping-fire',
'return-to-thornbush-farm', 'ring-bearer', 'sand-snakes',
'slalom', 'steelclaw-gap', 'the-geometry-of-flowers',
'the-two-flowers', 'timber-guard', 'toil-and-trouble', 'village-rover',
'vital-powers', 'zoo-keeper',
]
defaultCores = 2
@ -57,25 +52,22 @@ module.exports = class VerifierView extends RootView
#testLevels = testLevels.slice 0, 15
@linksQueryString = window.location.search
@levelIDs = if @levelID then [@levelID] else testLevels
#supermodel = if @levelID then @supermodel else undefined
@tests = []
@taskList = []
@tasksList = _.flatten _.map @levelIDs, (v) ->
console.log(v)
# TODO: offer good interface for choosing which languages, better performance for skipping missing solutions
#_.map ['python', 'javascript', 'coffeescript', 'lua'], (l) ->
_.map ['python', 'javascript'], (l) ->
#_.map ['javascript'], (l) ->
level: v, language: l
@testCount = @tasksList.length
chunks = _.groupBy @tasksList, (v,i) -> i%cores
supermodels = [@supermodel]
_.forEach chunks, (chunk, i) =>
_.forEach chunks, (chunk, i) =>
_.delay =>
parentSuperModel = supermodels[supermodels.length-1]
chunkSupermodel = new SuperModel()
@ -86,13 +78,15 @@ module.exports = class VerifierView extends RootView
async.eachSeries chunk, (task, next) =>
test = new VerifierTest task.level, (e) =>
@update(e)
if e.state in ['complete', 'error']
if e.state in ['complete', 'error', 'no-solution']
if e.state is 'complete'
if test.isSucessful()
if test.isSuccessful()
++@passed
else
++@failed
else
else if e.state is 'no-solution'
--@testCount
else
++@problem
next()
@ -103,6 +97,4 @@ module.exports = class VerifierView extends RootView
, if i > 0 then 5000 + i * 1000 else 0
update: (event) =>
# TODO: show unworkable tests instead of hiding them
# TODO: destroy them Tests after or something
@render()
@render()

View file

@ -20,7 +20,6 @@ ShareProgressModal = require 'views/play/modal/ShareProgressModal'
UserPollsRecord = require 'models/UserPollsRecord'
Poll = require 'models/Poll'
PollModal = require 'views/play/modal/PollModal'
storage = require 'core/storage'
CourseInstance = require 'models/CourseInstance'
trackedHourOfCode = false