Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
Last active December 15, 2016 14:31
Show Gist options
  • Save LarsBergqvist/7f4ffe2574652e02e8005c623c35dbd3 to your computer and use it in GitHub Desktop.
Save LarsBergqvist/7f4ffe2574652e02e8005c623c35dbd3 to your computer and use it in GitHub Desktop.
Call functions according to mappings between characters and objects' functions
action_methods = {
'F' : wheels.fw_step,
'B' : wheels.back_step,
'L' : wheels.turn_left,
'R' : wheels.turn_right,
'S' : wheels.stop,
'U' : hammer.up,
'D' : hammer.down,
'O' : claws.open,
'C' : claws.close
}
def run(sequence):
for action in sequence:
if action in action_methods:
action_methods[action]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment