0

I am trying to create the chaos game. I have an if statement that calls the diffrent chaos things and makes the points to plotg them. But i think there is something wrong with my if statement.

I am at a lost for what to try...

#This 'makes' the diffrent fractals
def make(self, fractal):
    if (fractal == "SierpinskiTriangle"):
        SierpinskiTriangle(self.dimensions)
        for i in range(len(SierpinskiTriangle.verticies)):
            plotPoint(i, self.vertexColor, self.vertexRadius)
        for i in range(SierpinskiTriangle.numPoints):
            listVertices = SierpinskiTriangle.verticies
            randVert = randint(0, len(listVertices)-1)
            newVertexPoint = listVertices[randVert]
            m1 = Point.midpt(m1, newVertexPoint)
            self.plot(m1)

    elif (fractal == "SierpinskiCarpet"):
        SierpinskiCarpet(self.dimensions)
        for i in range(len(SierpinskiCarpet.verticies)):
            plotPoint(i, self.vertexColor, self.vertexRadius)
        for i in range(SierpinskiCarpet.numPoints):
            listVertices = SierpinskiCarpet
            randVert = randint(0, len(listVertices)-1)
            newVertexPoint = listVertices[randVert]
            m1 = Point.midpt(m1, newVertexPoint)
            self.plot(m1)

    else:
        Pentagon(self.dimensions)
        for i in range(len(Pentagon.verticies)):
            plotPoint(i, self.vertexColor, self.vertexRadius)
        for i in range(Pentagon.numPoints):
            listVertices = SierpinskiCarpet
            randVert = randint(0, len(listVertices)-1)
            newVertexPoint = listVertices[randVert]
            m1 = Point.midpt(m1, newVertexPoint)
            self.plot(m1)

I expect this to call my classes and plot my points.

  • 1
    You are creating instances of your classes but not assigning them to a variable and are then using the classes class attributes for plotting your points. You almost definitely didn't intend this? `SierpinskiTriangle(self.dimensions); for i in range(len(SierpinskiTriangle.verticies)):` should probably be `triangle = SierpinskiTriangle(self.dimensions); for i in range(len(triangle.verticies)):`? – Iain Shelvington Nov 03 '19 at 04:37
  • 1
    Try to simplify your question with an example. If you are going to post the whole code. Explain it and provide the error. – Vedant Nov 03 '19 at 04:38

0 Answers0