examples/robots.py
def handle_input(self, input):
        '''Takes a single character string as input and alters the game
        state according to that input. Mostly, this means moving the
        player around. Returns a new game state and boolean indicating
        whether the input had an effect on the state.'''

        dirs = {
            'h': (-1, 0),
            'j': (0, 1),
            'k': (0, -1),
            'l': (1, 0),
            'y': (-1, -1),
            'u': (1, -1),
            'n': (1, 1),
            'b': (-1, 1),
        }

        if input in dirs:
            new_self = (lens.player + dirs[input])(self)
            if not new_self.player.inside():
                return self, False
            return new_self, True
        elif input == '.':
            return self, True
        elif input == 'q':
            return self.end_game(), False
        elif input == 't':
            self = lens.player.set(Vector.random())(self)
            return self, True
        else:
            return self, False
def handle_input(self, input):
        '''Takes a single character string as input and alters the game
        state according to that input. Mostly, this means moving the
        player around. Returns a new game state and boolean indicating
        whether the input had an effect on the state.'''

        dirs = {
            'h': (-1, 0),
            'j': (0, 1),
            'k': (0, -1),
            'l': (1, 0),
            'y': (-1, -1),
            'u': (1, -1),
            'n': (1, 1),
            'b': (-1, 1),
        }

        if input in dirs:
            new_self = (lens.player + dirs[input])(self)
            if not new_self.player.inside():
                return self, False
            return new_self, True
        elif input == '.':
            return self, True
        elif input == 'q':
            return self.end_game(), False
        elif input == 't':
            self = lens.player.set(Vector.random())(self)
            return self, True
        else:
            return self, False
def handle_input ( self , input ) : dirs = { 'h' : ( - 1 , 0 ) , 'j' : ( 0 , 1 ) , 'k' : ( 0 , - 1 ) , 'l' : ( 1 , 0 ) , 'y' : ( - 1 , - 1 ) , 'u' : ( 1 , - 1 ) , 'n' : ( 1 , 1 ) , 'b' : ( - 1 , 1 ) , } if input in dirs : new_self = ( lens . player + dirs [ input ] ) ( self ) if not new_self . player . inside ( ) : return self , False return new_self , True elif input == '.' : return self , True elif input == 'q' : return self . end_game ( ) , False elif input == 't' : self = lens . player . set ( Vector . random ( ) ) ( self ) return self , True else : return self , False
Takes a single character string as input and alters the game
        state according to that input. Mostly, this means moving the
        player around. Returns a new game state and boolean indicating
        whether the input had an effect on the state.
Takes a single character string as input and alters the game state according to that input . Mostly this means moving the player around . Returns a new game state and boolean indicating whether the input had an effect on the state .