Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def winner_check(field, field_len, win_condition):
- for x in range(field_len):
- for y in range(field_len): #range len field
- symbol = field[x][y]
- c = 0
- if y < field_len - win_condition: # len(field)-2 vagy field_len - (Win condition - 1)
- if not symbol == "#":
- for i in range(win_condition + 1): #win_c = 3
- if field[x][y + i] == symbol:
- c += 1
- """ print("Compraing this:", field[x][y + i])
- print("c:", c)
- print("x:", x, "y:", y + (i + 1))
- print("symb:", symbol) """
- if c >= win_condition + 1:
- return print_winner(symbol)
- c = 0
- if x < field_len - win_condition:
- if not symbol == "#":
- for i in range(win_condition + 1): #win_c = 3
- if field[x + i][y] == symbol:
- c += 1
- """ print("Compraing this:", field[x][y + i])
- print("c:", c)
- print("x:", x, "y:", y + (i + 1))
- print("symb:", symbol) """
- if c >= win_condition + 1:
- return print_winner(symbol)
- c = 0
- if x < field_len - win_condition and y < field_len - win_condition:
- if not symbol == "#":
- for i in range(win_condition + 1): #win_c = 3
- if field[x + i][y + i] == symbol:
- c += 1
- """ print("Compraing this:", field[x][y + i])
- print("c:", c)
- print("x:", x, "y:", y + (i + 1))
- print("symb:", symbol) """
- if c >= win_condition + 1:
- return print_winner(symbol)
- c = 0
- if x > 1 and y < field_len - win_condition:
- if not symbol == "#":
- for i in range(win_condition + 1): #win_c = 3
- if field[x - i][y + i] == symbol:
- c += 1
- """ print("Compraing this:", field[x][y + i])
- print("c:", c)
- print("x:", x, "y:", y + (i + 1))
- print("symb:", symbol) """
- if c >= win_condition + 1:
- return print_winner(symbol)
- #print(c)
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement