Robocode Tank Royale Bot API
    Preparing search index...

    Class BaseBotAbstract

    Abstract base class for bots implementing the IBaseBot interface. Provides all state accessors, rate setters, color management, and math utilities. Subclasses should override the event handler methods to implement bot behavior.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Methods

    addCustomEvent bearingTo broadcastTeamMessage calcBearing calcBulletSpeed calcDeltaAngle calcGunBearing calcGunHeat calcMaxTurnRate calcRadarBearing clearEvents directionTo distanceTo getArenaHeight getArenaWidth getBodyColor getBulletColor getBulletStates getDirection getEnemyCount getEnergy getEventPriority getEvents getFirepower getGameType getGraphics getGunColor getGunCoolingRate getGunDirection getGunHeat getGunTurnRate getMaxGunTurnRate getMaxInactivityTurns getMaxRadarTurnRate getMaxSpeed getMaxTurnRate getMyId getNumberOfRounds getRadarColor getRadarDirection getRadarTurnRate getRoundNumber getScanColor getSpeed getTargetSpeed getTeammateIds getTimeLeft getTracksColor getTurnNumber getTurnRate getTurnTimeout getTurretColor getVariant getVersion getX getY go gunBearingTo isAdjustGunForBodyTurn isAdjustRadarForBodyTurn isAdjustRadarForGunTurn isDebuggingEnabled isDisabled 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 sendTeamMessage setAdjustGunForBodyTurn setAdjustRadarForBodyTurn setAdjustRadarForGunTurn setBodyColor setBulletColor setEventPriority setFire setFireAssist setGunColor setGunTurnRate setInterruptible setMaxGunTurnRate setMaxRadarTurnRate setMaxSpeed setMaxTurnRate setRadarColor setRadarTurnRate setRescan setResume setScanColor setStop setTargetSpeed setTracksColor setTurnRate setTurretColor start

    Constructors

    • Creates a new BaseBot with auto-detected configuration from environment variables.

      Returns BaseBot

    • Creates a new BaseBot with the given bot info.

      Parameters

      Returns BaseBot

    • Creates a new BaseBot with the given bot info and server URL.

      Parameters

      • botInfo: BotInfo

        the bot info.

      • serverUrl: string

        the server URL.

      Returns BaseBot

    • Creates a new BaseBot with the given bot info, server URL, and server secret.

      Parameters

      • botInfo: BotInfo

        the bot info.

      • serverUrl: string

        the server URL.

      • serverSecret: string

        the server secret.

      Returns BaseBot

    Properties

    MAX_NUMBER_OF_TEAM_MESSAGES_PER_TURN: 10 = Constants.MAX_NUMBER_OF_TEAM_MESSAGES_PER_TURN

    The maximum number of team messages that can be sent per turn.

    TEAM_MESSAGE_MAX_SIZE: 32768 = Constants.TEAM_MESSAGE_MAX_SIZE

    The maximum size of a team message in bytes (32 KB).

    Methods

    • 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].

    • 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 bullet speed for a given firepower.

      Parameters

      • firepower: number

      Returns number

    • 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 gun heat for a given firepower.

      Parameters

      • firepower: number

      Returns number

    • Calculates the maximum turn rate for a given speed.

      Parameters

      • speed: number

      Returns number

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

    • Height of the arena measured in units. First available when the game has started.

      Returns number

    • Width of the arena measured in units. First available when the game has started.

      Returns number

    • Gets the event priority for a given event type name.

      Parameters

      • eventType: string

      Returns number

    • Game type, e.g. "melee" or "1v1". First available when the game has started.

      Returns string

    • The gun heat of the bot. The gun cannot fire when the gun heat is > 0.

      Returns number

    • Unique id of this bot, available when the game has started.

      Returns number

    • The number of microseconds left of this turn before the bot will skip the turn.

      Returns number

    • The turn timeout in microseconds. First available when the game has started.

      Returns number

    • 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 given bot ID is a teammate.

      Parameters

      • botId: number

      Returns boolean

    • Normalizes an angle to an absolute angle in the range [0, 360).

      Parameters

      • angle: number

        the angle to normalize.

      Returns number

      the normalized angle.

    • Normalizes an angle to a relative angle in the range [-180, 180].

      Parameters

      • angle: number

        the angle to normalize.

      Returns number

      the normalized angle.

    • 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].

    • Sends a message to a specific teammate.

      Parameters

      • teammateId: number
      • message: unknown

      Returns void

    • Sets the event priority for a given event type name.

      Parameters

      • eventType: string
      • priority: number

      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

    • Enables or disables fire assistance.

      Parameters

      • enable: boolean

      Returns void

    • Sets the gun turn rate in degrees per turn.

      Parameters

      • gunTurnRate: number

      Returns void

    • Sets whether the current event handler is interruptible.

      Parameters

      • interruptible: boolean

      Returns void

    • Sets the maximum gun turn rate in degrees per turn.

      Parameters

      • maxGunTurnRate: number

      Returns void

    • Sets the maximum radar turn rate in degrees per turn.

      Parameters

      • maxRadarTurnRate: number

      Returns void

    • Sets the maximum speed in units per turn.

      Parameters

      • maxSpeed: number

      Returns void

    • Sets the maximum turn rate of the bot in degrees per turn.

      Parameters

      • maxTurnRate: number

      Returns void

    • Sets the radar turn rate in degrees per turn.

      Parameters

      • radarTurnRate: number

      Returns void

    • Sets the bot to stop all movement.

      Returns void

    • Sets the bot to stop all movement, optionally overwriting a previous stop.

      Parameters

      • overwrite: boolean

      Returns void

    • Sets the target speed in units per turn.

      Parameters

      • targetSpeed: number

      Returns void

    • Sets the turn rate of the bot in degrees per turn.

      Parameters

      • turnRate: number

      Returns void

    • Starts the bot, connecting to the server and running until the game ends.

      Returns void