Skip to main content
All Games

Script Knight

Write the code, climb the tower

Write JavaScript in the editor, then press Run. Ctrl or Cmd + Enter runs too.

A coding game where the knight does exactly what your JavaScript tells it to. Read the floor, write a Player class, press Run and watch the replay as you climb the tower and fight, rescue and outwit your way to the stairs.

About Script Knight

Script Knight is a free coding game where you never touch the knight. You write a JavaScript class called Player, press Run, and the knight does exactly what your code says, one action per turn. Each floor is a small puzzle: a corridor, a few monsters, maybe a captive to rescue, and a staircase to reach. Your code runs in a sandbox in your browser, and the run is replayed on a wireframe floor.

How to play

  1. Read the floor briefing and the abilities this floor gives the knight.
  2. Write a playTurn method in the editor. It is called once per turn and may do one action, such as walk, attack, rest or rescue.
  3. Use senses, such as feel and health, to decide before you act.
  4. Press Run. The whole run is played out in the sandbox, then replayed for you.
  5. Step or scrub through the replay and read the event log.
  6. Reach the stairs to pass a floor and open the next one. Nine floors make a tower.
  7. Open Today's floor for the daily: a new corridor each UTC day, with a leaderboard.
  8. On a phone you play by hand: tap an action, then a direction.

Controls

Editor
Type your Player class. Tab inserts two spaces; press Escape, then Tab, to move focus out of the editor.
Hand pad
Tap an action, then an arrow. W A S D steer, Z undoes.
Ctrl or Cmd + Enter
Runs your code from inside the editor.
Space
Plays or pauses the replay when you are not typing in a field.
Transport buttons
Restart, step, play and skip to the end, with a speed choice.
Sound button
Mutes or unmutes the sounds; remembered on this device.

Tips and strategy

  • Sense before you act. Looking ahead costs nothing.
  • Rest when you are hurt and nothing is in reach; health is what keeps a run alive.
  • Write for the general case. Epic mode runs the same code through all nine floors in a row, so code that only works for one map will fail.
  • Use think to print values into the event log when your code misbehaves.

Quick facts

Language
JavaScript
Floors
Nine in The Narrow Path, then nine more in Powder Keep
Turn limit
200 turns per run
Where your code runs
In a Web Worker in your browser, never on a server
Saved on this device
Your code, your progress and your best grades

FAQ

Do I need to know JavaScript to play Script Knight?

A little helps. The first floors need one method and a call or two, and each floor lists its abilities, so you can learn by trying things and reading the replay.

Is my code sent anywhere, and what if it loops forever?

No. Your code runs in a sandboxed Web Worker in your own browser and is saved only on your device. The sandbox stops a turn that takes over a quarter of a second, or a run over five seconds, and tells you which turn was cut off.

Can I use TypeScript?

Not yet. Script Knight takes JavaScript only, so error line numbers match your code.

What is epic mode?

After you clear floor 9 of a tower, epic mode runs the same code through all nine floors in a row with every ability, and grades each floor and the average.

How are scores and the leaderboard checked?

A pass earns points from the knight, a time bonus and a clear bonus, graded F to S. For the daily board the server replays your moves and works out the score itself; your code never leaves your browser.

Credits

Other games you can play