RBN-CODE

code robots·win battles
autonomous·100% online
Arena Builder
Optional Presets
Starter
  • browserbot
  • wanderbot
Harder 1
  • browserbot
  • spinbot
Harder 2
  • browserbot
  • spinbot
  • slowbot
Harder 3
  • browserbot
  • spinbot
  • fastbot
Challenge 1
  • browserbot
  • default
Challenge 2
  • browserbot
  • default
  • default
Challenge 3
  • browserbot
  • default
  • default
  • default
Manuals
  • browserbot
  • browserbot
Load Robots

* sample code available
use your own robots: upload and paste ID into text area
Press Start
Ensure New Arena

Information

RBN-CODE is an open-source robot battle simulator inspired by Battlecode, JSBattle and Robocode. Robots are fully autonomous and controlled via JavaScript; other programming languages are supported via the WebSocket protocol. The real-time simulation features realistic 2D physics, via the Matter.js engine.

Interface
Run
Updates

Arena

When accessing an arena, the page will look like this:

Arenas only pause when:

  • Waiting for robot connection, usually with browser robots.
    Displayed as a red "(precheck) ..." error in the sidebar.
    Just connect a brain via the Robot Control Panel.
  • Other robot errors
    Displayed in sidebar as red text under a robot.
  • The simulation has stopped
    Notification shown at the top of the screen.

Additional details are shown below the current Arena:

Get a Robot ID and Key from Arenas, which can be used to upload robots via the Robot Manager. Direct uploads from the Robot Control Panel is also possible.

The Robot ID can be used to add uploaded robots into other arenas via the Arena Builder.

Robot Control Panel

To write and test client-side robots from the browser...

  1. Open an Arena Builder preset that has at least one "browserbot" configured
  2. Click on the black box to open the Robot IDE
  3. The Robot Integrated Development Environment (IDE) is where you test code:
  4. Add/edit code in the Brain/Code Editor
  5. "Connect" - the arena will start after a few seconds
    Pressing the button again will toggle the connection
  6. "Upload" stores code into the server, "retrieve" loads it back
    • Upload robots as many times as required
    • Only one robot will be stored per arena

Robots

  • Each robot has a "brain", consisting of functional code
  • There are two types of robots:
    • browserbots run client-side in the browser
    • serverbots run server-side and are uploaded browserbots
  • Browserbots are used for development and testing
    • Browserbots are always called Debug <number>
    • Convert browserbots into serverbots via the Robot Manager
    • Serverbots run faster and have custom names and teams
    • Serverbots are harder to debug
  • Robots receive context - "brain" input and output:
    • context.state contains current information about the robot
    • robots have two main sensor inputs:
      • context.state.scanner list things in front of it
      • context.state.proximity list things within close range
  • The "brain" sets context.action to control:
    • robot rotation / .desiredAngle
      a number in radians, maximum possible per frame is stored in context.state.maxRotate
    • robot forward movement / .desiredForce
      a number representing force, maximum possible per frame is stored in context.state.maxForce
    • projectile launch / .desiredLaunch
      a boolean value, actual launch rate is limited by the server
    • scan distance / .desiredScan
      a number, far scans are narrower; near scans are wider
  • context.round contains information about the current round
  • Robots are stateless and do not "remember" anything
    Frame-to-frame storage is available with context.memory
  • Code is run every frame, 60 frames = 1 server second
  • Robots are damaged by: projectiles, robot bodies, walls
  • Serverbots are also damaged from syntax errors; and brain timeouts, caused by hanging code
    Server-side damage show as blue sparks
  • Browserbots depend on the internet and run slower.
  • A faster way to code and test robots is to run a local server. This platform is open-source, can run offline locally. The link is available in the page footer.

Competition Outline

Important: Rules may be updated in the interest of fair-play - the organisers will always announce these beforehand.

Competitions use a league and ranking system.

  • League group assignments are random. The number of robots per group are announced prior to the competition.
  • Each match has two groups of robots battling several rounds.
  • Match ordering is random and can run concurrently.
  • The minimum number of rounds per match is the the total number of robots in the match.
  • A round lasts at least 1 minute.
  • When a round ends, robots are ranked based on:
    1. longest surviving; followed by,
    2. highest health; followed by,
    3. highest accuracy.
    Lowest rank wins!
  • Robots drawing at the same rank are penalised by the number of tied robots, e.g. three robots tied at rank 2, get rank 5 each.
  • Average ranking of robots is displayed in a live leaderboard.

PREPARE FOR BATTLE!

  • Treat the Arena ID as secret. Share it only if you have to.
  • Test with the presets, sample code and your own too!
  • Always make offline copies of your work!
    Browserbots are not auto-saved for you.
  • Robots must be uploaded for competitions.
    • The Robot Manager uploads/updates robots.
    • Serverbots reload brains every few seconds.
    • Running battles do not pause during reloads.
    • It is a valid strategy to update robots in the middle of a battle.
    • Test before uploads, serverbots are harder to debug.
  • Monitor robot performance via the leaderboard and live arenas.
  • Optionally have different brains with different strategies.

Changelog

  • 2023-02-19 to 2023-02-26
  • 2023-01-27 to 2023-02-13
    • overlay manager for branding, attract (2d sample)
    • pausable results
    • arena visuals: eliminate canvas taint
  • 2022-12-26 to 2023-01-09
    • tabbed content on front page
    • socket.io security fix
  • 2022-12-15 to 2022-12-25
    • NEW round status: context.round
    • NEW robot health: context.state.health
    • NEW distance to center for rankings
    • NEW retro-gritty design
    • NEW Arena Builder (old links still work)
    • unified notifications
    • change: last 1000 logs retained per arena
  • 2022-12-06 to 2022-12-11
    • NEW arena replay: 20 most recent
    • show shock/explosions in replays
    • optimisation: reduce replay storage (~80%)
    • optimisation: client-side render via lookups
    • standardise css
  • 2022-11-28 to 2022-12-04
    • NEW sound effects, music
    • NEW robots spark when code crashes
    • NEW damage log: context.state.lastDamage
    • NEW max 8 robots per server arena
    • optimisation: reduce bandwidth usage (~40%)
    • optimisation: forEach/map/reduce to faster for
    • competition page fast load, show started arenas
    • max 1000 rounds (from ∞), 12 hours (from 24)
  • 2022-11-21 to 2022-11-25
    • NEW competition mode: auto-resume; public dashboard; shuffle robots, places
    • NEW rule updates: start on any side of arena; penalise rank by robots tied; square arena; robot takes damage from code crash;
    • NEW source code release
    • direct upload from Robot Control Panel
    • start arenas independently, with optional lock
    • live reload of uploaded brains
    • unique robot ID and Key in each arena
    • notify on simulation stopped, incorrect balancer
  • 2022-11-13 to 2022-11-20
    • NEW robot sample code
    • NEW robot manager for robot upload
    • NEW API dashboard for backend control
    • NEW server-side arena, with uploaded robots
    • Robot Control Panel: copy context; big buttons
    • local cdn for js/css
    • limit arena ID characters
    • multiprocess: multi-core; IPC state sharing
    • standardised context for server/browser brains
    • results data as downloadable csv
    • rule upgrade: ranking by time, health, accuracy
    • nginx load-balancer support
    • socket.io upgraded to 4.5.3 (from 2.3.1)
    • random arena ID, browser persistence
    • improve page design and documentation
    • editor bugfixes: erratic entry, validation
    • concurrency bugfix: flashing/jumping robots