Top

spinbot module

import direction

class Spinbot(object):
    '''
    The class C{Spinbot} represents the "brains" 
    (or AI) of very simple, boring robots that stand still 
    and merely spin clockwise.
    '''
 
    def __init__(self, body):
        '''
        Creates a new spinbot brain for the given body.
        
        Parameter body is the robot whose actions the spinbot brain is supposed to control: Robot
        '''
        self.body = body        # fixed value
 
 
    def move_body(self):
        '''
        Moves the given "body", i.e., the robot given as a parameter. 
        A spinbot just spins 90 degrees clockwise as its move. 
        
        This method assumes that it is called only if the robot is not 
        broken or stuck.
        '''
        facing = self.body.get_facing()
        next_facing = direction.get_next_clockwise(facing)
        self.body.spin(next_facing)

Classes

class Spinbot

The class C{Spinbot} represents the "brains" (or AI) of very simple, boring robots that stand still and merely spin clockwise.

class Spinbot(object):
    '''
    The class C{Spinbot} represents the "brains" 
    (or AI) of very simple, boring robots that stand still 
    and merely spin clockwise.
    '''
 
    def __init__(self, body):
        '''
        Creates a new spinbot brain for the given body.
        
        Parameter body is the robot whose actions the spinbot brain is supposed to control: Robot
        '''
        self.body = body        # fixed value
 
 
    def move_body(self):
        '''
        Moves the given "body", i.e., the robot given as a parameter. 
        A spinbot just spins 90 degrees clockwise as its move. 
        
        This method assumes that it is called only if the robot is not 
        broken or stuck.
        '''
        facing = self.body.get_facing()
        next_facing = direction.get_next_clockwise(facing)
        self.body.spin(next_facing)

Ancestors (in MRO)

Instance variables

var body

Methods

def __init__(

self, body)

Creates a new spinbot brain for the given body.

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

def __init__(self, body):
    '''
    Creates a new spinbot brain for the given body.
    
    Parameter body is the robot whose actions the spinbot brain is supposed to control: Robot
    '''
    self.body = body        # fixed value

def move_body(

self)

Moves the given "body", i.e., the robot given as a parameter. A spinbot just spins 90 degrees clockwise as its move.

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

def move_body(self):
    '''
    Moves the given "body", i.e., the robot given as a parameter. 
    A spinbot just spins 90 degrees clockwise as its move. 
    
    This method assumes that it is called only if the robot is not 
    broken or stuck.
    '''
    facing = self.body.get_facing()
    next_facing = direction.get_next_clockwise(facing)
    self.body.spin(next_facing)