ON THIS PAGE
LANGUAGE REFERENCEALISCRIPTv2.5
THE ROBOT PROGRAMMING LANGUAGE
| Command | Category | Energy | Parameters | Description | Example |
|---|---|---|---|---|---|
IF...THEN...ELSE...END | CONTROL FLOW | Free | condition | Branching logic with optional else clause. Must be closed with END. | IF health < 50 THEN BACKUP ELSE FIRE END |
FOR...TO...DO...END | CONTROL FLOW | Free | assignment, limit | Deterministic looping logic. Executes a block a fixed number of times. Crucial for writing O(N) linear array traversals that stay within TLE limits. | FOR i = 0 TO LENGTH(enemies) DO SET current = enemies[i] END |
WHILE...DO...END | CONTROL FLOW | Free | condition | Looping logic. Executes block while condition is true. Auto-capped at 10 iter/tick. WARNING: Nested WHILE loops can easily trigger TLE crashes (O(N²)). | WHILE spotted DO FIRE WAIT 1 END |
FUNCTION / CALL | CONTROL FLOW | Free | name | Define reusable blocks of logic (functions) and invoke them. | FUNCTION retreat BACKUP END CALL retreat |
MOVE | MOVEMENT | 2/tick | — | Standard forward propulsion. Blocked during STASIS. | MOVE |
MOVE_FAST | MOVEMENT | 4/tick | — | High-speed forward propulsion. 2× speed, 2× the energy of MOVE. Blocked during STASIS. | MOVE_FAST |
BACKUP | MOVEMENT | 2/tick | — | Reverse thrust. Same cost as MOVE. Blocked during STASIS. | BACKUP |
PATHFIND | MOVEMENT | 3/tick | — | Weighted A* pathfinding toward nearest visible target, avoiding obstacles. Blocked during STASIS. | PATHFIND |
STOP | MOVEMENT | Free | — | Halt all movement. Always allowed, even during STASIS. | STOP |
SCAN | SENSORS | 3/use | — | Rotates FOV cone +15°/call to sweep the environment. Populates scanned_distance, scanned_angle, scanned_spotted. BLOCKED during STASIS — use WAIT instead. | SCAN |
WAIT | SENSORS | Free | N: ticks | Suspends code execution for N ticks. 60 ticks ≈ 1 second. Costs 0 energy. Note: energy does NOT regenerate during WAIT — only during STASIS. | WAIT 30 |
FIRE | ATTACK | 8/shot | — | Single precision shot toward nearest visible enemy. Deals 25 HP on hit. Only fires if an enemy is in FOV. Blocked during STASIS. | FIRE |
BURST_FIRE | ATTACK | 18/burst | — | Rapid 3-shot burst. Each shot deals 8 HP (up to 24 HP total). Requires enemy in FOV. Blocked during STASIS. | BURST_FIRE |
TELEPORT | SUPER POWERS | 80 | x, y | Instantly warp to the specified map coordinates. Sets velocity to zero. Blocked during STASIS. | TELEPORT 400 300 |
SHIELD | SUPER POWERS | 60 | — | Activates an energy shield that blocks all incoming damage (projectiles, mines) for 30 ticks (1.5s). Blocked during STASIS. | SHIELD |
CLOAK | SUPER POWERS | 50 | — | Turns the robot completely invisible to enemy sensors, FOV, and radar for 40 ticks (2s). Blocked during STASIS. | CLOAK |
MINE | SUPER POWERS | 40 | — | Drops a proximity mine at your current location. Arms after 250ms. Deals 35 damage. Blocked during STASIS. | MINE |
DASH | SUPER POWERS | 30 | distance | Instant, high-speed lateral thrust in the direction the robot is facing. Ideal for dodging. Blocked during STASIS. | DASH 100 |
SET var = expr | INTELLIGENCE | Free | expression | Assign values using math operators (+, -, *, /, %). Executes even during STASIS — use to update state machines while immobilised. | SET rotation = rotation + 0.1 |
NOT / TRUE / FALSE | INTELLIGENCE | Free | booleans | Logical operators and boolean constants for advanced conditions. | IF NOT CAN_SEE_ENEMY THEN SCAN END |
AND / OR | INTELLIGENCE | Free | logic | Compound boolean operators. AND has higher precedence than OR. Both short-circuit evaluate (second operand skipped if result determined by first). | IF health < 50 AND CAN_SEE_ENEMY THEN FIRE END |
Instantly warp to the specified map coordinates. Sets velocity to zero.
TELEPORT 400 300Activates an energy shield that blocks all incoming damage (projectiles, mines) for 30 ticks (1.5s).
SHIELDTurns the robot completely invisible to enemy sensors, FOV, and radar for 40 ticks (2s).
CLOAKDrops a proximity mine at your current location. Arms after 250ms. Deals 35 AoE damage when triggered.
MINEInstant, high-speed lateral thrust in the direction the robot is facing. Ideal for dodging.
DASH 100Query functions print live robot state to the status log panel during a match. They do not return values — use built-in identifiers (e.g. MY_ENERGY, health) for conditional logic instead.
GET_HEALTH()→ number (0-100)Prints current robot health to status logs.
GET_HEALTH()GET_ENERGY()→ number (0-100)Prints current energy level to status logs.
GET_ENERGY()GET_ENERGY_PCT()→ number (0-100)Prints current energy as a percentage.
GET_ENERGY_PCT()GET_DISTANCE()→ number | "Infinity"Prints distance to the nearest visible enemy.
GET_DISTANCE()GET_POSITION()→ string ({x, y})Prints current {x, y} position in arena units.
GET_POSITION()GET_ROTATION()→ numberPrints body facing angle in radians.
GET_ROTATION()GET_FOV_DIR()→ numberPrints scanner facing angle in radians.
GET_FOV_DIR()GET_VISIBLE_COUNT()→ numberPrints number of enemies currently in FOV.
GET_VISIBLE_COUNT()GET_OBSTACLE_TYPE()→ stringPrints type of nearest visible obstacle ("SOLID", "TRAP", "LAVA", "FINISH_LINE", "NONE").
GET_OBSTACLE_TYPE()GET_OBSTACLE_DISTANCE()→ number | "Infinity"Prints distance to the nearest visible obstacle.
GET_OBSTACLE_DISTANCE()healthnumberrotationnumberanglenumberrotnumberfovDirectionnumberlockVisionflagdistancenumberspottedbooleanbullet_speednumbertarget_vxnumbertarget_vynumberMY_ENERGYnumberENERGY_PCTnumberIN_STASISbooleanCAN_SEE_ENEMYbooleanVISIBLE_ENEMY_COUNTnumberNEAREST_VISIBLE_XnumberNEAREST_VISIBLE_YnumberFOV_ANGLEnumberCAN_SEE_OBSTACLEbooleanNEAREST_OBSTACLE_TYPEstringNEAREST_OBSTACLE_DISTANCEnumberscanned_distancenumberscanned_anglenumberscanned_spottedbooleanAliScript has evolved into a fully-fledged deterministic language. Leverage these powerful data structures and APIs, but beware of the 2,000 instruction-per-tick quota. O(N) complexity is required for array traversals!
ABS(x)→ numberAbsolute value. Strips the sign from a number.
SET d = ABS(x2 - x1)SQRT(x)→ numberSquare root of x. Negative inputs are clamped to 0.
SET dist = SQRT(dx * dx + dy * dy)POW(base, exp)→ numberRaise base to the power of exp.
SET sq = POW(side, 2)SIN(x)→ numberSine of x in radians.
SET vy = SIN(rotation)COS(x)→ numberCosine of x in radians.
SET vx = COS(rotation)TAN(x)→ numberTangent of x in radians.
SET slope = TAN(angle)ATAN2(y, x)→ number (radians)Angle in radians from the origin to the point (x, y). The gold-standard function for aiming — converts a direction vector to an angle.
SET aim = ATAN2(ey - POSITION_Y, ex - POSITION_X)MIN(a, b)→ numberReturns the smaller of two values.
SET safe = MIN(distance, 200)MAX(a, b)→ numberReturns the larger of two values.
SET e = MAX(MY_ENERGY, 0)FLOOR(x)→ integerRounds x down to the nearest integer.
SET i = FLOOR(LENGTH(arr) / 2)CEIL(x)→ integerRounds x up to the nearest integer.
SET pages = CEIL(count / 10)ROUND(x)→ integerRounds x to the nearest integer.
SET hp = ROUND(health)LOG(x)→ numberNatural logarithm of x. x must be greater than 0.
SET lg = LOG(MY_ENERGY)RANDOM()→ numberRandom floating-point number in [0.0, 1.0). Useful for stochastic movement to avoid predictable patterns.
SET noise = RANDOM() * 0.4 - 0.2SET arr = [v0, v1, v2]→ arrayDeclare an array literal with initial values. Elements can be any expression. Supports advanced deterministic memory management for state tracking.
SET angles = [0, 0.785, 1.57, -0.785]arr[index]→ valueRead the value at zero-based index. Returns undefined if out of bounds. Reading from arrays is an O(1) constant time operation.
SET a = angles[0]SET arr[index] = val→ —Write a value at zero-based index. Index must be within current array bounds. O(1) time complexity.
SET scores[i] = ROUND(dist)LENGTH(arr)→ numberReturns the number of elements in the array. Works on strings too (returns character count). O(1) lookup. Essential for O(N) bounds-checking in loops.
SET n = LENGTH(enemies)PUSH(arr, value)→ numberAppends value to the end of the array. Dynamic allocation occurs automatically. Returns the new array length.
PUSH(queue, NEAREST_VISIBLE_X)POP(arr)→ valueRemoves and returns the last element of the array. Returns undefined if empty. O(1) time complexity.
SET last = POP(queue)SET obj = { key: "val" }→ objectDeclare an object literal (Dictionary/Hash Map). Supports O(1) lookups and dynamic key insertion. Perfect for powerful state machines and memory persistence.
SET state = { mode: "HUNT", target_id: 4 }obj.key→ valueDot notation to access or modify a property. Key must be an identifier. Fast O(1) property access.
SET m = state.modeobj["key"]→ valueBracket notation to access or modify a property. Key can be any expression resolving to a string. O(1) property access.
SET state["mode"] = "EVADE"SET obj.key = val→ —Mutating assignment. Update a property on an existing object. Extremely useful for state preservation across ticks.
SET state.mode = "ATTACK"GET_ALL_VISIBLE_ENEMIES()Vision ArrayReturns an Array of enemy snapshots for every alive enemy currently inside this robot's FOV cone. Each snapshot is a 4-element sub-array. Enemies are intentionally returned UNSORTED — players are expected to implement O(N) complexity linear scans or O(N log N) sorting algorithms to find their priority target without triggering TLE crashes.
SET enemies = GET_ALL_VISIBLE_ENEMIES()SET count = LENGTH(enemies)// Find the weakest target (manual min-search)SET i = 1SET weakest = enemies[0]WHILE i < count DOSET candidate = enemies[i]IF candidate[3] < weakest[3] THENSET weakest = candidateENDSET i = i + 1END// Aim and fireSET aim = ATAN2(weakest[2] - POSITION_Y, weakest[1] - POSITION_X)SET rotation = aimFIRE
RAYCAST(angle)Line of SightFires an advanced physics ray from the robot's current position in the direction (robot.rotation + angle), where angle is a relative radian offset. Returns the distance in arena units to the first solid obstacle encountered. Essential for advanced collision avoidance and Line-of-Sight verification before firing. Checks: boundary walls → SOLID obstacles → alive robots. TRAP and LAVA zones are transparent.
// Obstacle avoidance with 3-ray sonarSET front = RAYCAST(0)SET left = RAYCAST(-0.785)SET right = RAYCAST(0.785)IF front < 60 THENIF left > right THENSET rotation = rotation - 0.3ELSESET rotation = rotation + 0.3ENDELSE// Clear path — check Line-of-Sight before firingIF CAN_SEE_ENEMY THENSET losCheck = RAYCAST(ATAN2(NEAREST_VISIBLE_Y - POSITION_Y, NEAREST_VISIBLE_X - POSITION_X) - rotation)IF losCheck > distance THENFIREENDENDENDMOVE
BROADCAST(data)Swarm CommSends a deep-copy of `data` (dictionary, array, string, or number) to the inbox of every alive teammate. Safely prevents cross-sandbox memory leaks by copying the payload.
// Broadcast a target to all alliesIF CAN_SEE_ENEMY THENSET count = BROADCAST({ type: "TARGET", x: NEAREST_VISIBLE_X, y: NEAREST_VISIBLE_Y })END
RECEIVE()Swarm CommAtomically drains this robot's inbox and returns the full array of messages received since the last RECEIVE() call. The inbox is cleared immediately after reading.
// Process all incoming messagesSET msgs = RECEIVE()SET len = LENGTH(msgs)IF len > 0 THEN// Get the most recent messageSET latest = msgs[len - 1]IF latest.type == "TARGET" THEN// Move to targetSET rotation = ATAN2(latest.y - POSITION_Y, latest.x - POSITION_X)MOVEENDEND
IF / FOR / WHILEFUNCTION/CALLSETWAITSTOPMOVEBACKUPMOVE_FASTPATHFINDSCANFIREBURST_FIRESCAN-3MOVE-2NET -5 / tickActive robots do not regenerate. Run out of energy to enter STASIS and regen.
rotationalias: angle, rotfovDirectionlockVision0Right (East)1.57Down (South)3.14Left (West)-1.57Up (North)4.71Up (North) altEvery AliScript command costs energy. Write efficient code to maximize your Efficiency Score.