# 混沌游戏

混沌游戏是一种迭代算法，它通过反复将绘图点向随机选取的多边形顶点移动固定比例的距离来生成分形图像。尽管每一步都是随机的，点序列却最终稳定在一个确定性的分形集合上，即迭代函数系统（IFS）的吸引子。该算法归功于迈克尔·F·巴恩斯利（Michael F. Barnsley）1988年的教科书《无处不在的分形》（*Fractals Everywhere*）<sup>[1](https://mathworld.wolfram.com/ChaosGame.html)</sup><sup> • </sup><sup>[2](https://ar5iv.labs.arxiv.org/html/2007.11517)</sup>，除了绘制分形之外，它还是生物信息学中DNA和蛋白质序列的混沌游戏表示（CGR）的基础。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心规则 | 新点 \( p_{n} = (1-r)\,p_{n-1} + r\,v \)，其中 \( v \) 为随机选取的顶点，\( r \) 为跳跃比<sup>[4](https://arun.chagantys.org/articles/chaos-game/)</sup> |
| 经典情形 | 三角形配合 \( r = 1/2 \) 生成谢尔宾斯基三角形<sup>[4](https://arun.chagantys.org/articles/chaos-game/)</sup> |
| 为何有效 | 轨道的经验分布几乎必然收敛到IFS不变测度 \( m = \sum_{i=1}^{N} p_{i}(S_{i})_{*}m \)<sup>[2](https://ar5iv.labs.arxiv.org/html/2007.11517)</sup> |
| 预热 | 丢弃最初若干点以减少初始瞬态，使轨道更接近吸引子；对某些参数选择而言，丢弃10–20个点在实践中已足够<sup>[4](https://arun.chagantys.org/articles/chaos-game/)</sup> |
| 实用规模 | 约50,000个点即可得到可辨认的谢尔宾斯基图案；高质量渲染使用约50万个点<sup>[5](https://ar5iv.labs.arxiv.org/html/2012.09638)</sup><sup> • </sup><sup>[6](https://chaotic-fractals.mpi-inf.mpg.de/Chaotic_Fractals.pdf)</sup> |
| 生物信息学用途 | CGR将DNA映射到以A、C、G、T为顶点的正方形上，产生序列特异性的分形图案<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup> |
| 效率 | 混沌游戏是两种标准IFS渲染算法中更高效的一种，内存占用低<sup>[7](https://link.springer.com/article/10.1007/s13373-013-0041-3)</sup> |

## 工作原理

每一步移动施加一组固定压缩映射中的一个。压缩映射 \( S \) 在其定义域内对所有 \( x, y \) 满足 \( |S(x) - S(y)| \le c\,|x - y| \)，其中 \( c < 1 \)；若等号成立，则 \( S \) 为压缩相似映射。<sup>[8](https://www.ma.ic.ic.ac.uk/~jswlamb/M345PA46/F03%20chap%209.pdf)</sup> 将笔移向顶点一半距离，等价于将整幅图像缩小为原来的1/2并向该顶点平移，因此游戏每一步随机施加一个仿射压缩映射。<sup>[9](https://chaosgame.drwhy.ai/chaos-game-1.html)</sup>

形式上，指标 \( i_n \) 从概率向量 \( (p_1, \dots, p_N) \) 中独立抽取，轨道服从 \( x_{n} := S_{i_{n}}\,x_{n-1} \)。<sup>[2](https://ar5iv.labs.arxiv.org/html/2007.11517)</sup> 由映射 \( S_i \) 构成的IFS本身是图像空间上的一个压缩映射，因此根据压缩映射定理，它具有唯一不动点，即分形吸引子 \( \Lambda = \bigcup_{i=1}^{N} S_{i}(\Lambda) \)。<sup>[10](http://www.sfu.ca/~rpyke/chaosgame.pdf)</sup><sup> • </sup><sup>[11](https://ar5iv.labs.arxiv.org/html/2102.02047)</sup> 轨道的经验测度几乎必然收敛到支撑在吸引子上的唯一不变测度 \( m = \sum_{i=1}^{N} p_{i}(S_{i})_{*}m \)，这正是随机过程能够绘制出确定性集合的原因。<sup>[2](https://ar5iv.labs.arxiv.org/html/2007.11517)</sup> 无论起点如何，吸引子几乎必然作为轨道的ω-极限集而获得。<sup>[11](https://ar5iv.labs.arxiv.org/html/2102.02047)</sup> 所赋概率 \( p_i \) 不影响吸引子的形状，只调节收敛速率和局部点密度。<sup>[6](https://chaotic-fractals.mpi-inf.mpg.de/Chaotic_Fractals.pdf)</sup> 一个一般性定理将其推广到压缩映射之外：若IFS具有吸引子 \( A \)，则从其吸引盆中出发的随机轨道以概率一收敛到 \( A \)，从而去掉了早期工作所要求的压缩或平均压缩条件。<sup>[12](https://www.cambridge.org/core/journals/ergodic-theory-and-dynamical-systems/article/abs/chaos-game-on-a-general-iterated-function-system/0AC751F2D51BE6666E94A03C78AF53E1)</sup>

## 操作步骤

实践者按以下几步实现该游戏<sup>[9](https://chaosgame.drwhy.ai/chaos-game-1.html)</sup><sup> • </sup><sup>[1](https://mathworld.wolfram.com/ChaosGame.html)</sup>：

1. 选择多边形顶点（或IFS映射）和跳跃比 \( r \)；三角形配合 \( r = 1/2 \) 生成谢尔宾斯基三角形。<sup>[4](https://arun.chagantys.org/articles/chaos-game/)</sup>
2. 在任意位置初始化一个点；\( x_0 \) 的选择无关紧要。<sup>[9](https://chaosgame.drwhy.ai/chaos-game-1.html)</sup>
3. 每一步随机选取一个顶点，按 \( x \leftarrow x + r\,(v_x - x) \)、\( y \leftarrow y + r\,(v_y - y) \) 更新坐标。<sup>[13](https://beltoforion.de/en/recreational_mathematics/chaos_game.php)</sup>
4. 丢弃前10–20个点作为预热，因为远离吸引子的起点需要几步才能落到吸引子上。<sup>[4](https://arun.chagantys.org/articles/chaos-game/)</sup><sup> • </sup><sup>[9](https://chaosgame.drwhy.ai/chaos-game-1.html)</sup>
5. 绘制剩余的点；约50,000个点即可产生类谢尔宾斯基图案，高质量稳定渲染使用约50万个点。<sup>[5](https://ar5iv.labs.arxiv.org/html/2012.09638)</sup><sup> • </sup><sup>[6](https://chaotic-fractals.mpi-inf.mpg.de/Chaotic_Fractals.pdf)</sup>

跳跃比 \( r \) 决定新点落在通向顶点的线段上的位置：\( r = 0.5 \) 为中点，\( r < 0.5 \) 更靠近当前点，\( r > 0.5 \) 更靠近顶点。<sup>[5](https://ar5iv.labs.arxiv.org/html/2012.09638)</sup> 在一般形式 \( p_{i+1} = p_{i} + r\,(V - p_{i}) \) 中，点甚至可能被置于凸包之外，从而改变吸引子。<sup>[14](https://computational-discovery-on-jupyter.github.io/Computational-Discovery-on-Jupyter/Contents/chaos-game-representation.html)</sup>

## 起源

巴恩斯利在1988年的教科书《无处不在的分形》中引入了混沌游戏，作为一种生成分形的随机方法。<sup>[2](https://ar5iv.labs.arxiv.org/html/2007.11517)</sup><sup> • </sup><sup>[1](https://mathworld.wolfram.com/ChaosGame.html)</sup> 这一框架建立在更早的工作之上：斯蒂芬·登科（Stephen Demko）、劳里·霍奇斯（Laurie Hodges）和布鲁斯·奈勒（Bruce Naylor）1985年发表于ACM SIGGRAPH的论文表明，由有限个带有相应概率的压缩仿射变换组成的族确定了一个具有唯一紧吸引子的IFS，该吸引子通常是一个分形集合。<sup>[15](https://doi.org/10.1145/325165.325245)</sup> 1988年的教科书提供了逐点绘制此类吸引子的随机迭代算法，并以谢尔宾斯基三角形作为标准示例。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup>

## 变体

该构造适用于任何多边形，但跳跃因子必须随角数增加而调整。向正方形随机选取的角移动一半距离会均匀填充正方形，而非产生分形。<sup>[13](https://beltoforion.de/en/recreational_mathematics/chaos_game.php)</sup><sup> • </sup><sup>[5](https://ar5iv.labs.arxiv.org/html/2012.09638)</sup> 在缩放因子为0.5时，是否出现清晰可见的图案取决于多边形及其规则；例如，三角形配合该因子生成可见的谢尔宾斯基三角形，而并不存在通用的顶点数阈值。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup>

两种实现形式有所区分：概率混沌游戏，每次迭代按所赋概率随机抽取一个变换；以及确定性混沌游戏或称析取混沌游戏，预先固定一个随机迭代顺序。<sup>[16](https://ar5iv.labs.arxiv.org/html/1506.07101)</sup> 扩展形式包括将蛋白质置于正十二面体中的三维CGR，用于蛋白质分类和系统发育分析<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup>，以及2025年在 \( n \) 维正多胞体上的广义混沌游戏，其更新式为 \( x_{c+1} = (1-r)\,x_{c} + r\,v_{i} \)，在二维情形下退化为标准多边形流程。<sup>[17](https://arxiv.org/html/2505.18669)</sup> 混沌游戏也是分形火焰算法的基础，后者是斯科特·德拉夫斯（Scott Draves）和埃里克·雷卡塞（Erik Reckase）于2004年提出的一种具有独特渲染风格的IFS变体。<sup>[18](https://jo.dreggn.org/2010_fractal_flames.pdf)</sup> 实际实现中还会加入限制规则，禁止选取某些顶点。<sup>[19](https://github.com/m-sarabi/chaos-game)</sup>

## 应用

CGR算法被应用于DNA，将三角形替换为正方形，其四个顶点分别代表腺嘌呤（A）、胞嘧啶（C）、鸟嘌呤（G）和胸腺嘧啶（T）；每个碱基将点向其顶点方向拉近一半距离。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup><sup> • </sup><sup>[20](https://link.springer.com/article/10.1186/s12864-024-11135-y)</sup> 因此，CGR是一张每个碱基对应一个点的散点图：随机序列均匀填充正方形，而真实DNA产生反映核苷酸、二核苷酸和三核苷酸频率的分形非随机图案。<sup>[21](https://pmc.ncbi.nlm.nih.gov/articles/PMC309551/)</sup><sup> • </sup><sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup> 其扩展形式FCGR将不同长度的序列转换为等尺寸的图像或矩阵。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup>

CGR可用作基因组签名，即区分近缘与远缘生物的量；CGR之间的距离（例如欧几里得距离）支持无比对序列比较和系统发育树构建。<sup>[20](https://link.springer.com/article/10.1186/s12864-024-11135-y)</sup> 应用涵盖无比对比较、系统发育、机器学习编码以及随机数生成器评估<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)</sup>，该技术也从DNA和RNA扩展到了蛋白质。<sup>[22](https://www.sciencedirect.com/science/article/abs/pii/S109332639700106X)</sup> CGRclust将CGR应用于无标签DNA序列的双重对比聚类。<sup>[20](https://link.springer.com/article/10.1186/s12864-024-11135-y)</sup> 在生物学之外，IFS吸引子计算支持具有分辨率无关缩放功能的分形图像压缩<sup>[23](https://www.ams.org/notices/199606/barnsley.pdf)</sup>，同一框架下的基于混沌的算法可合成云、雾、浪花、海景、风景和人脸的图像。<sup>[24](https://dl.acm.org/doi/10.1145/378456.378502)</sup>

## 局限与替代方案

跳跃比必须与多边形匹配。其他比值下的行为取决于多边形和规则：对于标准三角形游戏，\( r = 0.5 \) 生成谢尔宾斯基三角形，而其他比值可能产生重叠吸引子或不同的分形，点分布的均匀性需要额外假设。<sup>[14](https://computational-discovery-on-jupyter.github.io/Computational-Discovery-on-Jupyter/Contents/chaos-game-representation.html)</sup> 结果有时是分形，但并非总是如此。<sup>[1](https://mathworld.wolfram.com/ChaosGame.html)</sup> 预热的重要性超出直觉：若起点 \( P \) 不在谢尔宾斯基集合中，则绘制的30,000个点中没有一个会真正落在该集合内，因为半程移动会使轨道永远保持在被挖去的三角形内部。<sup>[25](http://webserv.jcu.edu/math/vignettes/chaosgame.htm)</sup> 非压缩映射一度超出理论范围，如今已被一般收敛定理所涵盖。<sup>[12](https://www.cambridge.org/core/journals/ergodic-theory-and-dynamical-systems/article/abs/chaos-game-on-a-general-iterated-function-system/0AC751F2D51BE6666E94A03C78AF53E1)</sup>

主要的替代方案是确定性IFS算法，它同时对整个集合施加所有变换。已发表的比较将混沌游戏描述为两者中更高效的一种，内存占用低，且可从单点出发。<sup>[7](https://link.springer.com/article/10.1007/s13373-013-0041-3)</sup><sup> • </sup><sup>[16](https://ar5iv.labs.arxiv.org/html/1506.07101)</sup>

## References

1. [Chaos Game -- from Wolfram MathWorld](https://mathworld.wolfram.com/ChaosGame.html)
2. [How long is the Chaos Game?](https://ar5iv.labs.arxiv.org/html/2007.11517)
3. [Chaos game representation and its applications in bioinformatics](https://pmc.ncbi.nlm.nih.gov/articles/PMC8636998/)
4. [Why does the chaos game converge to the Sierpinski triangle?](https://arun.chagantys.org/articles/chaos-game/)
5. [Chaos Game Representation (arXiv 2012.09638)](https://ar5iv.labs.arxiv.org/html/2012.09638)
6. [Learning Image Fractals Using Chaotic Differentiable Point Splatting (MPI Informatics)](https://chaotic-fractals.mpi-inf.mpg.de/Chaotic_Fractals.pdf)
7. [Developments in fractal geometry (Bulletin of Mathematical Sciences)](https://link.springer.com/article/10.1007/s13373-013-0041-3)
8. [Fractal Geometry: Mathematical Foundations and Applications, chapter 9 (Kenneth Falconer)](https://www.ma.ic.ic.ac.uk/~jswlamb/M345PA46/F03%20chap%209.pdf)
9. [3.2 Chaos Game](https://chaosgame.drwhy.ai/chaos-game-1.html)
10. [Fractals and the Chaos Game (R. Pyke, SFU)](http://www.sfu.ca/~rpyke/chaosgame.pdf)
11. [On the convergence rate of the chaos game](https://ar5iv.labs.arxiv.org/html/2102.02047)
12. [The chaos game on a general iterated function system (Ergodic Theory and Dynamical Systems, Cambridge University Press; Vince)](https://www.cambridge.org/core/journals/ergodic-theory-and-dynamical-systems/article/abs/chaos-game-on-a-general-iterated-function-system/0AC751F2D51BE6666E94A03C78AF53E1)
13. [The Chaos Game - Introduction to the world of fractals](https://beltoforion.de/en/recreational_mathematics/chaos_game.php)
14. [Chaos Game Representation, Computational Discovery on Jupyter](https://computational-discovery-on-jupyter.github.io/Computational-Discovery-on-Jupyter/Contents/chaos-game-representation.html)
15. [Stephen Demko, Laurie Hodges, Bruce Naylor (1985). Construction of fractal objects with iterated function systems. ACM SIGGRAPH Computer Graphics.](https://doi.org/10.1145/325165.325245)
16. [On the chaos game of iterated function systems](https://ar5iv.labs.arxiv.org/html/1506.07101)
17. [The Optimal Ratio of a Generalized Chaos Game in Regular Polytopes (arXiv, 2025)](https://arxiv.org/html/2505.18669)
18. [High Performance Iterated Function Systems](https://jo.dreggn.org/2010_fractal_flames.pdf)
19. [m-sarabi/chaos-game](https://github.com/m-sarabi/chaos-game)
20. [CGRclust: Chaos Game Representation for twin contrastive clustering of unlabelled DNA sequences (BMC Genomics, 2024; supplementary CGR definition merged)](https://link.springer.com/article/10.1186/s12864-024-11135-y)
21. [Nucleotide, dinucleotide and trinucleotide frequencies explain patterns observed in chaos game representations of DNA sequences](https://pmc.ncbi.nlm.nih.gov/articles/PMC309551/)
22. [Chaos game representation of proteins](https://www.sciencedirect.com/science/article/abs/pii/S109332639700106X)
23. [Fractal Image Compression (AMS Notices, June 1996, by Barnsley)](https://www.ams.org/notices/199606/barnsley.pdf)
24. [Harnessing chaos for image synthesis (SIGGRAPH)](https://dl.acm.org/doi/10.1145/378456.378502)
25. [The Chaos Game (John Carroll University vignette)](http://webserv.jcu.edu/math/vignettes/chaosgame.htm)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 几何学与拓扑学 › Computational and algorithmic geometry

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/chaos-game

English original: https://www.edgepedia.org/chaos-game
