ON THIS PAGE

LANGUAGE REFERENCEALISCRIPTv2.5

THE ROBOT PROGRAMMING LANGUAGE

COMMANDS:59
IDENTIFIERS:25
CORE:v2.5
// QUICK REFERENCE
CONTROL FLOW
IF...ELSE
WHILE...DO
FOR...TO
FUNCTION
CALL
END
SENSORS / FOV
SCAN (blocked in STASIS)
WAIT
CAN_SEE_ENEMY
NEAREST_VISIBLE_X/Y
CAN_SEE_OBSTACLE
MOVEMENT & VISION
rotation / angle / rot
fovDirection (Eye)
lockVision (Link)
SET rotation = 1.57
PATHFIND
ENERGY
MY_ENERGY (0–100)
ENERGY_PCT
IN_STASIS
Regen: +3/tick in STASIS only
INTELLIGENCE
SET var = val
Math (+,-,*,/,%)
NOT / AND / OR
TRUE / FALSE
ROTATION SYSTEM
rotation = body
fovDirection = eyes
lockVision = link
SET lockVision = TRUE
Auto-disables on SET
STATUS QUERIES
GET_HEALTH()
GET_ENERGY()
GET_POSITION()
GET_DISTANCE()
MATH STDLIB
ABS(x)
SQRT(x)
ATAN2(y, x)
SIN / COS
POW / MIN / MAX
FLOOR / CEIL / ROUND
ARRAYS
SET arr = [1, 2, 3]
arr[index]
LENGTH(arr)
PUSH(arr, val)
POP(arr)
DICTIONARIES / STATE
SET obj = { k: "v" }
obj.key
obj["key"]
SET obj.key = val
ADVANCED SENSORS
GET_ALL_VISIBLE_ENEMIES()
Returns [dist, x, y, hp][]
RAYCAST(angle)
Returns dist to first hit
SWARM INTELLIGENCE
BROADCAST(data)
Returns recipient count
RECEIVE()
Returns Array of messages
SYSTEM LIMITS
2000 Operations / Tick
Exceeding Quota = TLE Crash
WHILE loops cap at 10 iters
SUPER POWERS
TELEPORT / DASH
SHIELD / CLOAK
MINE (Proximity Trap)
Requires massive energy
// COMMAND REFERENCE
CommandCategoryEnergyParametersDescriptionExample
IF...THEN...ELSE...ENDCONTROL FLOWFreeconditionBranching logic with optional else clause. Must be closed with END.IF health < 50 THEN BACKUP ELSE FIRE END
FOR...TO...DO...ENDCONTROL FLOWFreeassignment, limitDeterministic 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...ENDCONTROL FLOWFreeconditionLooping 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 / CALLCONTROL FLOWFreenameDefine reusable blocks of logic (functions) and invoke them.FUNCTION retreat BACKUP END CALL retreat
MOVEMOVEMENT2/tickStandard forward propulsion. Blocked during STASIS.MOVE
MOVE_FASTMOVEMENT4/tickHigh-speed forward propulsion. 2× speed, 2× the energy of MOVE. Blocked during STASIS.MOVE_FAST
BACKUPMOVEMENT2/tickReverse thrust. Same cost as MOVE. Blocked during STASIS.BACKUP
PATHFINDMOVEMENT3/tickWeighted A* pathfinding toward nearest visible target, avoiding obstacles. Blocked during STASIS.PATHFIND
STOPMOVEMENTFreeHalt all movement. Always allowed, even during STASIS.STOP
SCANSENSORS3/useRotates FOV cone +15°/call to sweep the environment. Populates scanned_distance, scanned_angle, scanned_spotted. BLOCKED during STASIS — use WAIT instead.SCAN
WAITSENSORSFreeN: ticksSuspends code execution for N ticks. 60 ticks ≈ 1 second. Costs 0 energy. Note: energy does NOT regenerate during WAIT — only during STASIS.WAIT 30
FIREATTACK8/shotSingle precision shot toward nearest visible enemy. Deals 25 HP on hit. Only fires if an enemy is in FOV. Blocked during STASIS.FIRE
BURST_FIREATTACK18/burstRapid 3-shot burst. Each shot deals 8 HP (up to 24 HP total). Requires enemy in FOV. Blocked during STASIS.BURST_FIRE
TELEPORTSUPER POWERS80x, yInstantly warp to the specified map coordinates. Sets velocity to zero. Blocked during STASIS.TELEPORT 400 300
SHIELDSUPER POWERS60Activates an energy shield that blocks all incoming damage (projectiles, mines) for 30 ticks (1.5s). Blocked during STASIS.SHIELD
CLOAKSUPER POWERS50Turns the robot completely invisible to enemy sensors, FOV, and radar for 40 ticks (2s). Blocked during STASIS.CLOAK
MINESUPER POWERS40Drops a proximity mine at your current location. Arms after 250ms. Deals 35 damage. Blocked during STASIS.MINE
DASHSUPER POWERS30distanceInstant, high-speed lateral thrust in the direction the robot is facing. Ideal for dodging. Blocked during STASIS.DASH 100
SET var = exprINTELLIGENCEFreeexpressionAssign values using math operators (+, -, *, /, %). Executes even during STASIS — use to update state machines while immobilised.SET rotation = rotation + 0.1
NOT / TRUE / FALSEINTELLIGENCEFreebooleansLogical operators and boolean constants for advanced conditions.IF NOT CAN_SEE_ENEMY THEN SCAN END
AND / ORINTELLIGENCEFreelogicCompound 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
21 / 21 COMMANDS DISPLAYED
// SUPER POWERS (TACTICAL ABILITIES)
TELEPORT
80

