Chess player: Difference between revisions
Content added Content deleted
(→{{libheader|python-chess}}: needs more HAL 9000) |
|||
Line 966: | Line 966: | ||
board = chess.Board() |
board = chess.Board() |
||
def hal9000(): |
|||
print("Thank you for a very enjoyable game.") |
|||
while not board.outcome(): |
while not board.outcome(): |
||
Line 971: | Line 974: | ||
try: |
try: |
||
move = input("Your move? ") |
move = input("Your move? ") |
||
if move |
if move in ("quit", "resign", "exit"): |
||
hal9000() |
|||
sys.exit() |
|||
board.push_uci(move) |
board.push_uci(move) |
||
except ValueError: print("Sorry?") |
except ValueError: print("Sorry?") |
||
Line 997: | Line 1,002: | ||
print(board.unicode()) |
print(board.unicode()) |
||
print(f"Game finished, result is {board.result()}") |
print(f"Game finished, result is {board.result()}") |
||
hal9000()</lang> |
|||
{{Output}} (in ASCII) |
{{Output}} (in ASCII) |
||
<pre>$ python3 simplechess.py |
<pre>$ python3 simplechess.py |