Robot Specific Python#

The VR Rover has access to the standard VR Drivetrain, Events, Control, Variables, and Functions commands.

Drivetrain#

drivetrain.drive_to()#

The drivetrain.drive_to(object, wait) command is used to drive the VR Rover the distance between it and a specified object.

This is can be a non-waiting or waiting command depending on if the wait parameter is used.

Parameters

Description

object

The object that the VR Rover will drive to: BASE, ENEMY, or MINERALS.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.drive_to() command is called, the robot will not drive.

However, when the BASE parameter is used, the robot will drive forward the amount of distance between it and the base.

Returns: None.

def main():
    # Drive the VR Rover to the nearest mineral.
    drivetrain.drive_to(MINERALS)

drivetrain.go_to()#

The drivetrain.go_to(object, wait) command is used to turn and drive the VR Rover to a specified object.

This is can be a non-waiting or waiting command depending on if the wait parameter is used.

Parameters

Description

object

The object that the VR Rover will turn and drive to: BASE, ENEMY, or MINERALS.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.go_to() command is called, the robot will not drive.

However, when the BASE parameter is used, the robot will always turn towards the base and then drive towards it.

Returns: None.

def main():
    # Turn the VR Rover towards the base and drive to it.
    drivetrain.go_to(BASE)

drivetrain.turn_to()#

The drivetrain.turn_to(object, wait) command is used to turn the VR Rover towards a specified object.

This is can be a non-waiting or waiting command depending on if the wait parameter is used.

Parameters

Description

object

The object that the VR Rover will turn to: BASE, ENEMY, or MINERALS.

wait

Optional. The wait parameter determines whether the command will block subsequent commands (wait=True) or allow immediate execution (wait=False). If unspecified, the default for the wait parameter is wait=True.

If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.drive_to() command is called, the robot will not drive.

However, when the BASE parameter is used, the robot will turn to face the base.

Returns: None.

def main():
    # Turn the VR Rover towards the nearest mineral.
    drivetrain.turn_to(MINERALS)

Actions#

rover.pickup()#

The rover.pickup(object) command is used to pick up minerals in the playground.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

object

The object that the VR Rover can pick up: MINERALS.

Returns: None.

def main():
    # Turn and drive the VR Rover to the nearest minerals.
    drivetrain.go_to(MINERALS)
    # Pick up the minerals.
    rover.pickup(MINERALS)

rover.drop()#

The rover.drop(object) command is used to drop minerals in the playground.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

object

The object that the VR Rover can drop: MINERALS.

Returns: None.

def main():
    # Pick up the minerals.
    rover.pickup(MINERALS)
    # Drive in reverse for 200 millimeters.
    drivetrain.drive_for(REVERSE, 200, MM)
    # Drop the minerals.
    rover.drop(MINERALS)

rover.use()#

The rover.use(object) command is used to consume minerals in its storage to recharge its energy level and gain XP. The minerals must be on the ground to be consumed.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

object

The object that the VR Rover can consume: MINERALS.

Returns: None.

def main():
    # Turn and drive the VR Rover to the nearest minerals.
    drivetrain.go_to(MINERALS)
    # Consume the minerals.
    rover.use(MINERALS)

rover.absorb_radiation()#

The rover.absorb_radiation(object) command is used to absorb radiation from enemies in the Rover Rescue playground.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Parameters

Description

object

The object that the VR Rover can absorb radiation from: ENEMY.

Returns: None.

def main():
    # Turn and drive the VR Rover to the nearest enemy.
    drivetrain.go_to(ENEMY)
    # Absorb radiation from the enemy once.
    rover.absorb_radiation(ENEMY)

rover.standby()#

The rover.standby(percent) command is used to put the VR Rover into standby mode until the specified battery threshold is reached.

This is a non-waiting command and allows any subsequent commands to execute without delay.

When in standby, the VR Rover will use its battery slower, but the Number of Days Survived counter will increase at a higher rate.

Once the battery level threshold is reached, the VR Rover will come out of standby, going back to consuming its battery and increasing the Number of Days Survived counter at the normal rate.

If the passed threshold is equal or above the current battery level, the VR Rover will not enter standby mode.

Parameters

