| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1715 人关注过本帖
标题:求帮忙,看一下这个程序
只看楼主 加入收藏
已被折磨死
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
帖 子:8902
专家分:2567
注 册:2004-3-25
收藏
得分:20 
把错误提示贴上来看看

畅所欲言
2014-03-29 14:51
xinZ
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-9-11
收藏
得分:0 
你的程序在我这里可以运行,不知道你的问题是什么
2014-09-11 16:23
快速回复:求帮忙,看一下这个程序
数据加载中...
 
   



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

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