Top

direction module

These constants represent the main compass directions that robots can move in.

''
hese constants represent the main
ompass directions that robots can move in.
''    
ORTH = (0, -1)
AST = (1, 0)
OUTH = (0, 1)
EST = (-1, 0)
ef get_x_step(step):
   '''
   Returns the change of the x coordinate if moving one "step" 
   in the direction represented by the given compass direction.
   E.g. for C{WEST} the "x step" is
   -1 since moving one step west means a decrease of one in 
   the x coordinate.
   
   Returns: -1, 0 or 1
   See the documentation of class Coordinates
   '''
   return step[0]
ef get_y_step(step):
   '''
   Returns the change of the y coordinate if moving one 
   "step" in the direction represented by by the given compass 
   direction. E.g. for C{NORTH} the "y step" is
   -1 since moving one step north means a decrease of one in 
   the y coordinate.
   
   Returns: -1, 0 or 1
   See the documentation of class Coordinates
   '''
   return step[1]
ef get_values():
   '''
   Creates a list of directions in a clockwise direction starting 
   from north.
   Returns: list of direction tuples
   '''
   return [NORTH, EAST, SOUTH, WEST]
ef get_next_clockwise(step):
   '''
   Returns the direction 90 degrees clockwise from this direction.
   
   Returns: another direction tuple clockwise from this one: tuple
   '''
   direction_list = get_values()
   index = direction_list.index(step)
   return direction_list[(index + 1) % 4]
ef get_next_counter_clockwise(step):
   '''
   Returns the direction 90 degrees counterclockwise from this direction.
   
   Returns: another direction counterclockwise from this one: tuple
   '''
   direction_list = get_values()
   index = direction_list.index(step)
   return direction_list[(index + 3) % 4]

Module variables

var EAST

var NORTH

var SOUTH

var WEST

Functions

def get_next_clockwise(

step)

Returns the direction 90 degrees clockwise from this direction.

Returns: another direction tuple clockwise from this one: tuple

def get_next_clockwise(step):
    '''
    Returns the direction 90 degrees clockwise from this direction.
    
    Returns: another direction tuple clockwise from this one: tuple
    '''
    direction_list = get_values()
    index = direction_list.index(step)
    return direction_list[(index + 1) % 4]

def get_next_counter_clockwise(

step)

Returns the direction 90 degrees counterclockwise from this direction.

Returns: another direction counterclockwise from this one: tuple

def get_next_counter_clockwise(step):
    '''
    Returns the direction 90 degrees counterclockwise from this direction.
    
    Returns: another direction counterclockwise from this one: tuple
    '''
    direction_list = get_values()
    index = direction_list.index(step)
    return direction_list[(index + 3) % 4]

def get_values(

)

Creates a list of directions in a clockwise direction starting from north.

Returns: list of direction tuples

def get_values():
    '''
    Creates a list of directions in a clockwise direction starting 
    from north.

    Returns: list of direction tuples
    '''
    return [NORTH, EAST, SOUTH, WEST]

def get_x_step(

step)

Returns the change of the x coordinate if moving one "step" in the direction represented by the given compass direction. E.g. for C{WEST} the "x step" is -1 since moving one step west means a decrease of one in the x coordinate.

Returns: -1, 0 or 1

See the documentation of class Coordinates

def get_x_step(step):
    '''
    Returns the change of the x coordinate if moving one "step" 
    in the direction represented by the given compass direction.
    E.g. for C{WEST} the "x step" is
    -1 since moving one step west means a decrease of one in 
    the x coordinate.
    
    Returns: -1, 0 or 1

    See the documentation of class Coordinates
    '''
    return step[0]

def get_y_step(

step)

Returns the change of the y coordinate if moving one "step" in the direction represented by by the given compass direction. E.g. for C{NORTH} the "y step" is -1 since moving one step north means a decrease of one in the y coordinate.

Returns: -1, 0 or 1

See the documentation of class Coordinates

def get_y_step(step):
    '''
    Returns the change of the y coordinate if moving one 
    "step" in the direction represented by by the given compass 
    direction. E.g. for C{NORTH} the "y step" is
    -1 since moving one step north means a decrease of one in 
    the y coordinate.
    
    Returns: -1, 0 or 1

    See the documentation of class Coordinates
    '''
    return step[1]