Nov-02-2018, 01:04 PM
You don't need recursion for this, you just need another loop.
start = [x, y] all_data = [] for direction in [(0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)]: data = [] current = start[:] for step in depth: data.append(self.grid[current [0]][current [1]] current = [current[0] + direction[0], current[1] + direction[1]] if not (0 <= current[0] < len(self.grid)) or not (0 <= current[1] < len(self.grid[0])): break all_data.append(data)I didn't test the above code, but that's the basic format you want. Loop through the directions. For each direction go back to the start and step in that direction depth times. For each step, record the data at that point and check that you haven't gone off the edge of the grid.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures