Radar
ClockT+00:00
Landed0/0
Departed0/0
Collisions0
Delay0:00
Fuel0 kg
Flight Schedule
FlightTypeFixScheduledStatusDelay
MyTower.js

Tower API

Your file must define class MyTower extends Tower. The simulation calls your methods; you answer by calling methods on the airplanes. One tick is one simulated second.

Methods you implement

onStart(world)Once, before the first airplane appears.
onArrival(plane, world)An arrival has entered the airspace.
onDepartureReady(plane, world)A departure is ready at the gate.
onTick(world)Every simulated second.
onConflict(a, b, world)Two airplanes have just collided. For debugging.

Commands

plane.clearToLand()Arrival may continue past FINAL and land.
plane.clearForTakeoff()Departure enters the runway and goes.
plane.hold()Circle at the present position. One circle takes 60 seconds.
plane.resume()Stop circling, drop any detour, and carry on along the route.
plane.flyTo(x, y)Detour to a point, then rejoin the route by itself. Also takes a point, for example plane.flyTo(world.fixes.BASEN). Calling it again replaces the detour. Works in the air, before the FINAL fix is passed.
plane.setSpeed(knots)160 to 250. The default is 220. Faster burns more fuel.

Reading an airplane

plane.idCallsign, for example "JVA101".
plane.kind"arrival" or "departure".
plane.stateArrivals: inbound, holding, final, landing. Departures: gate, takeoff, outbound, holding.
plane.x, plane.yPosition in nautical miles. (0, 0) is the top left; the map is 48 by 32.
plane.headingCompass degrees. 0 is north (up), 90 is east.
plane.speedKnots.
plane.etaArrivals: seconds until touchdown at the present speed, with no holding.
plane.distanceToRunwayArrivals: miles left to fly along the route.
plane.distanceTo(other)Miles to another airplane, or to anything with x and y.
plane.entry, plane.exitName of the fix the airplane came from or is going to.
plane.targetThe next point it is flying to, with x and y.
plane.vectorThe detour point set by flyTo, or null. eta and distanceToRunway include the detour.
plane.clearedTrue once it has been cleared to land or take off.
plane.waitedSeconds spent at the gate or circling so far.

The airplane objects stay the same from tick to tick, so you can keep them in arrays and attach your own properties to them.

Reading the world

world.timeSeconds since the start.
world.planesEvery airplane now in the system.
world.arrivalsJust the arrivals.
world.departuresJust the departures.
world.waitingDepartures at the gate that are not yet cleared, oldest first.
world.runway.isClearTrue when nobody is on the runway.
world.runway.occupiedByThe airplane on the runway, or null.
world.runway.threshold, .endWhere landings touch down and where takeoffs lift off.
world.fixesNamed points, for example world.fixes.POLAR.
world.finalFixThe FINAL fix, 7 miles west of the runway.
world.separation3. Closer than this in the air is a collision.
world.find(id)Look up an airplane by callsign.

Rules

  • A takeoff occupies the runway for 40 seconds, a landing for 45.
  • Two airplanes on the runway at once is a collision.
  • Two airplanes in the air less than 3 miles apart is a collision.

Debugging

console.log(a, b, ...)Prints to the Console. Objects, airplanes and arrays appear with a small arrow: click it to open them. What you see is a copy taken at that moment.
console.table(list)Prints a list as a table, one row per item.
console.table(list, ["id", "eta"])The same, with only the columns you name.

In the editor, suggestions appear as you type after a dot. Press Ctrl+Space to ask for them anywhere. Cmd+/ (or Ctrl+/) comments the selected lines out, or back in. A syntax error is marked on its line.

Scoring (lower is better)

  • 1 point per second of delay, measured against the time each flight would take with the sky to itself
  • 1 point per 2 kg of extra fuel
  • 1000 points per collision
  • 2000 points per flight that never finishes
Console
Applet started.
Best: none