元胞自动机和随机运动
如何在元胞自动机模型中实现随机运动?例如,如果一个单元格中的元素远多于两个或多个相邻单元格,我想随机选择一些邻居来提供一些元素。我尝试了我想到的所有代码,但我的问题是,在 Mathematica 中,我必须确保一个元素同时从一个单元中生存并进入另一个单元。我想过使用条件来做到这一点,但我不知道如何做。有人可以帮我吗?
编辑:到目前为止我使用的代码
我的实际代码非常复杂,因此我将尝试告诉您我使用更简单的元胞自动机做了什么。我想在摩尔社区取得成功。我的元胞自动机中的每个细胞都有多个个体(或没有)。我想在我的细胞之间进行随机移动。我无法做到这一点,所以我尝试了以下代码,并在我的元胞自动机中使用了它,如下所示。
w[i_, j_] :=
If[(i - 4) > j, -1, If[(i - 4) == j, 0, If[(j - 4) > i, 1, 0]]];
dogs[p, p1, p2,p3,p4,p5,p6,p7,p8]:=newp &[
newp = w[p, p1] + w[p, p2] + w[p, p3] + w[p, p4] + w[p, p5] +
w[p, p6] + w[p, p7] + w[p, p8]]
这段代码正在做运动,但并不完全是我想要的,因为如果一个单元格中有 0 个个体,它的邻居有 5 个个体,那么最后它有 8 个个体,它的邻居有 4 个个体,但我不想要这样,因为我不'我们不希望其中个体较少的单元格最后的数量比其邻居多。我希望他们所有人都有接近的价值观并且仍然有活力。我不知道如何在 Mathematica 中做到这一点。
How can I have random movements in my Cellular automaton model? For example, if the elements in a cell is much more than two or more neighboring cells I'd like to randomly choose a few neighbors to give some elements. I tried all the codes that came to my mind but my problem is that in Mathematica I have to be sure that the same time an element is living from a cell and is going to another. I thought of doing it using conditions but I am not sure how. Can anyone please help me?
Edit: the code I used so far
My actual code is very complicated so I will try to tell you what I have done with a simpler cellular automaton. I wanted to succeed movements in a Moore neighbourhood. Every cell in my cellular automaton has more than one individual (or none). I want to make random movements between my cells. I couldn't do this, so I tried the following code and in my cellular automaton I used it like you can see below.
w[i_, j_] :=
If[(i - 4) > j, -1, If[(i - 4) == j, 0, If[(j - 4) > i, 1, 0]]];
dogs[p, p1, p2,p3,p4,p5,p6,p7,p8]:=newp &[
newp = w[p, p1] + w[p, p2] + w[p, p3] + w[p, p4] + w[p, p5] +
w[p, p6] + w[p, p7] + w[p, p8]]
This code is doing movements, but is not exactly what I want because if a cell has 0 individuals in it and its neighbours all 5, then at the end it has 8 and its neighbours 4 but I don't want that because I don't want the cell with the less individuals in it to have more than its neighbours at the end. I want all of them to have close values in them and still have movements. I don't know how to do that in Mathematica.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
元胞自动机并不是特别复杂,所以我的第一点建议是弄清楚你到底想要什么。然后,我建议您将经典转换规则与您引入的“随机”方面分开。
例如,这是我对康威生命游戏的实现:
执行evaluateAll后,您可以在矩阵中搜索“孤独”的单元格并根据需要移动它们。
有关代码如何工作的更多信息以及查看实际代码的示例,请参阅 我关于康威生活的博客文章。它包括一个 Mathematica 笔记本,其中包含完整的实现和大量示例。
A cellular automaton is not particularly complicated, so my first point of advice is to figure out exactly what you want. Then, I recommend you separate the classical transition rules from the "random" aspect you're introducing.
For instance, here is my implementation of Conway's Game of Life:
After performing evaluateAll, you can search through the matrix for "lonely" cells and move them as you please.
For additional information about how the code works, and to see examples of the code in action, see my blog post on Conway's Life. It includes a Mathematica notebook with the full implementation and plenty of examples.