Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.63 KB | None | 0 0
  1. def winner_check(field, field_len, win_condition):
  2.     for x in range(field_len):
  3.         for y in range(field_len): #range len field
  4.             symbol = field[x][y]
  5.             c = 0
  6.             if y < field_len - win_condition:  # len(field)-2  vagy  field_len - (Win condition - 1)
  7.                 if not symbol == "#":
  8.                     for i in range(win_condition + 1):  #win_c = 3
  9.                         if field[x][y + i] == symbol:
  10.                             c += 1
  11.                             """ print("Compraing this:", field[x][y + i])
  12.                            print("c:", c)
  13.                            print("x:", x, "y:", y + (i + 1))
  14.                            print("symb:", symbol) """
  15.                 if c >= win_condition + 1:
  16.                     return print_winner(symbol)
  17.             c = 0
  18.             if x < field_len - win_condition:
  19.                 if not symbol == "#":
  20.                     for i in range(win_condition + 1):  #win_c = 3
  21.                         if field[x + i][y] == symbol:
  22.                             c += 1
  23.                             """ print("Compraing this:", field[x][y + i])
  24.                            print("c:", c)
  25.                            print("x:", x, "y:", y + (i + 1))
  26.                            print("symb:", symbol) """
  27.                 if c >= win_condition + 1:
  28.                     return print_winner(symbol)
  29.             c = 0
  30.             if x < field_len - win_condition and y < field_len - win_condition:
  31.                 if not symbol == "#":
  32.                     for i in range(win_condition + 1):  #win_c = 3
  33.                         if field[x + i][y + i] == symbol:
  34.                             c += 1
  35.                             """ print("Compraing this:", field[x][y + i])
  36.                            print("c:", c)
  37.                            print("x:", x, "y:", y + (i + 1))
  38.                            print("symb:", symbol) """
  39.                 if c >= win_condition + 1:
  40.                     return print_winner(symbol)
  41.             c = 0
  42.             if x > 1 and y < field_len - win_condition:
  43.                 if not symbol == "#":
  44.                     for i in range(win_condition + 1):  #win_c = 3
  45.                         if field[x - i][y + i] == symbol:
  46.                             c += 1
  47.                             """ print("Compraing this:", field[x][y + i])
  48.                            print("c:", c)
  49.                            print("x:", x, "y:", y + (i + 1))
  50.                            print("symb:", symbol) """
  51.                 if c >= win_condition + 1:
  52.                     return print_winner(symbol)
  53.     #print(c)
  54.     return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement