标题:求帮忙,看一下这个程序
只看楼主
已被折磨死
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-3-29
结帖率:0
已结贴  问题点数:20 回复次数:2 
求帮忙,看一下这个程序
能不能帮忙看一下这个程序为什么运行错误?
主题是做一个wireworld,一种细胞自动机。

import matplotlib.pyplot as plt  
import matplotlib.animation as animation
mur = 2   
head = 1
taile =9
cond =0
def go(x,y):
    if n[x][y-1]==head and n[x][y]==cond:
        n[x][y]=head
        n[x][y-1]=taile
        n[x][y-2]=cond

def fin(x,y):
    if n[x][-1]==1:
        n[x][0]=head
        n[x][-1]=taile
        n[x][-2]=cond
def init():
    return n

def update(*args):
    for x in range(3):
        for y in range(8):
            if n[x][y-1]==head and n[x][y]==cond :
                n[x][y]=head
                n[x][y-1]=taile
                n[x][y-2]=cond
                if n[x+1][y]==3:
                    n[x][0]=head
                im.set_array(n)
                return im,
        
            fin(x,y)
                    
            
               
n=[[1,0,0,0,0,0,2,0],
   [1,0,0,0,0,0,0,0],
   [2,2,2,2,2,3,2,2]]
init()

fig = plt.figure()   
im= plt.imshow(n,interpolation = "nearest")
ani = animation.FuncAnimation(fig,update,init_func=init,frames = 300,interval=2*500,blit = False)

plt.grid(True)
plt.show()
搜索更多相关主题的帖子: return import update 自动机 主题 
2014-03-29 05:34
静夜思
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:济南的冬天
等 级:管理员
威 望:11
帖 子:8842
专家分:2567
注 册:2004-3-25
得分:20 
把错误提示贴上来看看

畅所欲言
2014-03-29 14:51
xinZ
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-9-11
得分:0 
你的程序在我这里可以运行,不知道你的问题是什么
2014-09-11 16:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429324-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029947 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved