本文整理汇总了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"] )
示例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')
示例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)
示例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')
示例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')
示例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)
示例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')
示例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())
示例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())
示例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')
示例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),[])
示例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)
示例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")
示例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)
示例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)