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
|
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
|
from flask import Flask, abort, request
|
||||||
|
|
||||||
BOARD_SIZE = 9
|
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'})
|
return ("It isn't O's turn.\n\n{}".format(board), 400, {'Content-type': 'text/plain'})
|
||||||
|
|
||||||
next_board = board.move()
|
next_board = board.move()
|
||||||
out = '''{}
|
out = str(next_board)
|
||||||
|
if bool(os.environ.get('TTT_DEBUG', False)):
|
||||||
Score: {}
|
import pprint
|
||||||
|
out += '\n\n---------- DEBUG ----------'
|
||||||
Next:
|
out += '\n\nInput:\n{}'.format(board)
|
||||||
{}'''.format(board, board.evaluate(), next_board)
|
out += '\n\nScore: {}'.format(board.score)
|
||||||
|
out += '\n\nChildren:\n{}'.format(pprint.pformat(board.children))
|
||||||
return (out, 200, {'Content-type': 'text/plain'})
|
return (out, 200, {'Content-type': 'text/plain'})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue