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

Method __init__

cellular_automata/langtons_ant.py:28–35  ·  view source on GitHub ↗
(self, width: int, height: int)

Source from the content-addressed store, hash-verified

26 """
27
28 def __init__(self, width: int, height: int) -> None:
29 # Each square is either True or False where True is white and False is black
30 self.board = [[True] * width for _ in range(height)]
31 self.ant_position: tuple[int, int] = (width // 2, height // 2)
32
33 # Initially pointing left (similar to the wikipedia image)
34 # (0 = 0° | 1 = 90° | 2 = 180 ° | 3 = 270°)
35 self.ant_direction: int = 3
36
37 def move_ant(self, axes: plt.Axes | None, display: bool, _frame: int) -> None:
38 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected