Skip to content

Instantly share code, notes, and snippets.

@darius
Created May 20, 2014 15:25
Show Gist options
  • Select an option

  • Save darius/186c20c898efa7488436 to your computer and use it in GitHub Desktop.

Select an option

Save darius/186c20c898efa7488436 to your computer and use it in GitHub Desktop.
def main():
board = Board()
with Terminal() as ui:
keys = ui.gen_key_events()
while True:
ui.render(board.view())
if board.ended():
break
for k in keys:
if k == '^D':
return
try: move = int(k)
except ValueError: continue
board = board.move(move)
ui.render(board.view())
break
if board.ended():
break
board = ai(board, 'o')
next(keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment