Robocode Tank Royale Bot API
    Preparing search index...

    Class BotAbstract

    Abstract bot class that provides convenient methods for movement, turning, and firing. Most bots should extend this class rather than BaseBot.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Methods

    addCustomEvent back bearingTo broadcastTeamMessage broadcastTeamMessageBatch calcBearing calcBulletSpeed calcDeltaAngle calcGunBearing calcGunHeat calcMaxTurnRate calcRadarBearing clearEvents directionTo distanceTo fire forward getArenaHeight getArenaWidth getBodyColor getBotName getBulletColor getBulletStates getDirection getDistanceRemaining getEnemyCount getEnergy getEventPriority getEvents getFirepower getGameType getGraphics getGunColor getGunCoolingRate getGunDirection getGunHeat getGunTurnRate getGunTurnRemaining getMaxGunTurnRate getMaxInactivityTurns getMaxRadarTurnRate getMaxSpeed getMaxTurnRate getMyId getNumberOfRounds getRadarColor getRadarDirection getRadarTurnRate getRadarTurnRemaining getRoundNumber getScanColor getSpeed getTargetSpeed getTeammateIds getTimeLeft getTracksColor getTurnNumber getTurnRate getTurnRemaining getTurnTimeout getTurretColor getVariant getVersion getX getY go gunBearingTo isAdjustGunForBodyTurn isAdjustRadarForBodyTurn isAdjustRadarForGunTurn isDebuggingEnabled isDisabled isRunning isStopped isTeammate normalizeAbsoluteAngle normalizeRelativeAngle onBotDeath onBulletFired onBulletHitBot onBulletHitBullet onBulletHitWall onConnected onConnectionError onCustomEvent onDeath onDisconnected onGameEnded onGameStarted onHitBot onHitByBullet onHitWall onRoundEnded onRoundStarted onScannedBot onSkippedTurn onTeamMessage onTick onWonRound radarBearingTo removeCustomEvent rescan resume run sendTeamMessage sendTeamMessageBatch setAdjustGunForBodyTurn setAdjustRadarForBodyTurn setAdjustRadarForGunTurn setBack setBodyColor setBulletColor setEventPriority setFire setFireAssist setForward setGunColor setGunTurnRate setInterruptible setMaxGunTurnRate setMaxRadarTurnRate setMaxSpeed setMaxTurnRate setRadarColor setRadarTurnRate setRescan setResume setScanColor setStop setTargetSpeed setTracksColor setTurnGunLeft setTurnGunRight setTurnLeft setTurnRadarLeft setTurnRadarRight setTurnRate setTurnRight setTurretColor start stop turnGunLeft turnGunRight turnLeft turnRadarLeft turnRadarRight turnRight waitFor

    Constructors

    Properties

    MAX_LOGICAL_TEAM_MESSAGES_PER_TURN: 128 = Constants.MAX_LOGICAL_TEAM_MESSAGES_PER_TURN

    Maximum logical payloads per turn, counting batch entries.

    MAX_NUMBER_OF_TEAM_MESSAGES_PER_TURN: 64 = Constants.MAX_NUMBER_OF_TEAM_MESSAGES_PER_TURN

    The maximum number of team-message packets per turn, with each batch counting as one packet.

    TEAM_MESSAGE_MAX_SIZE: number = Constants.TEAM_MESSAGE_MAX_SIZE

    The maximum size of an encoded team message in UTF-8 bytes (48 KiB).

    TEAM_MESSAGES_MAX_BYTES_PER_TURN: number = Constants.TEAM_MESSAGES_MAX_BYTES_PER_TURN

    Maximum UTF-8 bytes of the compact encoded teamMessages array per turn (256 KiB).

    Methods

    • Moves the bot backward by the given distance (blocking). Blocks until the movement is completed.

      Parameters

      • distance: number

        the distance to move backward in units.

      Returns void

    • Calculates the bearing from the bot's direction to the given coordinates.

      Parameters

      • x: number

        the X coordinate.

      • y: number

        the Y coordinate.

      Returns number

      the bearing in degrees in the range [-180, 180].

    • Broadcasts a compact JSON message to all teammates for delivery on the next turn. A turn accepts at most 64 packets and 128 logical payloads, counting batch entries. Each packet is at most 48 KiB UTF-8 and the compact array is at most 256 KiB. A batch arrives as one ordered event on the next turn. All recipients must support batch version 1. Throws without enqueueing the packet when any limit is exceeded.

      Parameters

      • message: unknown

      Returns void

      When the per-turn message count has been reached.

      When the message or complete batch exceeds its UTF-8 byte limit.

    • Calculates the bearing (angle) from the bot's direction to the given direction.

      Parameters

      • direction: number

        the direction to calculate the bearing to.

      Returns number

      the bearing in degrees in the range [-180, 180].

    • Calculates the delta angle between a target angle and a source angle.

      Parameters

      • targetAngle: number

        the target angle.

      • sourceAngle: number

        the source angle.

      Returns number

      the delta angle in degrees in the range [-180, 180].

    • Calculates the bearing from the gun's direction to the given direction.

      Parameters

      • direction: number

        the direction to calculate the bearing to.

      Returns number

      the bearing in degrees in the range [-180, 180].

    • Calculates the bearing from the radar's direction to the given direction.

      Parameters

      • direction: number

        the direction to calculate the bearing to.

      Returns number

      the bearing in degrees in the range [-180, 180].

    • Calculates the direction from the bot to the given coordinates.

      Parameters

      • x: number

        the X coordinate.

      • y: number

        the Y coordinate.

      Returns number

      the direction in degrees in the range [0, 360).

    • Calculates the distance from the bot to the given coordinates.

      Parameters

      • x: number

        the X coordinate.

      • y: number

        the Y coordinate.

      Returns number

      the distance in units.

    • Fires the gun with the given firepower (blocking). Blocks until the next turn after firing.

      Parameters

      • firepower: number

        the firepower to fire with.

      Returns void

    • Moves the bot forward by the given distance (blocking). Blocks until the movement is completed.

      Parameters

      • distance: number

        the distance to move forward in units.

      Returns void

    • Returns the server-provided name for this bot or a teammate, including version and any battle-wide duplicate suffix. Opponent and unknown IDs return null. Available after game start.

      Parameters

      • botId: number

      Returns string | null

    • Commits the current commands (actions), finalizing the current turn for the bot. Must be called once per turn before the turn timeout occurs.

      Returns void

    • Calculates the bearing from the gun's direction to the given coordinates.

      Parameters

      • x: number

        the X coordinate.

      • y: number

        the Y coordinate.

      Returns number

      the bearing in degrees in the range [-180, 180].

    • Returns whether the bot is currently running.

      Returns boolean

    • Calculates the bearing from the radar's direction to the given coordinates.

      Parameters

      • x: number

        the X coordinate.

      • y: number

        the Y coordinate.

      Returns number

      the bearing in degrees in the range [-180, 180].

    • Rescans with the radar (blocking). Blocks until the next turn.

      Returns void

    • Resumes movement after a stop (blocking). Blocks until the next turn.

      Returns void

    • The main method for the bot. Override this to implement the bot's behavior. This method is called when the bot starts running in a new round.

      Returns void

    • Sends a compact JSON message to a teammate for delivery on the next turn. A turn accepts at most 64 packets and 128 logical payloads, counting batch entries. Each packet is at most 48 KiB UTF-8 and the compact array is at most 256 KiB. A batch arrives as one ordered event on the next turn. All recipients must support batch version 1. Throws without enqueueing the packet when any limit is exceeded.

      Parameters

      • teammateId: number
      • message: unknown

      Returns void

      When the per-turn message count has been reached.

      When the recipient is invalid or the message or complete batch exceeds its UTF-8 byte limit.

    • Sets the bot to move backward by the given distance (non-blocking).

      Parameters

      • distance: number

        the distance to move backward in units.

      Returns void

    • Sets the gun to fire with the given firepower. Returns true if the gun will fire, false if not. The gun will not fire if the gun is still hot, or the firepower is out of range.

      Parameters

      • firepower: number

      Returns boolean

    • Sets the bot to move forward by the given distance (non-blocking).

      Parameters

      • distance: number

        the distance to move forward in units.

      Returns void

    • Sets the gun to turn left by the given degrees (non-blocking).

      Parameters

      • degrees: number

        the degrees to turn the gun left.

      Returns void

    • Sets the gun to turn right by the given degrees (non-blocking).

      Parameters

      • degrees: number

        the degrees to turn the gun right.

      Returns void

    • Sets the bot to turn left by the given degrees (non-blocking).

      Parameters

      • degrees: number

        the degrees to turn left.

      Returns void

    • Sets the radar to turn left by the given degrees (non-blocking).

      Parameters

      • degrees: number

        the degrees to turn the radar left.

      Returns void

    • Sets the radar to turn right by the given degrees (non-blocking).

      Parameters

      • degrees: number

        the degrees to turn the radar right.

      Returns void

    • Sets the bot to turn right by the given degrees (non-blocking).

      Parameters

      • degrees: number

        the degrees to turn right.

      Returns void

    • Stops all movement (blocking). Blocks until the next turn.

      Returns void

    • Stops all movement (blocking), optionally overwriting a previous stop. Blocks until the next turn.

      Parameters

      • overwrite: boolean

        whether to overwrite a previous stop.

      Returns void

    • Turns the gun left by the given degrees (blocking). Blocks until the turn is completed.

      Parameters

      • degrees: number

        the degrees to turn the gun left.

      Returns void

    • Turns the gun right by the given degrees (blocking). Blocks until the turn is completed.

      Parameters

      • degrees: number

        the degrees to turn the gun right.

      Returns void

    • Turns the bot left by the given degrees (blocking). Blocks until the turn is completed.

      Parameters

      • degrees: number

        the degrees to turn left.

      Returns void

    • Turns the radar left by the given degrees (blocking). Blocks until the turn is completed.

      Parameters

      • degrees: number

        the degrees to turn the radar left.

      Returns void

    • Turns the radar right by the given degrees (blocking). Blocks until the turn is completed.

      Parameters

      • degrees: number

        the degrees to turn the radar right.

      Returns void

    • Turns the bot right by the given degrees (blocking). Blocks until the turn is completed.

      Parameters

      • degrees: number

        the degrees to turn right.

      Returns void

    • Waits until the given condition is true, calling go() each turn.

      Parameters

      • condition: Condition

        the condition to wait for.

      Returns void