Skip to content

Instantly share code, notes, and snippets.

@molarmanful
Created September 18, 2019 19:40
Show Gist options
  • Save molarmanful/3cba6ae8f8911bac204fc6ac02ec0316 to your computer and use it in GitHub Desktop.
Save molarmanful/3cba6ae8f8911bac204fc6ac02ec0316 to your computer and use it in GitHub Desktop.
def move_wrap(d):
if d == 'up':
POS = (POS - COLS) % ROWS
if d == 'down':
POS = (POS + COLS) % ROWS
if d == 'left':
POS = POS - 1 if POS % COLS else POS + COLS - 1
if d == 'right':
POS = POS + 1 if (POS + 1) % COLS else POS - COLS + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment