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


Python Darwin.add方法代码示例

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


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

示例1: test_darwin8

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_darwin8(self):
   d = Darwin(2,2)
   s = Species('dog')
   c = Creature(s,'south')
   d.add(c,0,1)
   d.go(0,0)
   self.assertEqual(str(d),'  01\n0 .d\n1 ..\n')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:9,代码来源:TestDarwin.py

示例2: test_darwin21

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 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,代码行数:10,代码来源:TestDarwin.py

示例3: test_darwin19

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 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,代码行数:10,代码来源:TestDarwin.py

示例4: test_darwin16

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 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,代码行数:10,代码来源:TestDarwin.py

示例5: test_darwin10

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 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,代码行数:10,代码来源:TestDarwin.py

示例6: test_darwin9

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 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,代码行数:10,代码来源:TestDarwin.py

示例7: test_darwin7

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 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,代码行数:10,代码来源:TestDarwin.py

示例8: test_darwin3

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_darwin3(self):  
   d = Darwin(1,3)
   s = Species('cat')
   c1 = Creature(s,'south')
   c2 = Creature(s,'south')
   c3 = Creature(s,'south')
   d.add(c1,0,0)
   self.assertEqual(str(d),'  012\n0 c..\n')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:10,代码来源:TestDarwin.py

示例9: test_creature7

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_creature7(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('infect')
   c = Creature(s,'south')
   d.add(c,0,0)
   d.go(0,0)
   
   c.left()
   self.assertEqual('east', c.direction)  
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:12,代码来源:TestDarwin.py

示例10: test_darwin23

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_darwin23(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('infect')
   c = Creature(s,'east')
   d.add(c,0,0)
   c1 = Creature(s,'east')
   d.add(c,1,0)
   d.go(0,0)
   assert c != c1
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:12,代码来源:TestDarwin.py

示例11: test_creature12

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_creature12(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('infect')
   c = Creature(s,'west')
   d.add(c,0,0)
   d.go(0,0)
   
   c.right()
   self.assertEqual('north',c.direction)
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:12,代码来源:TestDarwin.py

示例12: test_darwin20

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_darwin20(self):
   d = Darwin(1,2)
   s = Species('cat')
   s.addInstruction('hop')
   s1 = Species('dog')
   s1.addInstruction('hop')
   c = Creature(s,'east')
   c1 = Creature(s1,'east')
   d.add(c,0,0)
   d.add(c1,0,1)
   d.go(0,0)
   self.assertEqual(True,d.isEnemy()) 
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:14,代码来源:TestDarwin.py

示例13: test_creature18

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
 def test_creature18(self):
   s = Species('dog')
   c = Creature(s,'east')
   s.addInstruction('hop')
   s.addInstruction('if_enemy 2')
   s.addInstruction('if_empty 3')
   s.addInstruction('if_random 4')
   s.addInstruction('go 0')
   d = Darwin(2,2)
   d.add(c,0,0)
   d.go(0,0)
   cmd = c.execute()
   self.assertEqual(cmd, 'hop')
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:15,代码来源:TestDarwin.py

示例14: print

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import add [as 别名]
r.addInstruction('if_random 5')
r.addInstruction('left')
r.addInstruction('go 0')
r.addInstruction('right')
r.addInstruction('go 0')
r.addInstruction('hop')
r.addInstruction('go 0')
r.addInstruction('infect')
r.addInstruction('go 0')


print('*** Darwin 8x8 ***')
seed(0)
d = Darwin(8,8)
c1 = Creature(f,'east')
d.add(c1,0,0)
c2 = Creature(h,'north')
d.add(c2,3,3)
d.add(Creature(h,'east'),3,4)
d.add(Creature(h,'south'),4,4)
d.add(Creature(h,'west'),4,3)
d.add(Creature(f,'north'),7,7)

for i in range(6):
  print('Turn = ' + str(d.turns) + '.')
  print(d)
  d.turn()

print('*** Darwin 7x9 ***')
seed(0)
开发者ID:jjloftin,项目名称:cs313e-darwin,代码行数:32,代码来源:RunDarwin.py


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