A game you play by writing JavaScript
In Drillscript you do not fly the drone. You write the program that does, press Run, and watch what your code made of the cave.
It is a single-player game that runs entirely in your browser. There is no account and nothing to install, and it costs nothing. Your scripts and scores stay on your own machine.
How a run works
A run is eight shafts. Each shaft is a cave of dirt, rock, ore and gems, generated from the seed of the run, with a dock at the top. Every action a drone takes costs energy: moving one tile costs 1, drilling rock costs 4, drilling ore costs 5. A drone starts with 400 energy, and one that runs dry is lost together with its cargo.
Only what a drone carries back to the dock counts. Each shaft has a quota of credits: 34 in the first shaft, 390 in the last. Meet it and the shaft is cleared. Run out of energy or time first and the run is over.
After a cleared shaft you pick one of three modules: more energy, a larger hold, a sonar, blast charges, a recall to the dock, a second drone. There are fourteen. A module changes what your program can do, so the script that cleared shaft 3 is rarely the one that clears shaft 6. You rewrite, and go deeper.
The whole shaft is computed at once and then played back. You can pause, step tick by tick, scrub back, and look up what your script saw and answered at any moment. Everything is deterministic: the same seed, script and module picks always replay to the same result, so a seed is a fair challenge to pass to someone else.
What you write
One function. The game calls tick(drone) once per drone per tick, and it returns one action. drone is plain data: position, energy, cargo,
where the dock is, and a scan of the tiles around it.
// Dig straight down, take any ore next to the shaft,
// go home when the hold is full or the energy runs low.
function tick(drone) {
const r = drone.scanRadius
const at = (dx, dy) => drone.scan[dy + r][dx + r]
const home = drone.cargo.count >= drone.cargo.capacity || drone.energy < drone.y + 10
if (home) return { type: 'move', dir: 'up' }
for (const dir of ['left', 'right', 'down']) {
const [dx, dy] = DIRS[dir]
if (at(dx, dy) === TILE.ORE) return { type: 'drill', dir }
}
return at(0, 1) === TILE.EMPTY ? { type: 'move', dir: 'down' } : { type: 'drill', dir: 'down' }
}
This one works, and it is not good. It banks about 11 of the 34 credits the first shaft asks for and clears it on one seed in fifty: it never looks further sideways than one tile, and it turns back too early. Making it better is the game.
The actions are move, drill and wait, plus blast and recall once you own their modules. An optional
draft(offers, state) lets your script pick the modules too. console.log goes to a console that shows the tick each line came from.
Where to start
You need to read and write a little JavaScript, and no more than that. "Training" in the game has eight short lessons, the Docs tab holds the full reference, and four example scripts show the way from a beginner's loop to a planner that reads the whole map.