Instantly warp to the specified map coordinates. Sets velocity to zero.

Usage
TELEPORT 400 300
SHIELD
60

Activates an energy shield that blocks all incoming damage (projectiles, mines) for 30 ticks (1.5s).

Usage
SHIELD
CLOAK
50

Turns the robot completely invisible to enemy sensors, FOV, and radar for 40 ticks (2s).

Usage
CLOAK
MINE
40

Drops a proximity mine at your current location. Arms after 250ms. Deals 35 AoE damage when triggered.

Usage
MINE
DASH
30

Instant, high-speed lateral thrust in the direction the robot is facing. Ideal for dodging.

Usage
DASH 100
// QUERY FUNCTIONS

Query 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.

e.g.GET_HEALTH()
GET_ENERGY()number (0-100)

Prints current energy level to status logs.

e.g.GET_ENERGY()
GET_ENERGY_PCT()number (0-100)

Prints current energy as a percentage.

e.g.GET_ENERGY_PCT()
GET_DISTANCE()number | "Infinity"

Prints distance to the nearest visible enemy.

e.g.GET_DISTANCE()
GET_POSITION()string ({x, y})

Prints current {x, y} position in arena units.

e.g.GET_POSITION()
GET_ROTATION()number

Prints body facing angle in radians.

e.g.GET_ROTATION()
GET_FOV_DIR()number

Prints scanner facing angle in radians.

e.g.GET_FOV_DIR()
GET_VISIBLE_COUNT()number

Prints number of enemies currently in FOV.

e.g.GET_VISIBLE_COUNT()
GET_OBSTACLE_TYPE()string

Prints type of nearest visible obstacle ("SOLID", "TRAP", "LAVA", "FINISH_LINE", "NONE").

e.g.GET_OBSTACLE_TYPE()
GET_OBSTACLE_DISTANCE()number | "Infinity"

Prints distance to the nearest visible obstacle.

