Skip to content

Commit c2e8a53

Browse files
committed
the horizintal winner is checked
1 parent 507386e commit c2e8a53

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

.idea/PyCharmMiscProject.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from multiprocessing.resource_sharer import stop
2+
13
game = [
24
[0, 0, 0],
35
[0, 0, 0],
@@ -9,11 +11,24 @@ def game_board(player=0, row=0, column=0, just_display=False):
911
try:
1012
if not just_display:
1113
game[row][column] = player
14+
else:
1215
print(' a b c')
1316
for count, row in enumerate(game):
1417
print(count, row)
1518
except IndexError as e:
1619
print('some error occured:', e)
1720

1821

19-
game_board(player=1, row=5, column=1)
22+
def checkWinner(game):
23+
for row in game:
24+
if row[0] == row[1] == row[2] != 0:
25+
print(f'Player {row[0]} wins!')
26+
stop;
27+
28+
29+
30+
game_board(player=1, row=2, column=1)
31+
game_board(player=1, row=2, column=0)
32+
game_board(player=1, row=2, column=2)
33+
game_board(just_display=True)
34+
checkWinner(game)

0 commit comments

Comments
 (0)