WaveFunctionCollapse相关 翻译
github的READMEAlgorithm算法 只是大体上的翻译,我增加了很多额外说明github的README
Algorithm
Read the input bitmap and count NxN patterns. (optional) Augment pattern data with rotations and reflections. Create an array with the dimensions of the output (called “wave” in the source). Each element of this array represents a state of an NxN region in the output. A state of an NxN region is a superposition of NxN patterns of the input with boolean coefficients (so a state of a pixel in the output is a superposition of input colors with real coefficients). False coefficient means that the corresponding pattern is forbidden, true coefficient means that the corresponding pattern is not yet forbidden.Initialize the wave in the completely unobserved state, i.e. with all the boolean coefficients being true.Repeat the following steps: Observation: Find a wave element with the minimal nonzero entropy. If there is no such elements (if all elements have zero or undefined entropy) then break the cycle (4) and go to step (5).Collapse this element into a definite state according to its coefficients and the distribution of NxN patterns in the input. Propagation: propagate information gained on the previous observation step. By now all the wave elements are either in a completely observed state (all the coefficients except one being zero) or in the contradictory state (all the coefficients being zero). In the first case return the output. In the second case finish the work without returning anything.算法
读入输入的位图,逐行逐列扫描,计算NxN的基础图案,用作计算的基本单元 (可选)使用旋转和镜像的方式处理基础图案,得到更多的图案,主要用来增强图案的多样性,注意不要滥用此功能,不然会得到一些奇怪的结果 创建一个高维数组用于计算和输出(在源码中称之为“wave”),此数组中的每个元素表示输出图形中NxN单元的状态,每个NxN区域的数值是原来NxN输入图案的布尔系数叠加(因此一个输出像素的数值是一个原输入像素颜色数值的叠加),false表示对应的图案不出现,true表示对应的图案会出现。刚开始在完全未知的情况下,初始化所有的wave为true重复下列步骤 观测: 找到一个具有具有最小熵的有效wave元素。 如果没有一个这样的元素(如果所有的元素都是零或者熵未定义)就中断此循环(4)进入步骤(5)。根据元素自身的系数和输入的NxN图案分布,将当前元素转化(collapse)为一个已知的状态 扩散: 传播在上一个观察中所获得的信息5.上述步骤完成后,所有的wave元素要么处于完全已知的状态(除了零之外的所有参数)要么处于矛盾状态(所有的参数都是零)。前一种情况时返回输出。后一种情况程序结束时对应的元素就不返回。