本文整理匯總了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)
示例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)
示例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)
示例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)
#.........這裏部分代碼省略.........