该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

不知道啥语言

def show_spaceship_speed(period, deltax, deltay):

# we found a moving oscillator

if period == 1:

g.show("Spaceship detected (speed = c)")

elif (deltax == deltay) or (deltax == 0) or (deltay == 0):

speed = ""

if (deltax == 0) or (deltay == 0):

# orthogonal spaceship

if (deltax > 1) or (deltay > 1):

speed += str(deltax + deltay)

else:

# diagonal spaceship (deltax == deltay)

if deltax > 1:

speed += str(deltax)

g.show("Spaceship detected (speed = " + speed + "c/" +str(period) + ")")

else:

# deltax != deltay and both > 0

speed = str(deltay) + "," + str(deltax)

g.show("Knightship detected (speed = " + speed + "c/" + str(period) + ")")

# --------------------------------------------------------------------

def oscillating():

# return True if the pattern is empty, stable or oscillating

# first get current pattern's bounding box

prect = g.getrect()

pbox = rect(prect)

if pbox.empty:

g.show("The pattern is empty.")

return True

# get current pattern and create hash of "normalized" version -- ie. shift

# its top left corner to 0,0 -- so we can detect spaceships and knightships

## currpatt = pattern( g.getcells(prect) )

## h = hash( tuple( currpatt(-pbox.left, -pbox.top) ) )

# use Golly's hash command (3 times faster than above code)

h = g.hash(prect)

# check if outer-totalistic rule has B0 but not S8

rule = g.getrule().split(":")[0]

hasB0notS8 = rule.startswith("B0") and (rule.find("/") > 1) and not rule.endswith("8")

# determine where to insert h into hashlist

pos = 0

listlen = len(hashlist)

while pos < listlen:

if h > hashlist[pos]:

pos += 1

elif h < hashlist[pos]:

# shorten lists and append info below

del hashlist[pos : listlen]

del genlist[pos : listlen]

del poplist[pos : listlen]

del boxlist[pos : listlen]

break

else:

# h == hashlist[pos] so pattern is probably oscillating, but just in

# case this is a hash collision we also compare pop count and box size

if (int(g.getpop()) == poplist[pos]) and \

(pbox.wd == boxlist[pos].wd) and \

(pbox.ht == boxlist[pos].ht):

period = int(g.getgen()) - genlist[pos]

if hasB0notS8 and (period % 2 > 0) and (pbox == boxlist[pos]):

# ignore this hash value because B0-and-not-S8 rules are

# emulated by using different rules for odd and even gens,

# so it's possible to have identical patterns at gen G and

# gen G+p if p is odd

return False

if period == 1:

if pbox == boxlist[pos]:

g.show("The pattern is stable.")

else:

show_spaceship_speed(1, 0, 0)

elif pbox == boxlist[pos]:

g.show("Oscillator detected (period = " + str(period) + ")")

else:

deltax = abs(boxlist[pos].x - pbox.x)

deltay = abs(boxlist[pos].y - pbox.y)

show_spaceship_speed(period, deltax, deltay)

return True

else:

# look at next matching hash value or insert if no more

pos += 1

# store hash/gen/pop/box info at same position in various lists

hashlist.insert(pos, h)

genlist.insert(pos, int(g.getgen()))

poplist.insert(pos, int(g.getpop()))

boxlist.insert(pos, pbox)

return False

# --------------------------------------------------------------------

def fit_if_not_visible():

# fit pattern in viewport if not empty and not completely visible

r = rect(g.getrect())

if (not r.empty) and (not r.visible()): g.fit()

# --------------------------------------------------------------------

g.show("Checking for oscillation... (hit escape to abort)")

oldsecs = time()

while not oscillating():

g.run(1)

newsecs = time()

if newsecs - oldsecs >= 1.0: # show pattern every second

oldsecs = newsecs

fit_if_not_visible()

g.update()

fit_if_not_visible()

