WaveFunctionCollapse相关 翻译
持续更新中,未完,预计2019年年底将此算法重要的文章都翻译完
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.
- Observation:
- 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元素要么处于完全已知的状态(除了零之外的所有参数)要么处于矛盾状态(所有的参数都是零)。前一种情况时返回输出。后一种情况程序结束时对应的元素就不返回。
- 评估:
来源:CSDN
作者:_王恒
链接:https://blog.csdn.net/qq_38871173/article/details/103577898