2016-03-04 16:04:52 -05:00
utils = require ' core/utils '
2014-09-03 19:14:33 -04:00
Aether . addGlobal ' Vector ' , require ' ./world/vector '
2014-08-30 16:43:56 -04:00
Aether . addGlobal ' _ ' , _
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
aetherOptions =
functionName: options . functionName
protectAPI: not options . skipProtectAPI
2014-10-10 21:23:51 -04:00
includeFlow: Boolean options . includeFlow
2015-03-16 20:36:38 -04:00
noVariablesInFlow: true
skipDuplicateUserInfoInFlow: true # Optimization that won't work if we are stepping with frames
2014-08-30 16:43:56 -04:00
yieldConditionally: options . functionName is ' plan '
2014-09-18 12:47:29 -04:00
simpleLoops: true
2015-10-20 09:42:43 -04:00
whileTrueAutoYield: true
2014-08-30 16:43:56 -04:00
globals: [ ' Vector ' , ' _ ' ]
problems:
jshint_W040: { level: ' ignore ' }
jshint_W030: { level: ' ignore ' } # aether_NoEffect instead
jshint_W038: { level: ' ignore ' } # eliminates hoisting problems
jshint_W091: { level: ' ignore ' } # eliminates more hoisting problems
jshint_E043: { level: ' ignore ' } # https://github.com/codecombat/codecombat/issues/813 -- since we can't actually tell JSHint to really ignore things
jshint_Unknown: { level: ' ignore ' } # E043 also triggers Unknown, so ignore that, too
aether_MissingThis: { level: ' error ' }
2014-10-14 17:02:31 -04:00
problemContext: options . problemContext
2014-08-30 16:43:56 -04:00
#functionParameters: # TODOOOOO
2015-04-04 12:34:31 -04:00
executionLimit: 3 * 1000 * 1000
2014-08-30 16:43:56 -04:00
language: options . codeLanguage
2016-03-04 16:04:52 -05:00
useInterpreter: ! ! utils . getQueryVariable ( ' esper ' )
2014-08-30 16:43:56 -04:00
parameters = functionParameters [ options . functionName ]
unless parameters
console . warn " Unknown method #{ options . functionName } : please add function parameters to lib/aether_utils.coffee. "
parameters = [ ]
if options . functionParameters and not _ . isEqual options . functionParameters , parameters
console . error " Update lib/aether_utils.coffee with the right function parameters for #{ options . functionName } (had: #{ parameters } but this gave #{ options . functionParameters } . "
parameters = options . functionParameters
aetherOptions.functionParameters = parameters . slice ( )
#console.log 'creating aether with options', aetherOptions
return aetherOptions
# TODO: figure out some way of saving this info dynamically so that we don't have to hard-code it: #1329
functionParameters =
hear: [ ' speaker ' , ' message ' , ' data ' ]
makeBid: [ ' tileGroupLetter ' ]
findCentroids: [ ' centroids ' ]
isFriend: [ ' name ' ]
evaluateBoard: [ ' board ' , ' player ' ]
getPossibleMoves: [ ' board ' ]
minimax_alphaBeta: [ ' board ' , ' player ' , ' depth ' , ' alpha ' , ' beta ' ]
2014-10-16 15:08:21 -04:00
distanceTo: [ ' target ' ]
2014-08-30 16:43:56 -04:00
chooseAction: [ ]
plan: [ ]
initializeCentroids: [ ]
2014-10-09 22:54:39 -04:00
update: [ ]
2014-10-16 15:08:21 -04:00
getNearestEnemy: [ ]
2014-11-26 15:33:29 -05:00
die: [ ]