aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-01-09 08:21:44 +0200
committerGravatar GitHub <[email protected]>2021-01-09 08:21:44 +0200
commit48103a601f48ac620adf8f97de7ab9f7ab942998 (patch)
tree1c3eeba71869e31a3d6d59e0ca43a030b25fe244 /bot
parentCorrected small spelling mistake. (diff)
Simplify check_win function returning
Diffstat (limited to 'bot')
-rw-r--r--bot/exts/evergreen/tic_tac_toe.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/bot/exts/evergreen/tic_tac_toe.py b/bot/exts/evergreen/tic_tac_toe.py
index b27f1942..d5c2a558 100644
--- a/bot/exts/evergreen/tic_tac_toe.py
+++ b/bot/exts/evergreen/tic_tac_toe.py
@@ -17,21 +17,21 @@ CONFIRMATION_MESSAGE = (
def check_win(board: t.Dict[int, str]) -> bool:
"""Check from board, is any player won game."""
- if (
+ return any(
+ (
# Horizontal
- board[1] == board[2] == board[3]
- or board[4] == board[5] == board[6]
- or board[7] == board[8] == board[9]
+ board[1] == board[2] == board[3],
+ board[4] == board[5] == board[6],
+ board[7] == board[8] == board[9],
# Vertical
- or board[1] == board[4] == board[7]
- or board[2] == board[5] == board[8]
- or board[3] == board[6] == board[9]
+ board[1] == board[4] == board[7],
+ board[2] == board[5] == board[8],
+ board[3] == board[6] == board[9],
# Diagonal
- or board[1] == board[5] == board[9]
- or board[3] == board[5] == board[7]
- ):
- return True
- return False
+ board[1] == board[5] == board[9],
+ board[3] == board[5] == board[7],
+ )
+ )
class Player: