philRG

shadows calculation

May 12th, 2021 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1.     def count_shadows(self, tree: Tree):
  2.         cell: Cell = self.board[tree.cell_index]
  3.         shadows = 0
  4.         for day in range(6):
  5.             distance = 0
  6.             is_shadow = False
  7.             c: Cell = self.board[tree.cell_index]
  8.             while distance < 3:
  9.                 c: Cell = self.board[c.neighbors[day]]
  10.                 t: Tree = self.get_tree(c.cell_index)
  11.                 if t and t.cell_index >= 0 and t.size > distance and t.size >= tree.size:
  12.                     is_shadow = True
  13.                 distance += 1
  14.             if is_shadow: shadows += 1
  15.         return shadows
Add Comment
Please, Sign In to add comment