e.g.GET_OBSTACLE_DISTANCE()
// BUILT-IN IDENTIFIERS v2.5
Self
healthnumber
Current HP (0–100).
Movement
rotationnumber
Body facing angle in radians. Writable via SET. Acts as the Steering Wheel — also updates velocity direction. Does NOT affect fovDirection.
anglenumber
Alias for rotation. Accepted by all SET commands.
rotnumber
Short alias for rotation. Accepted by all SET commands.
Vision
fovDirectionnumber
Scanner eye angle in radians. Independent from body rotation. SET fovDirection = X to aim the scanner separately. Does NOT affect body rotation.
lockVisionflag
SET lockVision = TRUE to sync fovDirection to rotation every tick. Auto-disables when SET rotation or SET fovDirection is used.
Combat
distancenumber
Distance to nearest VISIBLE enemy. Returns Infinity if none in FOV.
spottedboolean
True if any enemy is within FOV cone. Legacy alias for CAN_SEE_ENEMY — prefer CAN_SEE_ENEMY in new scripts.
bullet_speednumber
Projectile velocity constant (400 arena units/sec). Useful for predictive aiming calculations.
target_vxnumber
X-axis velocity of the nearest visible enemy. Returns 0 if no enemy in FOV. Use with bullet_speed for predictive lead shots.
target_vynumber
Y-axis velocity of the nearest visible enemy. Returns 0 if no enemy in FOV. Use with bullet_speed for predictive lead shots.
Energy
MY_ENERGYnumber
Current energy level (0–100).
ENERGY_PCTnumber
Energy as percentage (0–100). Useful for threshold checks.
IN_STASISboolean
True when energy ≤ 0. Robot exits STASIS at energy ≥ 20. MOVE, BACKUP, MOVE_FAST, PATHFIND, FIRE, BURST_FIRE, and SCAN are all blocked during STASIS. SET and WAIT still execute.
FOV
CAN_SEE_ENEMYboolean
True if one or more enemies are within the current FOV cone.
VISIBLE_ENEMY_COUNTnumber
Number of enemies currently within the FOV cone.
NEAREST_VISIBLE_Xnumber
X coordinate of the nearest visible enemy. Returns own X if none visible.
NEAREST_VISIBLE_Ynumber
Y coordinate of the nearest visible enemy. Returns own Y if none visible.
FOV_ANGLEnumber
Current FOV cone angle in degrees (default 120°).
CAN_SEE_OBSTACLEboolean
True if one or more obstacles (walls, lava, traps) are within the current FOV cone.
NEAREST_OBSTACLE_TYPEstring
Returns "SOLID" (wall), "TRAP" (slow), "LAVA" (damage), "FINISH_LINE", or "NONE" depending on the nearest visible obstacle.
NEAREST_OBSTACLE_DISTANCEnumber
Distance to the nearest visible obstacle. Returns Infinity if none in FOV.
Scan
scanned_distancenumber
Distance to nearest visible enemy as of last SCAN call. Only updates when SCAN executes (SCAN is blocked during STASIS).
scanned_anglenumber
Angle toward nearest visible enemy as of last SCAN call. Only updates when SCAN executes.
scanned_spottedboolean
True if any enemy was visible during the last SCAN call. Remains at its last known value while in STASIS (SCAN cannot update it).
// ADVANCED LANGUAGE FEATURES

AliScript 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!

Math Standard Library
ABS(x)number

Absolute value. Strips the sign from a number.

e.g.SET d = ABS(x2 - x1)
SQRT(x)number

Square root of x. Negative inputs are clamped to 0.

e.g.SET dist = SQRT(dx * dx + dy * dy)
POW(base, exp)number

Raise base to the power of exp.

e.g.SET sq = POW(side, 2)
SIN(x)number

Sine of x in radians.

e.g.SET vy = SIN(rotation)
COS(x)number

Cosine of x in radians.

e.g.SET vx = COS(rotation)
TAN(x)number

Tangent of x in radians.

e.g.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.

e.g.SET aim = ATAN2(ey - POSITION_Y, ex - POSITION_X)
MIN(a, b)number

Returns the smaller of two values.

e.g.SET safe = MIN(distance, 200)
MAX(a, b)number

Returns the larger of two values.

e.g.SET e = MAX(MY_ENERGY, 0)
FLOOR(x)integer

Rounds x down to the nearest integer.

e.g.SET i = FLOOR(LENGTH(arr) / 2)
CEIL(x)integer

Rounds x up to the nearest integer.

e.g.SET pages = CEIL(count / 10)
ROUND(x)integer

Rounds x to the nearest integer.

e.g.SET hp = ROUND(health)
LOG(x)number

Natural logarithm of x. x must be greater than 0.

e.g.SET lg = LOG(MY_ENERGY)
RANDOM()number

Random floating-point number in [0.0, 1.0). Useful for stochastic movement to avoid predictable patterns.

e.g.SET noise = RANDOM() * 0.4 - 0.2
Array Operations (O(1) / O(N))
SET arr = [v0, v1, v2]array

Declare an array literal with initial values. Elements can be any expression. Supports advanced deterministic memory management for state tracking.

e.g.SET angles = [0, 0.785, 1.57, -0.785]
arr[index]value

Read the value at zero-based index. Returns undefined if out of bounds. Reading from arrays is an O(1) constant time operation.

e.g.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.

e.g.SET scores[i] = ROUND(dist)
LENGTH(arr)number

Returns 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.

e.g.SET n = LENGTH(enemies)
PUSH(arr, value)number

Appends value to the end of the array. Dynamic allocation occurs automatically. Returns the new array length.

e.g.PUSH(queue, NEAREST_VISIBLE_X)
POP(arr)value

Removes and returns the last element of the array. Returns undefined if empty. O(1) time complexity.

e.g.SET last = POP(queue)
Dictionary Hash Maps (O(1))
SET obj = { key: "val" }object

