Fractals Generated through the Chaos Game: A Study of Iterated Function Systems, the Barnsley Fern, the Collage Theorem, and the Dragon Curve

Abstract

Chaos Game is an easy-to-implement random algorithm that can create highly complex and structured fractals. This paper is devoted to the mathematical and computational analysis of the Chaos Game based on the ideas of Iterated Function Systems (IFS). We will present a brief overview of the main notions of IFS-attractors and Barnsley’s Collage Theorem and discusses their application to the description of the emergence of the classic Chaos Game algorithm with three points to the Sierpinski triangle. Then we will show how the algorithm of the Chaos Game can be expanded to work with non-uniform affine transformations (for generating the Barnsley fern) and to include transformations with rotations (for creating dragon curves). We also consider fractals created with different numbers of reference points ( n=3,4,6,8 ) , including fractals associated with the Sierpinski carpet.

Share and Cite:

Akter, R. , Afroz, S. , Akter, T. and Ahmed, P. (2026) Fractals Generated through the Chaos Game: A Study of Iterated Function Systems, the Barnsley Fern, the Collage Theorem, and the Dragon Curve. Journal of Applied Mathematics and Physics, 14, 4516-4528. doi: 10.4236/jamp.2026.1411222.

1. Introduction

Over the past several decades, a field of mathematics broadly known as non-linear dynamics, or the theory of chaotic dynamical systems, has developed around the study of complex curves called fractals. These objects are, in a precise mathematical sense, infinitely detailed: successive magnification of any region reveals structure that never resolves into simplicity. Fractals entered popular scientific awareness largely through expository articles such as those of A. K. Dewdney in Scientific American, which made the subject accessible beyond specialist mathematical audiences [1].

There is a deep structural link between fractals and chaos: both arise from iterated functions, in which the state produced by one iteration becomes the input to the next. Some chaotic systems, such as bifurcation diagrams, display exact self-similarity under magnification, while other, more asymmetric fractals can appear visually irregular even though they retain a well-defined self-similar structure. A common feature of chaotic iteration is unpredictability at the level of an individual step: the value produced by a specific iteration cannot, in general, be anticipated without explicitly computing every preceding iteration. In this sense, fractals may be described as a form of ordered, or “beautiful,” chaos -globally structured, yet locally unpredictable.

Theoretical investigation of IFS has its roots in the seminal work of Hutchinson on self-similarity and contraction mappings [2] that later became widely known due to Barnsley’s geometric formulation of IFS and the collage theorem [3] as well as its placement into the context of the fractal geometry program developed by Mandelbrot [4], Falconer [5], and in expository works such as [1] [6]. Continuing this line of research, recent investigations have been carried out in the following directions: algorithmic and probabilistic analysis of chaos game and convergence issues, involving both classical chaos game and its generalizations (standard and disjunctive) along with fuzzy IFS [7]-[9]; quantitative research of contraction ratios and fractal dimension for special families of attractors including Sierpinski n-gons, fractal functions in function spaces, and continued-fraction sets [10]-[12]; extension of the classical Hutchinson-Barnsley scheme onto arbitrary shift spaces, multivalued mappings in neutrosophic metric spaces, and unifying fractal interpolation schemes [13]-[15]; advances in multifractal analysis of inhomogeneous measures under the action of non-doubling projections [16]; application of fractal and fractional descriptors in modeling of material microstructure [17]. A fractal is a mathematically created geometric figure that displays scale invariance: rising into or out of any segment reproduces a structure identical or fundamentally similar to the unique whole [18]. The overall trend of recent research is that of a transition from geometric to computational, probabilistic, and abstract generalization aspects of IFS theory.

Thus, justifying the choice of focus for this research, this paper examines one particular route from randomness to structure: the Chaos Game, and its formalisation as the attractor of an Iterated Function System (IFS). Section 2 introduces the Chaos Game and its classical three-point realisation. Section 3 develops the necessary mathematical framework of IFS theory. Section 4 states Barnsley’s Collage Theorem, which explains why the Chaos Game works. Section 5 describes representative computational implementations. Section 6 presents results and discussion, including the Barnsley fern, the dragon curve, and a generalised n-point Chaos Game, and Section 7 concludes.

2. The Chaos Game

Chaos Game Illustration assists as a powerful method for transforming linear sequence data into revealing visual patterns [19]. The Chaos Game is an algorithm that produces images of fractal structures using nothing more than paper and pencil or, more practically, a computer. The term was coined by the mathematician Michael Barnsley [3]. Notably, the relationship between the random, game-like procedure and the highly structured fractal image it produces is not obvious from the rules alone; there is no evident a priori connection between the two. This element of surprise is part of what makes the result mathematically interesting.

