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


Python Darwin.print_grid方法代码示例

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


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

示例1: test_print_grid

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

示例2: test_print_grid2

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import print_grid [as 别名]
 def test_print_grid2(self):
     D = Darwin(1,1)
     hopper = Species([], 'h')
     h1 = Creature(hopper, 2)
     D.add_creature(h1,0,0)
     self.assertEqual(D.print_grid(0),None)
开发者ID:JiannanZhang,项目名称:Darwin-World,代码行数:8,代码来源:TestDarwin.py

示例3: test_print_grid3

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import print_grid [as 别名]
 def test_print_grid3(self):
     D = Darwin(3,3)
     food = Species([], '')
     f = Creature(food, 2)
     D.add_creature(f,1,1)
     self.assertEqual(D.print_grid(0),None)
开发者ID:JiannanZhang,项目名称:Darwin-World,代码行数:8,代码来源:TestDarwin.py

示例4: main

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import print_grid [as 别名]
def main():

    # ------
    # hopper
    # ------

    hopper = Species()
    hopper.add_instruction("hop")
    hopper.add_instruction("go 0")

    # ----
    # food
    # ---- 
   
    food = Species()
    food.add_instruction("left")
    food.add_instruction("go 0")
        
    # -----
    # rover
    # -----
    
    rover = Species()
    rover.add_instruction("if_enemy 9")
    rover.add_instruction("if_empty 7")
    rover.add_instruction("if_random 5")
    rover.add_instruction("left")
    rover.add_instruction("go 0")
    rover.add_instruction("right")
    rover.add_instruction("go 0")
    rover.add_instruction("hop")
    rover.add_instruction("go 0")
    rover.add_instruction("infect")
    rover.add_instruction("go 0")

    # ----
    # trap
    # ----
    
    trap = Species()
    trap.add_instruction("if_enemy 3")
    trap.add_instruction("left")
    trap.add_instruction("go 0")
    trap.add_instruction("infect")
    trap.add_instruction("go 0")
      

    # ----
    # best
    # ----

    best = Species()
    best.add_instruction("if_wall 4")
    best.add_instruction("if_enemy 6")
    best.add_instruction("hop")
    best.add_instruction("go 0")
    best.add_instruction("left")
    best.add_instruction("go 0")
    best.add_instruction("infect")
    best.add_instruction("go 0")
    
    
    # ----
    # darwin8x8()
    # ----
    
    print("*** Darwin 8x8 ***")
    grid = Darwin(8, 8)
      
    f1 = Creature(food, "f", 1, 0, 0)
    h1 = Creature(hopper, "h", 0, 3, 3)
    h2 = Creature(hopper, "h", 1, 3, 4)
    h3 = Creature(hopper, "h", 2, 4, 4)
    h4 = Creature(hopper, "h", 3, 4, 3)
    f2 = Creature(food, "f", 0, 7, 7)
        
    grid.add_creature(f1)
    grid.add_creature(f2)
    grid.add_creature(h1)
    grid.add_creature(h2)
    grid.add_creature(h3)
    grid.add_creature(h4)
    
    for i in range(6):
        #printed which turn it is
        print("Turn = " + str(i))
        grid.print_grid()
        grid.cycle()
        print()
    
    
    # ----
    # darwin7x9
    # ----
    
    print("*** Darwin 7x9 ***")
    grid = Darwin(7, 9)
    seed(0);
    
    t1 = Creature(trap, "t", 2, 0, 0)
#.........这里部分代码省略.........
开发者ID:KHJRizen,项目名称:cs313e-darwin,代码行数:103,代码来源:RunDarwin.py


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