當前位置: 首頁>>代碼示例>>Python>>正文


Python Darwin.Darwin類代碼示例

本文整理匯總了Python中Darwin.Darwin的典型用法代碼示例。如果您正苦於以下問題:Python Darwin類的具體用法?Python Darwin怎麽用?Python Darwin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Darwin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_facing_wall4

 def test_facing_wall4(self):
     x = Darwin(2, 2)
     y = Species()
     z = Creature(y, "Bob", 3, 0, 0)
     x.add_creature(z)
     a = x.facing_wall(0, 0)
     self.assertEqual(a, True)
開發者ID:KHJRizen,項目名稱:cs313e-darwin,代碼行數:7,代碼來源:TestDarwin.py

示例2: test_darwin8

 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,代碼行數:7,代碼來源:TestDarwin.py

示例3: test_facing_enemy1

 def test_facing_enemy1(self):
     x = Darwin(2, 2)
     y = Species()
     z = Creature(y, "Bob", 2, 0, 0)
     x.add_creature(z)
     a = x.facing_enemy(0, 0)    
     self.assertEqual(a, False)
開發者ID:KHJRizen,項目名稱:cs313e-darwin,代碼行數:7,代碼來源:TestDarwin.py

示例4: test_print_grid

 def test_print_grid(self):
     x = Darwin(1,1)
     y = Species()
     z = Creature(y, "Bob", 2, 0, 0)
     x.add_creature(z)
     a = x.print_grid()
     self.assertEqual(a, None)
開發者ID:KHJRizen,項目名稱:cs313e-darwin,代碼行數:7,代碼來源:TestDarwin.py

示例5: 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

示例6: 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

示例7: 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

示例8: test_darwin3

 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,代碼行數:8,代碼來源:TestDarwin.py

示例9: 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

示例10: 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

示例11: test_Darwin_11

 def test_Darwin_11(self):
     assert hasattr(Darwin, "infect")
     game = Darwin(5,5)
     rover = Species("rover")
     c = Creature(rover)
     space = Species(".")
     game.place_creature(c,2,2,"west")
     self.assertEqual(c.direction,"west") 
     v = game.if_enemy(space,False) 
開發者ID:ibrahimnagib,項目名稱:Darwins-World,代碼行數:9,代碼來源:TestDarwin.py

示例12: test_Darwin_7

 def test_Darwin_7(self):
     assert hasattr(Darwin, "show_board")
     game = Darwin(5,5)
     trap = Species("trap")
     c = Creature(trap)
     game.place_creature(c,2,2,"north")
     self.assertEqual(c.direction,"north")
     game.left(0,0)
     self.assertEqual(c.direction,"west")
開發者ID:ibrahimnagib,項目名稱:Darwins-World,代碼行數:9,代碼來源:TestDarwin.py

示例13: test_Darwin_6

 def test_Darwin_6(self):
     # assert hasattr(Darwin, "place_creature")
     game = Darwin(5,5)
     food = Species("food")
     b = Creature(food)
     game.place_creature(b,2,2,"west")
     self.assertEqual(b.direction,"west")
     game.left(0,0)
     self.assertEqual(b.direction,"south")
開發者ID:ibrahimnagib,項目名稱:Darwins-World,代碼行數:9,代碼來源:TestDarwin.py

示例14: test_Darwin_5

 def test_Darwin_5(self):
     assert hasattr(Darwin, "hop")
     game = Darwin(6,6)
     rover = Species("rover")
     c = Creature(rover)
     game.place_creature(c,2,3,"east")
     self.assertEqual(c.direction,"east")
     game.right(0,0)
     self.assertEqual(c.direction,"south")
開發者ID:ibrahimnagib,項目名稱:Darwins-World,代碼行數:9,代碼來源:TestDarwin.py

示例15: test_facing_enemy5

 def test_facing_enemy5(self):
     x = Darwin(2, 2)
     y = Species()
     z = Creature(y, "Bob", 1, 0, 0)
     u = Creature(y, "Joe", 1, 0, 1)
     x.add_creature(z)
     x.add_creature(u)
     a = x.facing_enemy(0, 0)    
     self.assertEqual(a, False)        
開發者ID:KHJRizen,項目名稱:cs313e-darwin,代碼行數:9,代碼來源:TestDarwin.py


注:本文中的Darwin.Darwin類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。