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


Python Darwin.run方法代码示例

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


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

示例1: test_run1

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

示例2: test_game_1

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

示例3: test_run2

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import run [as 别名]
    def test_run2(self):
        # food
        food = Species([], 'f')
        food.add_instr(['left'])
        food.add_instr(['go', 0])

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

        # rover
        rover = Species([], 'r')
        rover.add_instr(['if_enemy', 9])
        rover.add_instr(['if_empty', 7])
        rover.add_instr(['if_random', 5])
        rover.add_instr(['left'])
        rover.add_instr(['go', 0])
        rover.add_instr(['right'])
        rover.add_instr(['go', 0])
        rover.add_instr(['hop'])
        rover.add_instr(['go', 0])
        rover.add_instr(['infect'])
        rover.add_instr(['go', 0])

        # trap
        trap = Species([], 't')
        trap.add_instr(['if_enemy', 3])
        trap.add_instr(['left'])
        trap.add_instr(['go', 0])
        trap.add_instr(['infect'])
        trap.add_instr(['go', 0])

        t1 = Creature(trap, 3)
        h1 = Creature(hopper, 2)
        r1 = Creature(rover, 1)
        t2 = Creature(trap, 4)

        g2 = Darwin(7, 9)
        g2.add_creature(t1, 0, 0)
        g2.add_creature(h1, 3, 2)
        g2.add_creature(r1, 5, 4)
        g2.add_creature(t2, 6, 8)

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

示例4: test_run3

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import run [as 别名]
    def test_run3(self):
        # food
        food = Species([], 'f')
        food.add_instr(['left'])
        food.add_instr(['go', 0])

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

        # rover
        rover = Species([], 'r')
        rover.add_instr(['if_enemy', 9])
        rover.add_instr(['if_empty', 7])
        rover.add_instr(['if_random', 5])
        rover.add_instr(['left'])
        rover.add_instr(['go', 0])
        rover.add_instr(['right'])
        rover.add_instr(['go', 0])
        rover.add_instr(['hop'])
        rover.add_instr(['go', 0])
        rover.add_instr(['infect'])
        rover.add_instr(['go', 0])

        # trap
        trap = Species([], 't')
        trap.add_instr(['if_enemy', 3])
        trap.add_instr(['left'])
        trap.add_instr(['go', 0])
        trap.add_instr(['infect'])
        trap.add_instr(['go', 0])

        g3 = Darwin(72, 72)
        creatureTypes = [food, hopper, rover, trap]
        for ctype in creatureTypes:
            for i in range (0, 10):
                row = random.randrange(0, 72)
                col = random.randrange(0, 72)
                direction = random.randrange(0, 4)
                g3.add_creature(Creature(ctype, direction), row, col)
        self.assertEqual(g3.run(5),None)
开发者ID:JiannanZhang,项目名称:Darwin-World,代码行数:44,代码来源:TestDarwin.py

示例5: print

# 需要导入模块: from Darwin import Darwin [as 别名]
# 或者: from Darwin.Darwin import run [as 别名]
print("*** Darwin 8x8 ***")
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)
g1.run(5)


print("*** Darwin 7x9 ***")
t1 = Creature(trap, 3)
h1 = Creature(hopper, 2)
r1 = Creature(rover, 1)
t2 = Creature(trap, 4)

g2 = Darwin(7, 9)
g2.add_creature(t1, 0, 0)
g2.add_creature(h1, 3, 2)
g2.add_creature(r1, 5, 4)
g2.add_creature(t2, 6, 8)

g2.run(5)
开发者ID:JiannanZhang,项目名称:Darwin-World,代码行数:33,代码来源:RunDarwin.py


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