java生命游戏_大神们 急求一个生命游戏的java代码 谢谢各路大神!相关推荐

  1. 用python设计游戏_我用 Python 制作了一个迷宫游戏

    相信大家都玩过迷宫的游戏,对于简单的迷宫,我们可以一眼就看出通路,但是对于复杂的迷宫,可能要仔细寻找好久,甚至耗费数天,然后可能还要分别从入口和出口两头寻找才能找的到通路,甚至也可能找不到通路. 虽然 ...

  2. 视频教程-大型Java项目视频教程_王勇老师DRP项目教程完整版292集-Java

    大型Java项目视频教程_王勇老师DRP项目教程完整版292集 动力节点王勇老师,CCTV<影响力对话>栏目特约嘉宾,Java培训知名讲师,中国Java培训领军人物,北京动力节点创始人,董 ...

  3. java小恐龙游戏_用Python实现谷歌的小恐龙游戏

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理. 谷歌流量器中有个很有名的彩蛋:当你网络出现问题时,就会出现一个"小恐龙游戏&quo ...

  4. 根据斗破苍穹改编的Java游戏_不仅《斗破苍穹》改编动漫游戏,这个作者才是游戏IP大师!...

    很多RPG游戏都是根据知名小说改编,吃桃鸽今天就挑出几部自己玩过游戏,还看过原文的小说来小评一下. <诛仙> <诛仙>这本小说刚出来的时候,吃桃鸽当时还在用诺基亚,上课的时候偷 ...

  5. java前沿技术_互联网百强企业架构师告诉你,Java应该这么学!云和数据超全面Java中级程序员学习路线图重磅发布!...

    作为常居编程语言排行榜第一名的编程语言,Java语言以其稳定性.健壮性著称,是一门非常成熟的编程语言,多年来一直是国际上众多企业的首选编程语言. Java语言不仅吸收了C++语言的各种优点,还摒弃了C ...

  6. python3.7魔塔游戏_基于Funcode平台的“火锅版魔塔”游戏开发与设计

    2019 年第 2 期 信息与电脑 China Computer & Communication 软件开发与应用 基于 Funcode 平台的"火锅版魔塔"游戏开发与设计 ...

  7. python实现图片找不同游戏_用Python实现谷歌的小恐龙游戏

    (给Python开发者加星标,提升Python技能) 来源: Charles的皮卡丘-白露未晞me理 谷歌流量器中有个很有名的彩蛋:当你网络出现问题时,就会出现一个"小恐龙游戏". ...

  8. java卡 应用_一种实现多发行方的多应用Java卡的方法与流程

    本发明涉及智能卡 技术领域: :,尤其涉及一种实现多发行方的多应用Java卡的方法. 背景技术: ::在GlobalPlatform组织发布的卡片规范中,有且只有一个发行方,该发行方是卡片的拥有者并最 ...

  9. 变成机器人 尼尔机械纪元_尼尔机械纪元竟然是一个外包游戏?

    还记得2B小妹妹吗? 虽然尼尔机械纪元已经发售了很长时间了,但是我觉得它的内容还是可以聊一聊的. 毫无疑问,尼尔机械纪元是成功的.这点从销量上就能看出来.(PS:当然也有人说是靠卖屁股得来的销量.哈哈 ...

  10. linux开源游戏_适用于Linux的7个开源终端游戏

    linux开源游戏 精美的图形真的会使游戏变得更好吗? Linux上的基于文本的游戏还能让您保持娱乐吗? 别误会,我偶尔会喜欢玩大型工作室发行的AAA游戏. 但是随着年龄的增长,我发现我真正重视游戏玩 ...

最新文章

  1. SAS 对数据的拼接与串接
  2. 考研数学一历年真题小题(选择填空)整理
  3. 如何实现文章中文字的打字效果
  4. adpater里写toast_Android开发UI之Toast的使用
  5. ios笔试题算法_【2018年最新】iOS面试题之常见算法
  6. dnf登录不了服务器未响应,win7dnf辅助登陆没反应的三种解决方法
  7. 【STM32F407的DSP教程】第13章 DSP快速计算函数-三角函数和平方根
  8. 2018年腾讯社交广告大赛复习总贴
  9. mySQL数据库中.frm和.myi和.myd和.ibd文件是什么文件?
  10. Latex 多图片排版--排版代码生成器
  11. 剪了 20% 的刘海、120Hz 刷新率、1TB 存储,最高售价为 12999 元的 iPhone 13 系列来了!
  12. python羊车门问题_羊车门作业 Python版
  13. 图形界面 II: 设置库的事件处理函数 (第三章)
  14. C1认证学习笔记2--计算机通识
  15. intel realsense 深度相机深度图像处理API总结
  16. Windows10中好用的软件推荐
  17. 免费馅饼 (数据结构)
  18. Idea相关操作以及相关问题
  19. 从单体架构到分布式微服务架构的思考
  20. Batch Normalization(BN)简介

热门文章

  1. 使用安全json parser防止json注入
  2. crossentropyloss 输入_Pytorch常用的交叉熵损失函数CrossEntropyLoss()详解
  3. mysql同步row模式_mysql行模式(ROW)主从同步测试及错误修复
  4. 续【将数据从MongoDB迁移到mysql】
  5. C#读写日志文本文件
  6. 17-(基础入门篇)GPRS(Air202)串口
  7. Map 3D 2012定制和应用程序开发Webcast将于明天(6月23号)进行
  8. zephir-(1)开篇介绍
  9. iOS POST 上传图片
  10. [Linux] ubuntu 安装 Wireshark