当前位置: 首页>>代码示例>>Python>>正文


Python Life.Life类代码示例

本文整理汇总了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
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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  
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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)
开发者ID:ttsoftware,项目名称:POM,代码行数:8,代码来源:LifeTest.py

示例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
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:10,代码来源:TestLife.py

示例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)    
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:11,代码来源:TestLife.py

示例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) == '-' 
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:12,代码来源:TestLife.py

示例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'
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:12,代码来源:TestLife.py

示例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-'
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:12,代码来源:TestLife.py

示例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
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:15,代码来源:TestLife.py

示例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
开发者ID:boogerpickin,项目名称:life_the_universe_and_everything,代码行数:16,代码来源:Domain.py

示例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()
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:16,代码来源:TestLife.py

示例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()
开发者ID:jjloftin,项目名称:cs313e-life,代码行数:16,代码来源:TestLife.py


注:本文中的Life.Life类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。