Set TTT_DEBUG to 1
Print some extra stuff when TTT_DEBUG is 1
This commit is contained in:
parent
1a48c696ea
commit
a29e9bd8cf
2 changed files with 9 additions and 6 deletions
1
.env
1
.env
|
@ -1 +1,2 @@
|
|||
FLASK_APP=tictactoe.py
|
||||
TTT_DEBUG=1
|
||||
|
|
14
tictactoe.py
14
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'})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue