From 6d4b2055959a5f483349c1cefa3a64fde8a62d3b Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sat, 9 Dec 2017 21:34:26 -0800 Subject: [PATCH] TicTacToe: Use simple comparison instead of overly-complex first_time(). --- zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py b/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py index 5460fcf..b944d8b 100644 --- a/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py +++ b/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py @@ -253,11 +253,6 @@ class TicTacToeGame(object): return ("next_turn", return_string) # ------------------------------------- -flat_initial = sum(initial_board, []) -def first_time(board): - flat = sum(board, []) - return flat == flat_initial - class ticTacToeHandler(object): ''' You can play tic-tac-toe in a private message with @@ -291,7 +286,7 @@ class ticTacToeHandler(object): user_board = copy.deepcopy(initial_board) user_game = TicTacToeGame(user_board) move = "new" - if not first_time(user_game.board): + if user_game.board != initial_board: return_content = "You're already playing a game! Type **@tictactoe help** or **@ttt help** to see valid inputs." else: return_content = "Welcome to tic-tac-toe! You'll be x's and I'll be o's. Your move first!\n"