我可以实现什么算法来加速某些元胞自动机模拟?
我正在为(几乎)任何使用 Moore 或 Neumann 邻域的 CA 编写一个基于 ncurses 的 CA 模拟器。
使用当前的(硬编码和最明显的[运行状态函数]),模拟运行得很好;直到屏幕充满“打开”(或任何活动的)单元格。
所以我的问题是: 是否有任何有效的算法来处理至少逼真的规则? 或世代,加权生命/世代......
谢谢。
I am writing a ncurses based C.A. simulator for (nearly) any kind of C.A. which uses the Moore or Neumann neighborhoods.
With the current (hardcoded and most obvious [running state funcs]) the simulation runs pretty well; until the screen is filled with 'on' (or whatever active) cells.
So my question is:
Are there any efficient algorithms for handling at least life-like rules?
or Generations, Weighted life/generations...
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通常最好只在前一个时间步骤中具有活动的网格区域中运行更新传递。如果你保留一个布尔格“这次我改变了吗?”对于每一遍,您只需要更新那些在变化晶格中带有“on”的单元格的一个半径内的单元格。
it's generally nice to only run update passes in areas of the grid that had activity in the previous time step. if you keep a boolean lattice of "did i change this time?" for each pass, you only need to update cells within one radius of those with an "on" in the change lattice.
我认为编写状态机并不是算法设计问题,而是如何编写干净且“无错误”代码的问题。您可能正在寻找的是元胞自动机/状态图的实现。
http://www.state-machine.com/ //<- 不,这不是巧合
http://www.boost.org/doc/ libs/1_40_0/libs/statechart/doc/index.html
您也可以尝试使用 stackless python http://stackless .com/。它可用于状态机或CA。这里 http://members.verizon.net/olsongt/stackless/why_stackless .html#the-factory 这是stackless实现工厂流程模拟的教程
I think writing state machines is not as much algorhitms designing problem as is just problem how to write clean and "bug free" code. What are you probably looking for is implementation of cellular automata / state chart.
http://www.state-machine.com/ //<- no this is not coincidence
http://www.boost.org/doc/libs/1_40_0/libs/statechart/doc/index.html
You might also try whit stackless python http://stackless.com/. It can be used for state machines or CA. Here http://members.verizon.net/olsongt/stackless/why_stackless.html#the-factory it is tutorial for stackless implementing factory process simulation
您可以研究 HashLife 算法并尝试使其概念适应无论您正在研究什么自动机。
You could look into the HashLife algorithm and try to adapt its concept to whatever automata you are working on.