Declare an object literal (Dictionary/Hash Map). Supports O(1) lookups and dynamic key insertion. Perfect for powerful state machines and memory persistence.

e.g.SET state = { mode: "HUNT", target_id: 4 }
obj.keyvalue

Dot notation to access or modify a property. Key must be an identifier. Fast O(1) property access.

e.g.SET m = state.mode
obj["key"]value

Bracket notation to access or modify a property. Key can be any expression resolving to a string. O(1) property access.

e.g.SET state["mode"] = "EVADE"
SET obj.key = val

Mutating assignment. Update a property on an existing object. Extremely useful for state preservation across ticks.

e.g.SET state.mode = "ATTACK"
Advanced Sensor Arrays
GET_ALL_VISIBLE_ENEMIES()Vision Array

Returns 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.

Returns
Array of [distance, x, y, health]
enemies[i][0] = distance • enemies[i][1] = position X • enemies[i][2] = position Y • enemies[i][3] = health (0–100)
Implementation Example
SET enemies = GET_ALL_VISIBLE_ENEMIES()
SET count = LENGTH(enemies)
// Find the weakest target (manual min-search)
SET i = 1
SET weakest = enemies[0]
WHILE i < count DO
SET candidate = enemies[i]
IF candidate[3] < weakest[3] THEN
SET weakest = candidate
END
SET i = i + 1
END
// Aim and fire
SET aim = ATAN2(weakest[2] - POSITION_Y, weakest[1] - POSITION_X)
SET rotation = aim
FIRE
Note:Returns an empty array [] when no enemies are in FOV. Always check LENGTH() before indexing.
RAYCAST(angle)Line of Sight

Fires 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.

Returns
number (distance in arena units)
Range: 1 to FOV range (default 300). Returns the FOV range value when nothing is hit within sensor range.
Implementation Example
// Obstacle avoidance with 3-ray sonar
SET front = RAYCAST(0)
SET left = RAYCAST(-0.785)
SET right = RAYCAST(0.785)
IF front < 60 THEN
IF left > right THEN
SET rotation = rotation - 0.3
ELSE
SET rotation = rotation + 0.3
END
ELSE
// Clear path — check Line-of-Sight before firing
IF CAN_SEE_ENEMY THEN
SET losCheck = RAYCAST(ATAN2(NEAREST_VISIBLE_Y - POSITION_Y, NEAREST_VISIBLE_X - POSITION_X) - rotation)
IF losCheck > distance THEN
FIRE
END
END
END
MOVE
Note:angle is relative to robot.rotation. RAYCAST(0) fires straight ahead. RAYCAST(-1.57) fires 90° left. Use ATAN2 to compute an absolute angle then subtract rotation to get the relative offset.
Swarm Intelligence
BROADCAST(data)Swarm Comm

Sends 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.

Returns
number
Returns the count of teammates that successfully received the message.
Implementation Example
// Broadcast a target to all allies
IF CAN_SEE_ENEMY THEN
SET count = BROADCAST({ type: "TARGET", x: NEAREST_VISIBLE_X, y: NEAREST_VISIBLE_Y })
END
Note:Returns 0 if no data is provided or no alive teammates exist.
RECEIVE()Swarm Comm

Atomically 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.

Returns
Array of payloads
Each element in the array is a message payload sent via BROADCAST().
Implementation Example
// Process all incoming messages
SET msgs = RECEIVE()
SET len = LENGTH(msgs)
IF len > 0 THEN
// Get the most recent message
SET latest = msgs[len - 1]
IF latest.type == "TARGET" THEN
// Move to target
SET rotation = ATAN2(latest.y - POSITION_Y, latest.x - POSITION_X)
MOVE
END
END
Note:Calling RECEIVE() when the inbox is empty returns []. Messages are delivered exactly once.
// ENERGY SYSTEM v2.5
Passive Regen+3 energy / tick
STASIS only · max 100
COGNITIVE — FREE
IF / FOR / WHILE
FREE
Control-flow never costs energy
FUNCTION/CALL
FREE
SET
FREE
Executes even during STASIS — ideal for state machine flags
WAIT
FREE
Costs 0 energy. Energy does NOT regenerate during WAIT — regen only occurs in STASIS.
STOP
FREE
Allowed during STASIS
MOVEMENT
MOVE
2/tick
BACKUP
2/tick
MOVE_FAST
4/tick
2× speed for 2× the cost. Blocked during STASIS.
PATHFIND
3/tick
A* navigation toward nearest visible target. Blocked during STASIS.
SENSORS
SCAN
3/call
BLOCKED during STASIS — use WAIT to pause the script and let STASIS regen energy.
COMBAT
FIRE
8/shot
25 HP damage on hit. Only fires if an enemy is within FOV.
BURST_FIRE
18/burst
3 shots × 8 HP = up to 24 HP total. Requires enemy in FOV.
Drain Simulatortick #0
ENERGY100 / 100
Per tick:SCAN-3MOVE-2NET -5 / tick

