Displays the board without delay in a matplotlib plot to visually understand and track the ant. >>> _ = LangtonsAnt(WIDTH, HEIGHT)
(self, frames: int = 100_000)
| 84 | axes.imshow(self.board, cmap="gray", interpolation="nearest") |
| 85 | |
| 86 | def display(self, frames: int = 100_000) -> None: |
| 87 | """ |
| 88 | Displays the board without delay in a matplotlib plot |
| 89 | to visually understand and track the ant. |
| 90 | |
| 91 | >>> _ = LangtonsAnt(WIDTH, HEIGHT) |
| 92 | """ |
| 93 | fig, ax = plt.subplots() |
| 94 | # Assign animation to a variable to prevent it from getting garbage collected |
| 95 | self.animation = FuncAnimation( |
| 96 | fig, partial(self.move_ant, ax, True), frames=frames, interval=1 |
| 97 | ) |
| 98 | plt.show() |
| 99 | |
| 100 | |
| 101 | if __name__ == "__main__": |