Classical Procedure

In its simplest form, the Chaos Game proceeds as follows. Three points (vertices of a triangle) are fixed in the plane, and an arbitrary starting point is chosen. On each iteration, one of the three vertices is selected at random (for example, by rolling a die and mapping the result onto the three vertices), and the current point is replaced by the midpoint between itself and the selected vertex. This process is then repeated many times.

Intuitively, one might expect that this procedure, repeated indefinitely, would produce a triangle filled uniformly with random dots. This is not the case. When the Chaos Game is implemented on a computer using a pseudo-random number generator for the vertex selection and run for several thousand iterations, the resulting point cloud is not uniform at all: it converges to the well-known Sierpinski triangle (Figure 1), named after the mathematician Wacław Sierpiński, who first described the set.

Figure 1. The attractor produced by the classical three-point Chaos Game: The Sierpinski triangle.

3. Mathematical Formalism: Iterated Function Systems

Barnsley’s Chaos Game exploits the self-similar structure of fractals by using a random walk procedure to plot points of the attractor of a given Iterated Function System (IFS). To make this precise, we require the following definitions.

3.1. Iterated Function Systems

We restrict attention to affine iterated function systems. An iterated function system (IFS) M on a complete metric space ( X,d ) where X= ℝ 2 and d( x,y )= ‖ x−y ‖ 2 is the Euclidean distance, is a finite set of affine contraction map pings M={ f 1 , f 2 ,⋯, f N } , f i :X→X . Each mapping takes the affine form f i ( x )= A i x+ b i , where A i ∈ ℝ 2×2 and b i ∈ ℝ 2 . The map f i is a contraction with respect to d if the eigenvalues λ i,1 , λ i,2 of A i satisfy | λ i,j |<1 for j=1,2 ensuring that every f i strictly contracts distances.

3.2. The Attractor of an Iterated Function System

The term attractor is reserved exclusively for the unique non-empty compact set A⊂X invariant under M , satisfying A= ∪ i=1 N f i ( A ) . Any finite set of points used to seed or generate an approximation of A should be referred to as reference vertices or seed points, not as the attractor.

3.3. The Chaos Game: Precise Statement

Let ( X,d ) be a compact metric space (here X⊂ ℝ 2 is a compact set with w i ( X )⊂X ). Let w 1 ,⋯, w N :X→X be contractions with Lipschitz constants r i ≤r<1 . Let A be the attractor, i.e. the unique non empty compact set with A= ∪ i w i ( A ) .

(H1) Contractivity. Each w i is a contraction, as above.

(H2) Map selection. The indices σ 1 , σ 2 ,⋯∈{ 1,2,⋯,N } are independent and identically distributed, independent of x 0 , with P( σ n =i )= p i and p i >0 for every i , ∑ i p i =1 .

The chaos game is x n = w σ n ( x n−1 )=( w σ n ∘⋯∘ w σ 1 )( x 0 ) .

Let μ be the unique Borel probability measure with μ= ∑ i p i ( w i ) #μ . It is supported on A . Note that A depends only on the maps, while μ also depends on ( p i ) .

Theorem

Assume (H1) and (H2). Then for every starting point x 0 ∈X :

a) Convergence of the sampled points (forgetting and attraction).

For every realization ( σ n ) and any two starting points x 0 , y 0 ,

d( x n , y n )≤ r n d( x 0 , y 0 ).

Moreover, dist( x n ,A )≤ r n dist( x 0 ,A ) , and if x 0 ∈A then x n ∈A for all n . Also, the law of x n converges to μ in Wasserstein distance: W 1 ( Law( x n ),μ )≤ r n ∫ d( x 0 ,y )dμ( y ) .

b) Orbit density (topological statement).

Almost surely, the set of accumulation points of x n is A . Equivalently, for every a∈A and ε>0 , x n ∈B( a,ε ) for infinitely many n. In particular, if x 0 ∈A then { x n } is dense in A almost surely.

c) Convergence of the sampled measure (statistical statement).

Let v n = 1 n ∑ k=0 n−1 δ x k . Almost surely, v n →μ weakly, i.e. 1 n ∑ k=0 n−1 f( x k ) → ∫ f dμ for all continuous f .

4. Barnsley’s Collage Theorem

The Chaos Game solves the forward problem: given an IFS, find (a picture of) its attractor. Barnsley’s Collage Theorem addresses the inverse problem: given a target image, find an IFS whose attractor approximates it.

4.1. Theorem (The Collage Theorem)

