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


Python Darwin.Species类代码示例

本文整理汇总了Python中Darwin.Species的典型用法代码示例。如果您正苦于以下问题:Python Species类的具体用法?Python Species怎么用?Python Species使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Species类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_species_add_instruction4

 def test_species_add_instruction4(self):
     x = Species()
     y = "hop"
     x.add_instruction(y)
     x.add_instruction("YUH sup")
     z = x.program
     self.assertEqual(z, ["hop", "YUH sup"] )
开发者ID:KHJRizen,项目名称:cs313e-darwin,代码行数:7,代码来源:TestDarwin.py

示例2: test_creature2

 def test_creature2(self):
   s = Species('cat')
   s.addInstruction('hop')
   s.addInstruction('infect')
   c = Creature(s,'north')
   
   self.assertEqual(c.direction, 'north')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:7,代码来源:TestDarwin.py

示例3: test_run1

    def test_run1(self):

        food = Species([], 'f')
        food.add_instr(['left'])
        food.add_instr(['go', 0])

        hopper = Species([], 'h')
        hopper.add_instr(['hop'])
        hopper.add_instr(['go', 0])

        f1 = Creature(food, 2)
        h1 = Creature(hopper, 1)
        h2 = Creature(hopper, 2)
        h3 = Creature(hopper, 3)
        h4 = Creature(hopper, 4)
        f2 = Creature(food, 1)

        g1 = Darwin(8, 8)
        g1.add_creature(f1, 0, 0)
        g1.add_creature(h1, 3, 3)
        g1.add_creature(h2, 3, 4)
        g1.add_creature(h3, 4, 4)
        g1.add_creature(h4, 4, 3)
        g1.add_creature(f2, 7, 7)

        self.assertEqual(g1.run(5),None)
开发者ID:JiannanZhang,项目名称:Darwin-World,代码行数:26,代码来源:TestDarwin.py

示例4: test_creature3

 def test_creature3(self):
   s = Species('cat')
   s.addInstruction('hop')
   s.addInstruction('infect')
   c = Creature(s,'north')
   cmd = c.execute()  
   self.assertEqual(cmd, 'hop')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:7,代码来源:TestDarwin.py

示例5: test_darwin7

 def test_darwin7(self):
   d = Darwin(2,2)
   s = Species('dog')
   s.addInstruction('hop')
   c = Creature(s,'north')
   d.add(c,0,1)
   d.go(0,1)
   self.assertEqual(str(d),'  01\n0 .d\n1 ..\n')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:8,代码来源:TestDarwin.py

示例6: test_darwin9

 def test_darwin9(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('hop')
   c = Creature(s, 'east')
   d.add(c,0,0)
   d.turn()
   self.assertEqual(d.turns, 1)    
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:8,代码来源:TestDarwin.py

示例7: test_darwin10

 def test_darwin10(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('hop')
   c = Creature(s, 'east')
   d.add(c,0,0)
   d.turn()
   self.assertEqual(str(d),'  01\n0 .c\n')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:8,代码来源:TestDarwin.py

示例8: test_darwin16

 def test_darwin16(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('infect')
   c = Creature(s,'east')
   d.add(c,0,0)
   d.go(0,0)
   self.assertEqual(False,d.isWall())
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:8,代码来源:TestDarwin.py

示例9: test_darwin19

 def test_darwin19(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('hop')
   c = Creature(s,'east')
   d.add(c,0,0)
   d.go(0,0)
   self.assertEqual(False,d.isEnemy())  
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:8,代码来源:TestDarwin.py

示例10: test_darwin21

 def test_darwin21(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('infect')
   c = Creature(s,'east')
   d.add(c,0,0)
   d.go(0,0)
   self.assertEqual(str(d), '  01\n0 c.\n')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:8,代码来源:TestDarwin.py

示例11: test_game_1

 def test_game_1(self):
     game = Darwin(4,4)
     food = Species("food")
     food.add_instruction("right")
     food.add_instruction("go 0")
     f1 = Creature(food)
     game.place_creature(f1,2,2, "north")
     self.assertNotEqual(game.run(4),[])
开发者ID:ibrahimnagib,项目名称:Darwins-World,代码行数:8,代码来源:TestDarwin.py

示例12: test_creature6

 def test_creature6(self):
   s = Species('cat')
   s.addInstruction('hop')
   s.addInstruction('infect')
   c = Creature(s,'north')
   c.execute()
   c.execute()
   
   self.assertEqual(c.counter,2)  
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:9,代码来源:TestDarwin.py

示例13: test39

 def test39 (self):
   g = DarwinGrid(72, 72)
   food = Species("food")
   food.addInstruction("left")
   food.addInstruction("go 0")
   f = Creature(food, 0, 0, "North")
   g.addCreature(f)
   g.nextTurn()
   self.assertTrue(f.direction == "West")
开发者ID:AaronBorik,项目名称:cs313e-darwin,代码行数:9,代码来源:TestDarwin.py

示例14: test21

 def test21 (self):
   g = DarwinGrid(72, 72)
   food = Species("food")
   food.addInstruction("left")
   food.addInstruction("go 0")
   f = Creature(food, 0, 0, "East")
   g.addCreature(f)
   g.nextTurn()
   self.assertTrue(f.current == 1)
开发者ID:AaronBorik,项目名称:cs313e-darwin,代码行数:9,代码来源:TestDarwin.py

示例15: test19

 def test19 (self):
   g = DarwinGrid(4,4)
   food = Species("food")
   food.addInstruction("left")
   food.addInstruction("go 0")
   f = Creature(food, 0, 0, "East")
   g.addCreature(f)
   g.printGrid()
   self.assertTrue(len(food.instructions) == 2)
开发者ID:AaronBorik,项目名称:cs313e-darwin,代码行数:9,代码来源:TestDarwin.py


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