diff --git a/.env b/.env index 344dc13..1fdf296 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ FLASK_APP=tictactoe.py +TTT_DEBUG=1 diff --git a/tictactoe.py b/tictactoe.py index 8f9a170..0b5b4b7 100644 --- a/tictactoe.py +++ b/tictactoe.py @@ -1,3 +1,4 @@ +import os from flask import Flask, abort, request BOARD_SIZE = 9 @@ -171,10 +172,11 @@ def hello(): return ("It isn't O's turn.\n\n{}".format(board), 400, {'Content-type': 'text/plain'}) next_board = board.move() - out = '''{} - -Score: {} - -Next: -{}'''.format(board, board.evaluate(), next_board) + out = str(next_board) + if bool(os.environ.get('TTT_DEBUG', False)): + import pprint + out += '\n\n---------- DEBUG ----------' + out += '\n\nInput:\n{}'.format(board) + out += '\n\nScore: {}'.format(board.score) + out += '\n\nChildren:\n{}'.format(pprint.pformat(board.children)) return (out, 200, {'Content-type': 'text/plain'})