Let ( X,d ) be a complete metric space, and let H( X ) be the space of nonempty compact subsets of X , equipped with the Hausdorff metric h . Consider a finite iterated function system M={ w 1 ,⋯, w N } and its Hutchinson operator

W( B )= ∪ i=1 N w i ( B ).

Suppose W is contractive with factor s∈[ 0,1 ) , meaning

h( W( B ),W( C ) )≤sh( B,C ) for all B,C∈H( X ).

For example, if the maps w i have Lipchitz constants s i <1 , one may take s= max i s i .

Let A be the unique attractor satisfying W( A )=A . Then, for every target set L∈H( X ) , h( L,A )≤ h( L,W( L ) ) 1−s .

Consequently, if the collage error satisfies h( L,W( L ) )≤ε , then h( L,A )≤ ε 1−s .

To guarantee an attractor approximation error of at most δ , it therefore suffices to require h( L,W( L ) )≤( 1−s )δ .

4.2. Illustrative Example: The Sierpinski Triangle as a Collage

The Sierpinski triangle provides the simplest non-trivial illustration of the Collage Theorem. Placing a vertex of the triangle at the origin, the triangle can be exactly tiled by three smaller copies of itself, each scaled by a factor of one-half and positioned at each of the three corners (Figure 2). Each of the three smaller triangles has exactly half the vertical and horizontal extent of the whole. Reading these three placements directly as the three affine contraction maps of an IFS reproduces exactly the classical three-point Chaos Game of Section 2, now derived rigorously from the collage geometry of the target shape rather than assumed ad hoc.

(a) (b)

Figure 2. The Sierpinski triangle as a self-tiling collage of three half-scale copies of itself, illustrating the Collage Theorem.

5. Computational Implementation

The Chaos Game was implemented in MATLAB. The program proceeds in three stages: (i) initialise the set of reference vertices and a starting point; (ii) repeatedly select a vertex at random, with all vertices equally likely and each selection independent of the previous ones, and move the current point x to x ′ =r⋅x( 1−r )⋅ v i where v i is the selected vertex and r is the contraction ratio ( r=1/2 gives the midpoint rule of the Sierpinski triangle; other values of r are used in Section 6); (iii) plot the accumulated set of points. For the Barnsley fern and the dragon curve, step (ii) instead applies one of the affine maps given in Section 6, chosen independently with the stated probabilities.

The program does not use graphical animation: all retained points are plotted once the iteration loop has completed, and the number of iterations is supplied interactively by the user. The implementation was validated by checking that, for n=3 and r=1/2 , the output reproduces the Sierpinski triangle. It was then extended to the more general cases discussed in Section 6.

6. Results and Discussion

6.1. Chaos Game Output for the Sierpinski Triangle

Figure 3 illustrates the progressive formation of the Sierpinski triangle generated via the iterative Chaos Game algorithm ( n=3 , r=1/2 ), demonstrating the emergence of deterministic fractal structure from an underlying stochastic process. Beginning with n=3 fixed corner vertices that define a triangle, an initial point is iteratively moved half the distance toward a randomly selected vertex at each step. The sequence captures the transition from an early phase characterized by a sparse point distribution after N≈500 iterations (Figure 3(a)) to an intermediate phase where sub-triangular clusters and inverted void regions emerge ( N≈2500 ; Figure 3(b)), culminating in a dense, highly detailed representation of the self-similar attractor after N≥10000 iterations (Figure 3(c)).

(a)

(b) (c)

Figure 3. Sequential formation of the Sierpinski triangle fractal via the Chaos Game algorithm.

6.2. The Barnsley Fern

The Barnsley fern is the attractor of a four-map affine IFS. In the Sierpinski triangle all maps are chosen with equal probability, but here each map is assigned a different selection probability. One map (probability about 1%) generates the central stem. The remaining maps generate the main frond and the successively smaller left- and right-leaning leaflets, each contracted and rotated by a different affine transformation (Figure 4).

The affine maps determine the geometric attractor, that is, the shape of the fern. As long as every p i >0 , any choice of probabilities yields the same set. The selection probabilities, by contrast, determine the sampled invariant measure, which governs how many points land in each part of the fern and therefore how dense it looks in the plot. The values 0.01, 0.85, 0.07, 0.07 are Barnsley’s standard empirical choice, which makes the fern clearly visible with reasonably even density after relatively few points. They are not derived from the maps’ relative area contraction (Figure 5).

Figure 4. The Barnsley fern, the attractor of a four-map affine iterated function system.

