本文整理汇总了Python中Life.Life类的典型用法代码示例。如果您正苦于以下问题:Python Life类的具体用法?Python Life怎么用?Python Life使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Life类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_life_35
def test_life_35(self):
l = Life(1,3)
l.neighbors = 3
c1 = ConwayCell()
c1.evolve(l)
assert c1.alive == True
示例2: test_life_36
def test_life_36(self):
l = Life(1,3)
l.neighbors = 2
c2 = ConwayCell()
c2.evolve(l)
assert c2.alive == False
示例3: test_life_34
def test_life_34(self):
l = Life(2,2)
l.neighbors = 2
c1 = ConwayCell(True)
c1.evolve(l)
assert c1.alive == True
示例4: test_life_18
def test_life_18(self):
k = AbstractCell(True)
l = Life(1,1)
l.addCell(0,0,k)
k.evolve(l)
k.evolve(l)
k.evolve(l)
assert k.alive
示例5: test_life_25
def test_life_25(self):
k = FredkinCell(True)
l = Life(1,1)
l.addCell(0,0,k)
l.countLives()
k.evolve(l)
assert k.alive == False
示例6: test_foerste
def test_foerste(self):
l = Life(0, 20, 0, 20, self.alive)
xmin, xmax, ymin, ymax = l.foerste()
self.assertEqual(xmin, 0)
self.assertEqual(xmax, 20)
self.assertEqual(ymin, 0)
self.assertEqual(xmax, 20)
示例7: test_life_26
def test_life_26(self):
k1 = FredkinCell(True)
k2 = FredkinCell(True)
l = Life(2,2)
l.addCell(0,0,k1)
l.addCell(1,0,k2)
l.countLives()
k1.evolve(l)
assert k1.alive == True
示例8: test_life_27
def test_life_27(self):
k1 = FredkinCell(True)
k2 = FredkinCell(True)
l = Life(2,2)
l.addCell(0,0,k1)
l.addCell(1,0,k2)
l.countLives()
k1.age = 1
k1.evolve(l)
assert isinstance(k1,ConwayCell)
示例9: test_life_10
def test_life_10(self):
l1 = Life(1,1)
c1 = FredkinCell(True)
l1.addCell(0,0,c1)
l1.populationEvolve()
l2 = Life(1,1)
c2 = ConwayCell(True)
l2.addCell(0,0,c2)
l2.populationEvolve()
assert str(l2) == '.' and str(l1) == '-'
示例10: test_life_5
def test_life_5(self):
l = Life(2,2)
c1 = FredkinCell(True)
c2 = FredkinCell(True)
c3 = FredkinCell(True)
c4 = FredkinCell(True)
l.addCell(0,0,c1)
l.addCell(0,1,c2)
l.addCell(1,0,c3)
l.addCell(1,1,c4)
assert str(l) == '00\n00'
示例11: test_life_6
def test_life_6(self):
l = Life(2,2)
c1 = ConwayCell(True)
c2 = ConwayCell(False)
c3 = FredkinCell(True)
c4 = FredkinCell(False)
l.addCell(0,0,c1)
l.addCell(0,1,c2)
l.addCell(1,0,c3)
l.addCell(1,1,c4)
assert str(l) == '*.\n0-'
示例12: test_life_42
def test_life_42(self):
l = Life(2,2)
c1 = ConwayCell(True)
c2 = ConwayCell(True)
c3 = FredkinCell()
c4 = FredkinCell()
l.addCell(0,0,c1)
l.addCell(0,1,c2)
l.addCell(1,0,c3)
l.addCell(1,1,c4)
l.countLives()
l.cellExecute(1,1)
assert l.liveNeighbors() == 1
示例13: __init__
def __init__(self, spark = 42, d = -1):
Life.__init__(self)
self.d = d
self.domains = ["Bacteria", "Archaea", "Eukaryota"]
self.domain = self.domains[self.d]
def domainRandomize(self):
self.d = random.randint(0,2)
self.domain = self.domains[self.d]
pass
if (self.d < 0):
domainRandomize(self)
pass
if __name__ == '__main__':
#print "The Answer to Life, the Universe and Everything is: ", self.TheAnswerToLifeTheUniverseAndEverything
pass
示例14: test_life_45
def test_life_45(self):
l = Life(2,2)
c1 = ConwayCell(True)
c2 = ConwayCell(True)
c3 = ConwayCell(True)
c4 = ConwayCell(False)
l.addCell(0,0,c1)
l.addCell(0,1,c2)
l.addCell(1,0,c3)
l.addCell(1,1,c4)
l.countLives()
l.cellExecute(2,2)
assert c4.getAlive()
示例15: test_life_47
def test_life_47(self):
l = Life(2,2)
c1 = FredkinCell(True)
c2 = FredkinCell(True)
c3 = FredkinCell(True)
c4 = FredkinCell(False)
l.addCell(0,0,c1)
l.addCell(0,1,c2)
l.addCell(1,0,c3)
l.addCell(1,1,c4)
l.countLives()
l.cellExecute(1,1)
assert not c1.getAlive()