找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5104|回复: 10
收起左侧

51单片机模拟二维宇宙演化

[复制链接]
ID:67796 发表于 2015-1-7 18:10 | 显示全部楼层 |阅读模式
本帖最后由 exv 于 2015-1-7 18:11 编辑

二位宇宙模拟动态图

二位宇宙模拟动态图


霍金在The Grand Design中写道
"In the Game of Life, as in our world, self-reproducing patterns are complex objects. One estimate, based on the earlier work of mathematician John von Neumann, places the minimum size of a self- replicating pattern in the Game of Life at ten trillion squares—roughly the number of molecules in a single human cell."

这里Game指的是Law而非游戏,Einstein说过“The god does not play the game which throw the dice.",Game与Law的不同在于前者是不定的,如同Schrodinger's Cat的状态是不定的。

如果模拟宇宙的维数达到11,并且有合适的Law及相应起始状态,复现我们这个世界也是可能的,这便是The Grand Design之意。

由于是既定的演化路径,故而可用51单片机模拟二维宇宙演化。

以下是编码原则(The Law of A 2D World,摘自霍金的书The Grand Design

The world Conway envisioned is a square array, like a chessboard, but extending infinitely in all directions. Each square can be in one of two states: alive (shown in green) or dead (shown in black). Each square has eight neighbors: the up, down, left, and right neighbors and four diagonal neighbors. Time in this world is not continuous but moves forward in discrete steps. Given any arrangement of dead and live squares, the number of live neighbors determine what happens next according to the following laws:

1.  A live square with two or three live neighbors survives (survival).
2.  A dead square with exactly three live neighbors becomes a live cell (birth).
3.  In all other cases a cell dies or remains dead. In the case that a live square has zero or one neighbor, it is said to die of loneliness; if it has more than three neighbors, it is said to die of overcrowding.

二位宇宙模拟

二位宇宙模拟

上图是自己用51单片机在12864液晶上模拟的二位宇宙演化,该宇宙的演化经历时间为43演化单位。

相关书籍及代码晚些时候附上。

此模拟方案可用于:
1. 练习编写与液晶/单片机有关的代码优化;
2. 测试硬件性能,类似计算PI来评价计算机性能的那个程式。
回复

使用道具 举报

ID:67796 发表于 2015-1-8 20:07 | 显示全部楼层
相关代码请参考我这个帖子:
http://www.51hei.com/bbs/dpj-30318-1.html

霍金的The Grand Design请到这下载:
http://vdisk.weibo.com/s/B4iksprsm65q
相关编码原理请参考第八章

以上资料仅供交流学习之用~
回复

使用道具 举报

ID:67796 发表于 2015-1-9 12:38 | 显示全部楼层
更多细胞自动机参考:

1.一位网友在彩色液晶上做的屏保

彩色液晶屏保

彩色液晶屏保


2.网友withparadox2的作品

withparadox的作品

withparadox的作品


3.另外一位网友的作品

3

3


提示:
您若用手上的51单片机和液晶实现这些,请适当更改我的算法,否则会等上很久的。

回复

使用道具 举报

ID:70129 发表于 2015-1-11 17:10 来自手机 | 显示全部楼层
谢谢楼主分享,好漂亮。
回复

使用道具 举报

ID:67796 发表于 2015-1-12 22:47 | 显示全部楼层
本帖最后由 exv 于 2015-1-12 22:50 编辑

霍金的书向来以难懂著称,为了让更多朋友能看懂,我稍翻译下霍金书上的文字:

The world Conway envisioned is a square array, like a chessboard, but extending infinitely in all directions. Each square can be in one of two states: alive (shown in green) or dead (shown in black). Each square has eight neighbors: the up, down, left, and right neighbors and four diagonal neighbors. Time in this world is not continuous but moves forward in discrete steps. Given any arrangement of dead and live squares, the number of live neighbors determine what happens next according to the following laws:

Conway架构了一个可无限延展的二维棋盘阵列。
每格仅阴阳二态:阳(绿)阴(黑)。
(注:书上的颜色和我提供的程序中的颜色正好相反)
每格8邻:上下左右及四斜角。
此世界中的时间是离散而非连续。
若给定阴阳变易法则及始态,则可向时间轴前方推演此世界:

1.  A live square with two or three live neighbors survives (survival).
2.  A dead square with exactly three live neighbors becomes a live cell (birth).
3.  In all other cases a cell dies or remains dead. In the case that a live square has zero or one neighbor, it is said to die of loneliness; if it has more than three neighbors, it is said to die of overcrowding.

1. 若阳格周围有 2 ~ 3 阳格,其继为阳。
2. 若阴格周围恰 3 阳格,此格转阳。
3. 其他所有情形,阴继为阴。阳格周阳格少则死于孤寂;反之死于拥挤。
回复

使用道具 举报

ID:72183 发表于 2015-1-13 22:41 | 显示全部楼层
大师级的人物,专门注册来学习!
回复

使用道具 举报

ID:67796 发表于 2015-1-13 23:17 | 显示全部楼层
如果有STM32板子的朋友,可参考我的这个帖子:
www点openedv点com/posts/list/0/45175.htm
运算速度会快上很多。
回复

使用道具 举报

ID:67796 发表于 2015-1-13 23:28 | 显示全部楼层
gonggu8181 发表于 2015-1-13 22:41
大师级的人物,专门注册来学习!

真正的大师在书里:
John von Neumann(冯诺依曼)有两个大作为后人称道:
一个是包括51单片机都在使用的冯诺依曼结构,另一个便是这细胞自动机。

霍金引用了冯诺依曼的一个大作,
而我只是引用了霍金的大作。

民国时有位诗人写过这样一首诗:
你站在桥上看风景
看风景人在桥上看你
明月装饰了你的窗子
你装饰了别人的梦

咱不过是风景中的风景,梦中的梦,真正的万有在这一切之外。
回复

使用道具 举报

ID:65707 发表于 2015-1-14 08:25 | 显示全部楼层
太强了.不晓得要好久才能达到这个水平
回复

使用道具 举报

ID:67796 发表于 2015-1-14 12:48 | 显示全部楼层
附上一个可在89c52+12864液晶上运行的hex文件(51hei5默认配置即可)
效率比之前高约二十倍。
部分修改后的代码亦在附件中。
底层代码请各位朋友依据自己的硬件实现。
Evolution.rar (3.74 KB, 下载次数: 9)
回复

使用道具 举报

ID:67796 发表于 2015-1-18 10:50 | 显示全部楼层
重新用STM32写了一遍代码,支持互动式操作(可在屏幕上绘图)。

Cellular.jpg

相关代码可到 百度 STM32下的元胞自动机。(第一个即是)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表