Figure 5. The Barnsley fern rendered by the Chaos Game with non-uniform map-selection probabilities weighted by relative contraction area.

6.3. The Dragon Curve: Introducing Rotation

The dragon curve fractal extends the Chaos Game to an IFS whose maps combine contraction with rotation (see Figure 6). The dragon curve is composed of two smaller copies of itself, but unlike the Sierpinski triangle, these copies are related to the whole not merely by scaling and translation but also by a rotation. Each copy is obtained by rotating the curve through a fixed angle θ about the origin, contracting it by a factor of 1/ 2 , and applying a horizontal offset of +1 or −1 to obtain the two respective smaller curves. The corresponding rotation matrix follows directly from elementary linear algebra. Equal selection probabilities ( p 1 = p 2 =0.5 ) are assigned to the two affine maps.

Figure 6. The dragon curve, the attractor of a two-map iterated function system incorporating rotation.

As the Chaos Game plots the orbit of this two-map IFS, the dragon curve gradually emerges (Figure 7); points are naturally colourable according to which of the two affine maps was selected at each step, visually distinguishing the two self-similar halves of the curve [6].

Figure 7. The Chaos Game plotting the dragon curve; the left panel colours points by the affine map selected at each iteration, while the centre and right panels show the same attractor in a single colour at increasing iteration counts.

6.4. A Generalised n-Point Chaos Game

Figure 8 demonstrates the structural dependence of the Iterated Function System (IFS) attractor on the contraction ratio r for an n=3 vertex system. In Panel A, applying a scaling factor r<0.5 results in a disconnected fractal structure consisting of isolated, self-similar triangular clusters separated by clear voids. Conversely, in Panel B, increasing the contraction factor to r>0.5 causes the sub-attractor regions corresponding to each vertex (color-coded red, green, and blue) to overlap, yielding a denser, continuous triangular distribution with overlapping sub-structures.

Figure 8. Chaos game attractors for n=3 reference vertices after N=50000 iterations under two different parameter settings: (a) a disconnected Cantor-like fractal formed with a reduced scaling factor ( r=0.38<0.5 ), and (b) an overlapping continuous attractor generated with an increased scaling factor r=0.62>0.5 ).

Figure 9(a) illustrates Chaos Game attractors for n=4 reference vertices using a contraction factor of r=0.5 . In Panel A, placing the four vertices at the corners of a square with unrestricted random vertex selection results in a solid, space-filling square split into four equal quadrant regions (color-coded cyan, red, green, and blue). In Panel B, altering the vertex geometry to a trapezoidal layout reveals a complex fractal pattern with self-similar, triangular voids distributed across all four colored regions.

Figure 9(b) depicts the Sierpinski Carpet fractal attractor generated via an 8-transformation Chaos Game system ( n=8 ) with a contraction factor of r=1/3 after N=50000 iterations. The square domain is partitioned into a 3×3 grid, where eight perimeter vertices/sub-regions are assigned as target maps, leaving the central square empty. Points are color-coded according to the chosen transformation at each step, clearly illustrating the eight self-similar, recursively perforated sub-carpets that collectively form the overall fractal structure.

Figure 9. (a): Chaos Game attractors generated with n=4 reference vertices and a contraction factor of r=0.5 after N=50000 iterations. (b): Chaos Game generation of the Sierpinski Carpet fractal ( n=8 , r=1/3 ) after N=50000 iterations.

Figure 10 depicts the Hexagasket fractal attractor generated via a 6-vertex Chaos Game algorithm ( n=6 ) with a contraction scaling factor of r=1/3 after N=50000 iterations. Positioning six reference vertices at the corners of a regular hexagon creates a ring of six self-similar sub-hexagons surrounding a central void. The six distinct colors (red, orange, magenta, cyan, green, and blue) delineate the attractor sub-regions corresponding to each target vertex, illustrating the recursive, self-similar structure at multiple spatial scales.

Figure 10. Chaos Game generation of the Hexagasket fractal ( n=6 , r=1/3 ) after N=50000 iterations.

7. Conclusion

In this article, the mathematics and computation underlying the Chaos Game have been unified into a rigorous treatment of the technique as a means of rendering IFS attractors. Beginning with Barnsley’s original construction using three points and its counter-intuitive emergence into the Sierpinski triangle, the formalism of complete metric spaces, affine contraction mappings, and attractors of IFSes was introduced and used to prove the convergence. In addition, it was shown that the Collage Theorem provides a method to construct an IFS that approximates a predetermined object via its attractor. The examples of using probability weights and adding rotation operations to affine mappings showed the power of the framework in its generality, whereas the generalized n-point Chaos Game allowed us to consider the classical Sierpinski carpet in terms of polygon-based attractors. Collectively, these findings reaffirm one of the main concepts of fractal geometry: namely, chaotic and unpredictable processes at the local level can produce highly deterministic and structured objects governed solely by a few contraction and probability parameters.

