• 大小: 2.09KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2021-03-27
  • 语言: 其他
  • 标签: 其他  

资源简介


二维元胞自动机,冯诺伊曼边界,可以随意设置规则,输出图像

资源截图

代码片段和文件信息

# -*- coding:utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.animation import FuncAnimation

principle =‘01011101001001111111110111111111‘
principle0=‘01010111110101010101010101010111‘
principle1=‘00010111110101010101010101010111‘
principle2 =‘00010110110111010100010101011111‘
principle3 =‘01110001011010111001110001000101‘
principle4 =‘01110001011101000011101101010100‘
principle5 =‘01010101010101010101010101010101‘
principle6 =‘01011010101000101011110011111101‘

‘‘‘
定义为冯诺依曼边界的规则,种类有2^32种
‘‘‘

class group:
    def __init__(selflength):
         grid = np.zeros([lengthlength])
         grid[int(length/2)][int(length/2)] = 1
         self.cells = grid
         self.shape = grid.shape
         self._length = length
    def genarate(self):
        N=self._length
        self.cells = np.random.choice([01]N*N p=[0.3 0.7]).reshape(N N)

评论

共有 条评论