import numpy as np import matplotlib.pyplot as plt import lsystem as ls L1 = ls.genere({"A": "A−B+A+B−A", "B": "BB"}, "A−B−B", 1) print("L1 = " + L1) assert(L1 == "A−B+A+B−A−BB−BB") L2 = ls.genere({"A": "A−B+A+B−A", "B": "BB"}, "A−B−B", 2) assert(L2 == "A−B+A+B−A−BB+A−B+A+B−A+BB−A−B+A+B−A−BBBB−BBBB") plt.close('all') t = ls.Tortue(0) for i in range(4): t.avance(20) t.tourne(np.pi/2) plt.show() plt.close('all') t = ls.Tortue(0) s = ls.genere({"A":"A-B+A+B-A", "B":"BB"},"A−B−B", 5) t.trace(s,2*np.pi/3) plt.show() plt.close('all') t = ls.Tortue(0) s = ls.genere({"A":"A-A++A-A", "B":"BB"},"A++A++A", 4) t.trace(s,np.pi/3) plt.show() plt.close('all') t = ls.Tortue(0) s = ls.genere({"A":"A[+A]A[-A]A"},"A", 3) t.trace(s,22*np.pi/180) plt.show() plt.close('all') t = ls.Tortue(0) s = ls.genere({"A":"B[+A][-A]BA", "B":"BB"},"A", 4) t.trace(s,25*np.pi/180) plt.show() plt.close('all') t = ls.Tortue(0) s = ls.genere({"A":"A+b-AA+A+AA+Ab+AA-B+AA-A-AA-Ab-AAA", "b":"bbb"},"A", 2) t.trace(s,np.pi/2) plt.show() plt.close('all') for i in range(5): t = ls.Tortue(0, i) s = ls.genere3({"A":[(2,"A[+A]A[-A]A"), (1,"A[+A]A"), (1,"A[-A]A")]},"A", 5) t.trace(s,np.pi/6) plt.show()