Electra's API

Circuit team

Circuit object
Evaluator class
State class
Element class

Levels/Judge team

Levels object
  • advanceLevel() is called to notify that the user has requested to move to the next level (with no dialog).
  • showSelector() is called to notify that the level selection dialog should be displayed.
  • getCurrentLevel() returns a Level object representing the currently selected level.
Level class
  • orderText is a string providing the text that should be shown the user describing the problem.
  • hint is a string containing a hint that the user can choose to receive.
  • sensors is a string indicating which sensors should be supplied in the circuit. Possible characters in the string include R, G, Y, C, o (ball), - (bar), and | (stick).
  • link would normally be omitted. But if the initial circuit should include a wire connecting one of the sensors to an output, then this field would contain the one-character identifier for the connected sensor.
  • tools is an array of strings such as and and not indicating what components should be available for insertion into the circuit.
  • types is a string listing possible items that could appear in a test sequence, in a form such as “G- *o R*”, which would indicate that green bars, balls of any flavor, and any red shape should be eligible.
  • script is an identifier string that the tutorial team provides and uses to map the level to a tutorial sequence.
  • analyze is a method taking no parameters and returning an array of SequenceItem objects. type: Type of item levelSays: boolean giving what level expects regarding acceptance circuitSays: object return by circuit for this item, with accept field
SequenceItem class
  • type is a string such as “R-” identifying the type of item being shown.
  • levelSays is a Boolean value indicating whether the item should be accepted according to the level's definition.
  • circuitSays is a State object (which has an accept Boolean field indicating whether the circuit accepts this item).

Factory Floor team

FactoryFloor object
  • levelChanged(oldLevelnewLevel) returns nothing
  • getLeverLocation() returns an object with x, y, width, height providing a bounding box (in page coordinates) around the element that indicates to perform a test.
  • getAdvanceLocation() returns an object with x, y, width, height providing a bounding box (in page coordinates) around the element that indicates to advance to the next level.

Tutorial team

Tutorial object
  • levelChanged(oldLevelnewLevel) indicates that the module should update itself to reflect the new level. It can save any information about its status in the oldLevel's tutorialState field.
  • circuitChanged() is called to indicate that the circuit has been altered (and so the tutorial should perhaps advance).
  • leverPushed() is called to indicate that the element for performing a test of the current circuit has been activated.