(y, x, get_cell)
| 141 | |
| 142 | |
| 143 | def count_neighbors(y, x, get_cell): |
| 144 | n_ = get_cell(y - 1, x + 0) # North |
| 145 | ne = get_cell(y - 1, x + 1) # Northeast |
| 146 | e_ = get_cell(y + 0, x + 1) # East |
| 147 | se = get_cell(y + 1, x + 1) # Southeast |
| 148 | s_ = get_cell(y + 1, x + 0) # South |
| 149 | sw = get_cell(y + 1, x - 1) # Southwest |
| 150 | w_ = get_cell(y + 0, x - 1) # West |
| 151 | nw = get_cell(y - 1, x - 1) # Northwest |
| 152 | neighbor_states = [n_, ne, e_, se, s_, sw, w_, nw] |
| 153 | count = 0 |
| 154 | for state in neighbor_states: |
| 155 | if state == ALIVE: |
| 156 | count += 1 |
| 157 | return count |
| 158 | |
| 159 | def simulate_pipeline(grid, in_queue, out_queue): |
| 160 | for y in range(grid.height): |
no test coverage detected