import numpy as np import matplotlib.pyplot as plt def apply_rule(rule, state, pos): left = state[pos - 1] center = state[pos] right = state[(pos + 1) % len(st…