机器人专用 Python#

VR Rover 可以访问标准 VR 传动系统、事件、控制、变量和功能命令。

传动系统#

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.

参数

描述

目的

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

等待

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.

**返回:**无。

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.

参数

描述

目的

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

等待

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.

**返回:**无。

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.

参数

描述

目的

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

等待

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.

**返回:**无。

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

行动#

rover.pickup()#

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

参数

描述

目的

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

**返回:**无。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

参数

描述

目的

The object that the VR Rover can drop: MINERALS.

**返回:**无。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

参数

描述

目的

The object that the VR Rover can consume: MINERALS.

**返回:**无。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

参数

描述

目的

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

**返回:**无。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

待机状态下,VR Rover 的电池消耗速度会较慢,但生存天数计数器会以更高的速率增加。

一旦达到电池电量阈值,VR Rover 将退出待机状态,重新消耗电池并以正常速率增加生存天数计数器。

如果传递的阈值等于或高于当前电池电量,VR Rover 将不会进入待机模式。

参数

描述

百分比

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

**返回:**无。

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

外观#

VR Rover 无法访问 VR Pen,但它仍然可以打印到其监视器控制台。

活动#

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**无。

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**无。

# 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)

传感#

VR Rover 可以访问标准大脑、传动系统和距离感应命令。

rover.battery()#

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

**返回:**报告一个布尔值。

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.

参数

描述

目的

The Game Element to detect: MINERALS or ENEMY.

这是一个非等待命令,允许任何后续命令无延迟地执行。

VR 探测车的探测半径为 800 毫米 (MM)。您可以在游乐场的迷你地图上看到 VR 探测车周围的黄色圆圈。

**返回:**报告一个布尔值。

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.

参数

描述

目的

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

VR 火星车的视野范围是距离火星车 1000 毫米 (mm),在其视野范围内。

VR 探测车的视野为 40 度。这可以在游乐场的迷你地图上看到,VR 探测车前方的灰色半透明锥体表示该视野。

**返回:**报告一个布尔值。

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.

参数

描述

目的

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

VR 火星车的视野范围是距离火星车 1000 毫米 (mm),在其视野范围内。

VR 探测车的视野为 40 度。这可以在游乐场的迷你地图上看到,VR 探测车前方的灰色半透明锥体表示该视野。

**返回:**报告一个数值。

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.

参数

描述

目的

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

单位

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

VR 火星车的视野范围是距离火星车 1000 毫米 (mm),在其视野范围内。

VR 探测车的视野为 40 度。这可以在游乐场的迷你地图上看到,VR 探测车前方的灰色半透明锥体表示该视野。

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.

**返回:**报告一个数值。

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.

参数

描述

目的

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

The axis to return values on: X or Y.

单位

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

这是一个非等待命令,允许任何后续命令无延迟地执行。

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

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

VR 探测车的探测半径为 800 毫米 (MM)。您可以在游乐场的迷你地图上看到 VR 探测车周围的黄色圆圈。

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

**返回:**报告一个数值。

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.

这是一个非等待命令,允许任何后续命令无延迟地执行。

VR 探测车的探测半径为 800 毫米 (MM)。您可以在游乐场的迷你地图上看到 VR 探测车周围的黄色圆圈。

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

**返回:**报告一个数值。

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