本文整理汇总了Python中species.Species.is_larger方法的典型用法代码示例。如果您正苦于以下问题:Python Species.is_larger方法的具体用法?Python Species.is_larger怎么用?Python Species.is_larger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类species.Species
的用法示例。
在下文中一共展示了Species.is_larger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_larger
# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import is_larger [as 别名]
def test_is_larger(self):
# Population different
self.defender.population = 2
self.attacker.population = 1
self.assertEqual(Species.is_larger(self.defender, self.attacker), 1)
self.assertEqual(Species.is_larger(self.attacker, self.defender), -1)
# Same population different food
self.attacker.population = 2
self.defender.food = 2
self.attacker.food = 1
self.assertEqual(Species.is_larger(self.defender, self.attacker), 1)
self.assertEqual(Species.is_larger(self.attacker, self.defender), -1)
# Same population and food different body
self.attacker.food = 2
self.defender.body = 4
self.attacker.body = 3
self.assertEqual(Species.is_larger(self.defender, self.attacker), 1)
self.assertEqual(Species.is_larger(self.attacker, self.defender), -1)
# Equal population, food, and body
self.attacker.body = 4
self.assertEqual(Species.is_larger(self.defender, self.attacker), 0)