Top

lovebot module

import direction


class Lovebot(object):
    '''
    NOTE! IMPLEMENT THE METHODS DEFINED HERE

    The class Lovebot represents "brains" (or AI) of robots which have another robot as their "beloved". A lovebot tries to home in on its target.

    See the documentation of RobotWorld
    ''' 
   
    def __init__(self, body, beloved):
        '''
        NOTE! IMPLEMENT THIS.

        Creates a new lovebot brain for the given robot body. The lovebot considers the given other robot to be its "beloved".

        Parameter body is the robot whose actions the lovebot brain is supposed to control: Robot

        Parameter beloved is another robot that the lovebot is in love with and follows: Robot

        '''
        pass
 
    def move_body(self):
        '''
        NOTE! IMPLEMENT THIS.

        Moves the given "body", i.e., the robot given as a parameter. A lovebot tries to home in on its beloved unless
        it already is in an adjacent square (diagonally adjacent is not good enough). The lovebot does not know how to
        avoid obstacles, and blindly follows its primitive urges. If there is a wall or another bot in the chosen
        direction, the lovebot will collide into it (causing it to break instead of moving into the square).

        The path of movement is chosen as follows. First the lovebot calculates its distance to its target in both x and
        y dimension. It moves one square at a time so that either x or y distance decreases by one, depending on which
        one is greater. The greater of the two is decremented. In the case that the distances are equal, x is
        decremented. The lovebot only moves one square per turn. When moving (or colliding) a lovebot turns to face the
        direction it is moving in.

        This method assumes that it is called only if the robot is not broken or stuck.
        '''
        pass
 
    def get_beloved(self):
        '''
        NOTE! IMPLEMENT THIS.

        Returns the beloved of the lovebot: Robot
        '''
        pass

    def determine_direction(self, current_location):
        '''
        NOTE! IMPLEMENT THIS.
        
        Determines the direction the lovebot will attempt to move in.

        Parameter current_location is the lovebot's current location: Coordinates

        Returns the preferred direction of movement: tuple

        See move_body()
        '''
        pass
    

Classes

class Lovebot

NOTE! IMPLEMENT THE METHODS DEFINED HERE

The class Lovebot represents "brains" (or AI) of robots which have another robot as their "beloved". A lovebot tries to home in on its target.

See the documentation of RobotWorld

class Lovebot(object):
    '''
    NOTE! IMPLEMENT THE METHODS DEFINED HERE

    The class Lovebot represents "brains" (or AI) of robots which have another robot as their "beloved". A lovebot tries to home in on its target.

    See the documentation of RobotWorld
    ''' 
   
    def __init__(self, body, beloved):
        '''
        NOTE! IMPLEMENT THIS.

        Creates a new lovebot brain for the given robot body. The lovebot considers the given other robot to be its "beloved".

        Parameter body is the robot whose actions the lovebot brain is supposed to control: Robot

        Parameter beloved is another robot that the lovebot is in love with and follows: Robot

        '''
        pass
 
    def move_body(self):
        '''
        NOTE! IMPLEMENT THIS.

        Moves the given "body", i.e., the robot given as a parameter. A lovebot tries to home in on its beloved unless
        it already is in an adjacent square (diagonally adjacent is not good enough). The lovebot does not know how to
        avoid obstacles, and blindly follows its primitive urges. If there is a wall or another bot in the chosen
        direction, the lovebot will collide into it (causing it to break instead of moving into the square).

        The path of movement is chosen as follows. First the lovebot calculates its distance to its target in both x and
        y dimension. It moves one square at a time so that either x or y distance decreases by one, depending on which
        one is greater. The greater of the two is decremented. In the case that the distances are equal, x is
        decremented. The lovebot only moves one square per turn. When moving (or colliding) a lovebot turns to face the
        direction it is moving in.

        This method assumes that it is called only if the robot is not broken or stuck.
        '''
        pass
 
    def get_beloved(self):
        '''
        NOTE! IMPLEMENT THIS.

        Returns the beloved of the lovebot: Robot
        '''
        pass

    def determine_direction(self, current_location):
        '''
        NOTE! IMPLEMENT THIS.
        
        Determines the direction the lovebot will attempt to move in.

        Parameter current_location is the lovebot's current location: Coordinates

        Returns the preferred direction of movement: tuple

        See move_body()
        '''
        pass

Ancestors (in MRO)

Methods

def __init__(

self, body, beloved)

NOTE! IMPLEMENT THIS.

Creates a new lovebot brain for the given robot body. The lovebot considers the given other robot to be its "beloved".

Parameter body is the robot whose actions the lovebot brain is supposed to control: Robot

Parameter beloved is another robot that the lovebot is in love with and follows: Robot

def __init__(self, body, beloved):
    '''
    NOTE! IMPLEMENT THIS.
    Creates a new lovebot brain for the given robot body. The lovebot considers the given other robot to be its "beloved".
    Parameter body is the robot whose actions the lovebot brain is supposed to control: Robot
    Parameter beloved is another robot that the lovebot is in love with and follows: Robot
    '''
    pass

def determine_direction(

self, current_location)

NOTE! IMPLEMENT THIS.

Determines the direction the lovebot will attempt to move in.

Parameter current_location is the lovebot's current location: Coordinates

Returns the preferred direction of movement: tuple

See move_body()

def determine_direction(self, current_location):
    '''
    NOTE! IMPLEMENT THIS.
    
    Determines the direction the lovebot will attempt to move in.
    Parameter current_location is the lovebot's current location: Coordinates
    Returns the preferred direction of movement: tuple
    See move_body()
    '''
    pass

def get_beloved(

self)

NOTE! IMPLEMENT THIS.

Returns the beloved of the lovebot: Robot

def get_beloved(self):
    '''
    NOTE! IMPLEMENT THIS.
    Returns the beloved of the lovebot: Robot
    '''
    pass

def move_body(

self)

NOTE! IMPLEMENT THIS.

Moves the given "body", i.e., the robot given as a parameter. A lovebot tries to home in on its beloved unless it already is in an adjacent square (diagonally adjacent is not good enough). The lovebot does not know how to avoid obstacles, and blindly follows its primitive urges. If there is a wall or another bot in the chosen direction, the lovebot will collide into it (causing it to break instead of moving into the square).

The path of movement is chosen as follows. First the lovebot calculates its distance to its target in both x and y dimension. It moves one square at a time so that either x or y distance decreases by one, depending on which one is greater. The greater of the two is decremented. In the case that the distances are equal, x is decremented. The lovebot only moves one square per turn. When moving (or colliding) a lovebot turns to face the direction it is moving in.

This method assumes that it is called only if the robot is not broken or stuck.

def move_body(self):
    '''
    NOTE! IMPLEMENT THIS.
    Moves the given "body", i.e., the robot given as a parameter. A lovebot tries to home in on its beloved unless
    it already is in an adjacent square (diagonally adjacent is not good enough). The lovebot does not know how to
    avoid obstacles, and blindly follows its primitive urges. If there is a wall or another bot in the chosen
    direction, the lovebot will collide into it (causing it to break instead of moving into the square).
    The path of movement is chosen as follows. First the lovebot calculates its distance to its target in both x and
    y dimension. It moves one square at a time so that either x or y distance decreases by one, depending on which
    one is greater. The greater of the two is decremented. In the case that the distances are equal, x is
    decremented. The lovebot only moves one square per turn. When moving (or colliding) a lovebot turns to face the
    direction it is moving in.
    This method assumes that it is called only if the robot is not broken or stuck.
    '''
    pass