Future work can proceed with the framework described here and calculate fractal dimensions numerically.

Author Contributions

Conceptualization, R.A., S.A. and P.A.; methodology, R.A. and T.A.; software, R.A. and P.A.; validation, R.A., S.A. and T.A.; formal analysis, R.A. and S.A.; investigation, R.A.; resources, R.A.; data curation, R.A. and T.A.; writing—original draft preparation, R.A., S.A. and T.A.; writing—review and editing, R.A., and S.A.; visualization, S.A. and P.A.; supervision, P.A.; project administration, R.A.. All authors have read and agreed to the published version of the manuscript.

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.

References

[1] Dewdney, A.K. (1985) Computer Recreations Columns on Fractal Geometry. Scientific American, 253, 16-25.
[2] Hutchinson, J.E. (1981) Fractals and Self-Similarity. Indiana University Mathematics Journal, 30, 713-747.[CrossRef]
[3] Barnsley, M.F., Rising, H. and Barnsley, M.F. (1993) Fractals Everywhere (Vol. 2). Academic Press.
[4] Garg, A. and Negi, A. (2014) A Review on Natural Phenomenon of Fractal Geometry. International Journal of Computer Applications, 86, 1-7.
[5] Falconer, K. (2013) Fractal Geometry: Mathematical Foundations and Applications. Wiley.
[6] Peitgen, H.O., Jürgens, H., Saupe, D. and Feigenbaum, M.J. (2004) Chaos and Fractals: New Frontiers of Science. 2nd Edition, Springer.
[7] Kolenda, M., Strobin, F. and Wiśniewski, K. (2025) Chaos Game Algorithm for Fuzzy Iterated Function Systems. Fuzzy Sets and Systems, 500, Article 109173.[CrossRef]
[8] Leśniak, K., Snigireva, N. and Strobin, F. (2022) Rate of Convergence in the Disjunctive Chaos Game Algorithm. Chaos: An Interdisciplinary Journal of Nonlinear Science, 32, Article 013107.[CrossRef] [PubMed]
[9] Morris, I.D. and Jurga, N. (2021) How Long Is the Chaos Game? Bulletin of the London Mathematical Society, 53, 1749-1765.[CrossRef]
[10] Abdulaziz, A. and Said, J. (2021) On the Contraction Ratio of Iterated Function Systems Whose Attractors Are Sierpinski n-gons. Chaos, Solitons & Fractals, 150, Article 111140.[CrossRef]
[11] Chandra, S. and Abbas, S. (2022) On Fractal Dimensions of Fractal Functions Using Function Spaces. Bulletin of the Australian Mathematical Society, 106, 470-480.[CrossRef]
[12] Fang, L., Moreira, C.G. and Zhang, Y. (2024) Fractal Geometry of Continued Fractions with Large Coefficients and Dimension Drop Problems. arXiv:2409.00521.[CrossRef]
[13] Ahmadi Dastjerdi, D. and Aghaee, M. (2023) Iterated Function Systems over Arbitrary Shift Spaces. Khayyam Journal of Mathematics, 9, 127-143.
[14] Pasupathi, R. and Miculescu, R. (2024) A Very General Framework for Fractal Interpolation Functions. Journal of Mathematical Analysis and Applications, 534, Article 128093.[CrossRef]
[15] Saleem, N., Ahmad, K., Ishtiaq, U. and de la Sen, M. (2023) Multivalued Neutrosophic Fractals and Hutchinson-Barnsley Operator in Neutrosophic Metric Space. Chaos, Solitons & Fractals, 172, Article 113607.[CrossRef]
[16] Selmi, B., Shen, S. and Yuan, Z. (2025) Multifractal Analysis of Inhomogeneous Multinomial Measures with Non-Doubling Projections. Fractals, 33, Article 2550027.[CrossRef]
[17] Wang, L. and Tang, S. (2025) Fractal and Fractional in Construction Materials. Fractal and Fractional, 9, Article 785.[CrossRef]
[18] Lefler, S. (2006) Fractals and the Chaos Game. MAT Exam Expository Papers, 24.
https://digitalcommons.unl.edu/mathmidexppap/24
[19] Chan, E.Y.S. and Corless, R.M. (2023) Chaos Game Representation. SIAM Review, 65, 261-290.[CrossRef]

Copyright © 2026 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.