Description

percent

The battery threshold that the VR Rover will exit standby mode at, from 0 to 100.

Returns: None.

def main():
    # Go into standby mode until battery reaches 35%.
    rover.standby(35)

Looks#

The VR Rover does not have access to the VR Pen, but it can still print to its Monitor Console.

Events#

When Rover is Under Attack#

The rover.on_under_attack(callback) command runs the callback function when the VR Rover takes damage from an enemy.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: None.

# Define a new function for when the rover is under attack.
def under_attack():
    # The rover will print that it is under attack in the Print Console.
    brain.print("The rover is under attack!")

def main():
    # Register the under_attack() function to trigger
    # when the rover is under attack.
    rover.on_under_attack(under_attack)
    # Wait .15 seconds to allow the function time to register in the event.
    wait(.15, SECONDS)

When Rover Levels Up#

The rover.on_level_up(callback) command runs the callback function when the VR Rover moves from one level to the next.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: None.

# Define a new function for when the rover levels up.
def level_up():
    # The rover will print that it leveled up in the Print Console.
    brain.print("The rover leveled up!")

def main():
    # Register the level_up() function to trigger
    # when the rover levels up.
    rover.on_level_up(level_up)
    # Wait .15 seconds to allow the function time to register in the event.
    wait(.15, SECONDS)

Sensing#

The VR Rover has access to the standard Brain, Drivetrain, and Distance Sensing commands.

rover.battery()#

The rover.battery() command reports the current battery level of the VR Rover.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: This reports a numerical value.

def main():
    # Print the current battery level.
    brain.print(rover.battery())

rover.minerals_stored()#

The rover.minerals_stored() command reports the current amount of minerals the VR Rover has in its storage.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: This reports a numerical value.

def main():
    # Print the current amount of minerals in the VR Rover's storage.
    brain.print(rover.minerals_stored())

rover.level()#

The rover.level() command reports the current level of the VR Rover.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: This reports a numerical value.

def main():
    # Print the current level of the VR Rover.
    brain.print(rover.level())

rover.exp()#

The rover.exp() command reports the number of Experience Points (XP) that the VR Rover has at the current level.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: This reports a numerical value.

def main():
    # Print the current amount of XP that the VR Rover has.
    brain.print(rover.exp())

rover.storage_capacity()#

The rover.storage_capacity() command reports the carrying capacity of the VR Rover.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: This reports a numerical value.

def main():
    # Print the carrying capacity of the VR Rover.
    brain.print(rover.storage_capacity())

rover.under_attack()#

The rover.under_attack() command reports whether the VR Rover is under attack from an enemy.

This is a non-waiting command and allows any subsequent commands to execute without delay.

Returns: This reports a Boolean value.

def main():
    # Continuously check the if statement every 5 milliseconds.
    while True:
        wait(5, MSEC)
        # Check if the rover has come under attack.
        if rover.under_attack() = True:
            # Print a message to the Print Console.
            brain.print("The rover is under attack!")

rover.detects()#

The rover.detects(object) command reports whether the VR Rover detects an enemy or minerals in its smelling range.

Parameters

Description

object

The Game Element to detect: MINERALS or ENEMY.

This is a non-waiting command and allows any subsequent commands to execute without delay.

The detect radius of the VR Rover is 800 millimeters (MM). This can be seen in the mini-map on the Playground indicated by the yellow circle around the VR Rover.

Returns: This reports a Boolean value.

def main():
    # Continuously check the if statement every 5 milliseconds.
    while True:
        wait(5, MSEC)
        # Check if the rover has detected any minerals.
        if rover.detects(MINERALS) = True:
            # Turn and drive to the closest minerals.
            drivetrain.go_to(MINERALS)
            # Pick up the minerals.
            rover.pickup(MINERALS)

rover.sees()#

The rover.sees(object) command reports whether the VR Rover sees detectable objects in its vision range.

Parameters

Description

object

The Game Element to see: BASE, ENEMY, HAZARD, MINERALS or OBSTACLE.

This is a non-waiting command and allows any subsequent commands to execute without delay.

The vision range of the VR Rover is 1000 millimeters (mm) away from the Rover and within its field of view.

