MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / display

Method display

cellular_automata/langtons_ant.py:86–98  ·  view source on GitHub ↗

Displays the board without delay in a matplotlib plot to visually understand and track the ant. >>> _ = LangtonsAnt(WIDTH, HEIGHT)

(self, frames: int = 100_000)

Source from the content-addressed store, hash-verified

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
101if __name__ == "__main__":

Callers 1

langtons_ant.pyFile · 0.45

Calls 1

showMethod · 0.80

Tested by

no test coverage detected