Skip to content
CS 233 // Spimbot
Pages

Map and movement

Coordinates

#

The map is 300 by 300 pixels with the origin at the top left: x grows to the right and y grows down. It is divided into 30 by 30 tiles of 10 by 10 pixels.

The map at the start of a match, where a faint line marks each of its 30 by 30 tiles. Red's base covers 3 by 3 tiles in the upper left, and blue's base covers 3 by 3 tiles in the lower right. Twelve wooden walls, each 3 to 6 tiles long, sit in pairs that mirror each other through the center of the map.
  • The tile under pixel (x, y) is in column x / 10 and row y / 10, with integer division.
  • The center of the tile in column c and row r is the pixel (10c + 5, 10r + 5).
  • A tile's index in the field map is row * 30 + column.

The map is symmetric under a 180-degree rotation about its center, which takes row r and column c to row 29 - r and column 29 - c.

Bases

#

Bot 0's home base lies in the left half: its top-left tile is in rows 4 to 23 and columns 4 to 8. Bot 1's base is its rotation. A base belongs to its bot for the whole match and is impassable to the opponent. In a one-bot match, bot 1's base is still on the map as an obstacle.

Walls

#

Walls are straight horizontal or vertical segments, 3 to 6 tiles long, up to 12 per map in rotated pairs. They lie in rows and columns 2 to 27 and leave at least 2 empty tiles around each base and between each other. A bot can reach every tile except the walls and the opponent's base. A bot cannot drive on, paint or claim a wall.

Movement

#

A bot is a disc with a radius of 5 pixels. It starts at rest at the center of its base, facing 0 degrees.

Value Range Meaning
Heading 0 to 359 A whole number of degrees: 0 points right (+x), 90 down (+y), 180 left and 270 up
Velocity -10 to 10 A whole number of pixels per 10,000 cycles. At 10, a bot crosses a tile in 10,000 cycles. A negative velocity drives backward

To turn:

  1. Write an angle from -360 to 360 to ANGLE.
  2. Write 0 to ANGLE_CONTROL to turn by that angle, or 1 to set the heading to it.

Each further write of 0 turns by the same angle again. Reading ANGLE returns the current heading.

BOT_X and BOT_Y truncate the bot's position to whole pixels. Painting and claiming happen as the bot's center enters each tile. When the center passes exactly through a tile corner, it enters the next tile in its row, then the next tile in its column, then the diagonal tile.

Bonks

#

A bot's disc cannot come closer than 5 pixels to a wall tile, a tile of the opponent's base or the map edge. A bot centered in a row of tiles drives past a wall in the next row. A move that would come closer is a bonk: the bot stops, its velocity becomes 0, and BONK is raised.

Collisions

#

Two bots collide when their centers come closer than 10 pixels. On first contact, both bots stop, both get BONK, and every trail on the map is canceled with COLLISION. Until the bots move apart, a move that brings one closer to the other is blocked. That bot stops and gets BONK, and no trail is canceled.