The field of view of the VR Rover is 40 degrees. This can be seen in the mini-map on the Playground indicated by the gray translucent cone from the front of the VR Rover.

Returns: This reports a Boolean value.

def main():
    # Continuously check the if statement every 5 milliseconds.
    while True:
        wait(5, MSEC)
        # Check if the rover can see any minerals.
        if rover.sees(MINERALS) = True:
            # Turn and drive to the closest minerals.
            drivetrain.go_to(MINERALS)
            # Pick up the minerals.
            rover.pickup(MINERALS)

rover.angle()#

The rover.angle(object) command reports the direction in degrees of the closest specified object within the VR Rover’s vision range (1000 millimeters) and within its field of view.

Parameters

Description

object

The Game Element to report the direction of: BASE, ENEMY, or MINERALS.

This is a non-waiting command and allows any subsequent commands to execute without delay.

The vision range of the VR Rover is 1000 millimeters (mm) away from the Rover and within its field of view.

The field of view of the VR Rover is 40 degrees. This can be seen in the mini-map on the Playground indicated by the gray translucent cone from the front of the VR Rover.

Returns: This reports a numerical value.

def main():
    # Print the direction in degrees of the closest minerals.
    brain.print(rover.angle(MINERALS))

rover.get_distance()#

The rover.get_distance(object, units) command reports the distance from the VR Rover to minerals, enemies, obstacles, hazards, or the base if they’re within its vision range.

Parameters

Description

object

Game Element to report distances from VR Rover: BASE, ENEMY, HAZARD, MINERALS, or OBSTACLE.

units

The units to report the distance as: Millimeters (MM) or INCHES.

This is a non-waiting command and allows any subsequent commands to execute without delay.

The vision range of the VR Rover is 1000 millimeters (mm) away from the Rover and within its field of view.

The field of view of the VR Rover is 40 degrees. This can be seen in the mini-map on the Playground indicated by the gray translucent cone from the front of the VR Rover.

If BASE is passed as the object parameter, the VR Rover will always report the distance, even if the Base is not in view.

If OBSTACLE or HAZARD is passed as the object parameter, but no obstacle or hazard is within view, the rover.get_distance() command will return 1000 millimeters or 39.37 inches.

Returns: This reports a numerical value.

def main():
    # Print the distance between the VR Rover and the base.
    brain.print(rover.get_distance(BASE))

rover.location()#

The rover.location(object, axis, units) command reports the X or Y coordinate location of minerals, enemies, obstacles, hazards, or the base if they’re within its vision range.

Parameters

Description

object

Game Element to report locations of: BASE, ENEMY, HAZARD, MINERALS, OBSTACLE, ROVER.

axis

The axis to return values on: X or Y.

units

The units to report the distance as: Millimeters (MM) or INCHES.

This is a non-waiting command and allows any subsequent commands to execute without delay.

If BASE is passed as the object parameter, the VR Rover will always report the location, even if the Base is not in view.

Returns: This reports a numerical value.

def main():
    # Print the current location of the VR Rover on the Y axis in millimeters.
    brain.print(rover.location(ROVER, Y, MM))

rover.enemy_level()#

The rover.enemy_level() command reports the level of the closest enemy detected in the VR Rover’s vision.

This is a non-waiting command and allows any subsequent commands to execute without delay.

The detect radius of the VR Rover is 800 millimeters (MM). This can be seen in the mini-map on the Playground indicated by the yellow circle around the VR Rover.

If no enemy is detected, rover.enemy_level() will return 0.

Returns: This reports a numerical value.

def main():
    # Print the level of the closest detected enemy.
    brain.print(rover.enemy_level())

rover.enemy_radiation()#

The rover.enemy_radiation() command reports the radiation of the closest enemy detected in the VR Rover’s vision.

This is a non-waiting command and allows any subsequent commands to execute without delay.

The detect radius of the VR Rover is 800 millimeters (MM). This can be seen in the mini-map on the Playground indicated by the yellow circle around the VR Rover.

If no enemy is detected, rover.enemy_radiation() will return 0.

Returns: This reports a numerical value.

def main():
    # Print the radiation of the closest detected enemy.
    brain.print(rover.enemy_radiation())