Active robots do not regenerate. Run out of energy to enter STASIS and regen.

// ROTATION SYSTEM v2.3
// THE_3_CONTROLS
rotationalias: angle, rot
Robot body & tracks
[MOVE YES][VISION NO]
Controls which direction the robot drives. Physics auto-updates it when moving. Does NOT touch fovDirection ever.
fovDirection
Scanner cone (eyes)
[MOVE NO][VISION YES]
Controls where the FOV cone points. Completely independent from body. CAN_SEE_ENEMY checks this cone only.
lockVision
Links body + scanner
[MOVE NO][VISION NO]
When TRUE, fovDirection auto-follows rotation every tick. Auto-disables when SET rotation or SET fovDirection is used manually.
// COMMON_ANGLES
0Right (East)
1.57Down (South)
3.14Left (West)
-1.57Up (North)
4.71Up (North) alt
// CONFLICT_RESOLUTION
lockVision ON + SET rotation = X
lockVision disables. Body turns to X. Scanner stays at last position.
lockVision ON + SET fovDirection = X
lockVision disables. Scanner turns to X. Body stays unchanged.
lockVision ON + MOVE
Body rotates from physics. Scanner follows (lockVision still ON).
lockVision ON + SCAN
Scanner rotates +15°. Next tick lockVision re-syncs scanner to body.
lockVision OFF + MOVE
Body rotates from physics. Scanner frozen at last position.
lockVision OFF + SET rotation = X
Body turns to X. Scanner completely unaffected.
lockVision OFF + SET fovDirection = X
Scanner turns to X. Body completely unaffected.
// EXAMPLE_SCRIPTS

Simplest setup: scanner follows body, fires anything in front.

Result:Robot drives forward, shoots anything its body faces.
AliScript
SET lockVision = TRUE
WHILE TRUE DO
  MOVE
  IF CAN_SEE_ENEMY THEN
    FIRE
  END
END
// ALGORITHM CHALLENGES
Efficiency Rule

Every AliScript command costs energy. Write efficient code to maximize your Efficiency Score.

Continuously rotate the FOV with SCAN until an enemy enters vision, then engage. Classic search algorithm applied to robot combat.

AliScript
// ── Spiral Search Pattern ──────────────────────
// Uses SCAN to rotate the FOV cone until CAN_SEE_ENEMY
// becomes true, then switches to combat mode.
WHILE TRUE DO
IF CAN_SEE_ENEMY THEN
// Target acquired — eliminate
PATHFIND
IF distance < 200 THEN
FIRE
END
ELSE
// Sweep the environment
SCAN
SET rotation = rotation + 0.08
MOVE
WAIT 1
END
END
// PRESET SCRIPTS
THE STALKER
Sensor-loop logic for hyper-accurate target acquisition.
AliScript
// Adaptive Scan Loop SCAN WHILE NOT scanned_spotted DO SET rotation = rotation + 0.1 WAIT 2 SCAN END PATHFIND
THE TURRET
Energy-efficient static defense with manual rotation.
AliScript
FUNCTION defend SCAN IF scanned_distance < 150 THEN BURST_FIRE WAIT 10 ELSE SET rotation = rotation + 0.05 END END STOP WHILE TRUE DO CALL defend END
THE JITTERBUG
Chaotic movement offsets to bypass enemy trajectory prediction.
AliScript
SET offset = 1 WHILE TRUE DO MOVE_FAST SET rotation = rotation + (offset * 0.5) SET offset = offset * -1 IF CAN_SEE_ENEMY THEN FIRE END WAIT 3 END
THE PHANTOM MINER
Covert sabotage operation using Cloak, Mine, and Dash abilities.
AliScript
// Infiltrate and Trap CLOAK WHILE CAN_SEE_ENEMY == FALSE DO SCAN MOVE END PATHFIND IF distance < 50 THEN MINE SET rotation = rotation + 3.14 DASH 100 END
// LIVE EDITOR
SCRIPT EDITOR27 LINES
COMMAND LIST
Waiting for script…
PROFILE
FRIENDS
GARAGE
ALISCRIPT
BLACK MARKET
SETTINGS