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


Python Species.setFatFood方法代码示例

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


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

示例1: parse_species

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import setFatFood [as 别名]
def parse_species(species_json):
	"""
	converts from a json representation of species to a species representation
	:param species_json: Species+
	:return: Species
	"""
	try:
		if (len(species_json) == 5):
			[[f, food], [b, body], [p, population], [t, lot], [fb, fat_food]] = species_json
			if (f == "food" and b == "body" and p == "population" and t == "traits" and fb == "fat-food"):
				species = Species(food, body, population, parse_lot(lot))
				if fat_food == 0:
					return species
				species.setFatFood(fat_food)
				return species
		else:
			[[f, food], [b, body], [p, population], [t, lot]] = species_json
			if (f == "food" and b == "body" and p == "population" and t == "traits"):
				return Species(food, body, population, parse_lot(lot))
	except ValueError:
		raise ValueError("invalid species")
开发者ID:mahaalkhairy,项目名称:Evolution,代码行数:23,代码来源:parse_json.py

示例2: TestProxyDealer

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import setFatFood [as 别名]
class TestProxyDealer(unittest.TestCase):
  def setUp(self):
    self.pDealer = ProxyDealer()

    self.card1 = TraitCard(Trait.ambush, -2)
    self.card2 = TraitCard(Trait.carnivore, -8)
    self.card3 = TraitCard(Trait.ambush, 0)

    self.species1 = Species(0, 3, 3, [])
    self.species2 = Species(0, 2, 1, [])
    self.speciesscavenger = Species(0, 3, 3, [Trait.scavenger])
    self.speciesforaging = Species(0, 3, 3, [Trait.foraging])
    self.speciescoop = Species(0, 3, 3, [Trait.cooperation])
    self.speciesfull = Species(2, 2, 2, [])
    self.speciesfull1 = Species(3, 2, 3, [])
    self.speciesfull2 = Species(4, 2, 4, [])
    self.speciesfat= Species(0, 3, 3, [Trait.fat_tissue])
    self.speciesfat.setFatFood(1)
    self.specieshorns = Species(0, 3, 3, [Trait.horns])
    self.speciescarni = Species(0, 3, 3, [Trait.carnivore])
    self.specieshorns1 = Species(0, 3, 1, [Trait.horns])
    self.speciescarni1 = Species(0, 3, 1, [Trait.carnivore])
    self.speciesLongFertile = Species(0, 3, 1, [Trait.long_neck, Trait.fertile])
    self.speciesFertile = Species(0, 3, 1, [Trait.fertile])
    self.speciesLongNeck = Species(0, 3, 1, [Trait.long_neck])

  def tearDown(self):
    del self.pDealer

  def testNew(self):
    pass

  def testStart(self):
    self.pDealer.new("TODO")
    self.pDealer.start(json.dumps([12,
                                    [[["food",2],
                                          ["body",2],
                                          ["population",2],
                                          ["traits",["carnivore"]]]],
                                    [[2, "long-neck"]]]))
    self.assertEqual(self.pDealer.getExternalPlayer().getFoodBag(), 12)
    self.assertEqual(len(self.pDealer.getExternalPlayer().getSpeciesBoards()), 1)
    self.assertEqual(self.pDealer.getExternalPlayer().getSpeciesBoards()[0].getFood(), 2)
    self.assertEqual(self.pDealer.getExternalPlayer().getSpeciesBoards()[0].getPopulation(), 2)
    self.assertEqual(self.pDealer.getExternalPlayer().getSpeciesBoards()[0].getBodySize(), 2)
    self.assertEqual(len(self.pDealer.getExternalPlayer().getSpeciesBoards()[0].getTraits()), 1)
    self.assertEqual(self.pDealer.getExternalPlayer().getSpeciesBoards()[0].getTraits()[0], Trait.carnivore)
    self.assertEqual(len(self.pDealer.getExternalPlayer().getHand()), 1)
    self.assertEqual(self.pDealer.getExternalPlayer().getHand()[0].getFoodPoints(), 2)
    self.assertEqual(self.pDealer.getExternalPlayer().getHand()[0].getTrait(), Trait.long_neck)

  def testChoose(self):
    self.pDealer.new("TODO")
    self.pDealer.start(json.dumps([12,
                                    process_output.make_los_json([self.species1, self.speciescarni1, self.speciesfat]),
                                    process_output.make_loc_json([self.card1, self.card2, self.card3])]))
    action4 = self.pDealer.choose(json.dumps([[], []]))
    self.assertEqual(action4, json.dumps([0, [],[], [[2, 1]], []]))

  def testFeedNext(self):
    self.pDealer.new("TODO")
    feeding = self.pDealer.feedNext(json.dumps([12,
                                   process_output.make_los_json([self.species1, self.speciescarni1, self.speciesfat]),
                                   process_output.make_loc_json([self.card1, self.card2, self.card3]),
                                   9,
                                   process_output.make_lolos_json([[self.speciesfull1], [self.specieshorns1], [self.species2]])
                                   ]))
    self.assertEqual(feeding, json.dumps([2, 2]))

    self.assertEqual(self.pDealer.getExternalPlayer().getFoodBag(), 12)
    self.assertEqual(len(self.pDealer.getExternalPlayer().getSpeciesBoards()), 3)
开发者ID:mahaalkhairy,项目名称:Evolution,代码行数:73,代码来源:test_proxyDealer.py

示例3: TestDealer

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import setFatFood [as 别名]
class TestDealer(unittest.TestCase):
	def setUp(self):
		self.player1 = Player(1, [], 0, info = "j")
		self.player2 = Player(2, [], 0, info = "j")
		self.player3 = Player(3, [], 0, info = "j")
		self.player4 = Player(4, [], 0, info = "j")
		self.player5 = Player(5, [], 0, info = "j")
		self.player6 = Player(6, [], 0, info = "j")
		self.player7 = Player(7, [], 0, info = "j")
		self.player8 = Player(8, [], 0, info = "j")

		self.players = [self.player1, self.player2, self.player3]
		self.players8 = [self.player1, self.player2, self.player3, self.player4, self.player5, self.player6, self.player7, self.player8]

		self.species1 = Species(0, 3, 3, [])
		self.species2 = Species(0, 2, 1, [])
		self.speciesscavenger = Species(0, 3, 3, [Trait.scavenger])
		self.speciesforaging = Species(0, 3, 3, [Trait.foraging])
		self.speciescoop = Species(0, 3, 3, [Trait.cooperation])
		self.speciesfull = Species(2, 2, 2, [])
		self.speciesfull1 = Species(3, 2, 3, [])
		self.speciesfull2 = Species(4, 2, 4, [])
		self.speciesfat= Species(0, 3, 3, [Trait.fat_tissue])
		self.speciesfat.setFatFood(1)
		self.specieshorns = Species(0, 3, 3, [Trait.horns])
		self.speciescarni = Species(0, 3, 3, [Trait.carnivore])
		self.specieshorns1 = Species(0, 3, 1, [Trait.horns])
		self.speciescarni1 = Species(0, 3, 1, [Trait.carnivore])
		self.speciesLongFertile = Species(0, 3, 1, [Trait.long_neck, Trait.fertile])
		self.speciesFertile = Species(0, 3, 1, [Trait.fertile])
		self.speciesLongNeck = Species(0, 3, 1, [Trait.long_neck])

		self.watering_hole = WateringHole(0)

		self.dealer = Dealer(self.watering_hole, self.players)

		self.warning_call_card = TraitCard(Trait.warning_call, 0)
		self.warning_call_card2 = TraitCard(Trait.warning_call, 1)
		self.climbing_card = TraitCard(Trait.climbing, 3)
		self.carnivore_card = TraitCard(Trait.carnivore, -8)

		self.fertileCard = TraitCard(Trait.fertile, 2)
		self.climbingCard = TraitCard(Trait.climbing, 0)
		self.cooperationCard = TraitCard(Trait.cooperation, 0)
		self.carnivoreCard = TraitCard(Trait.carnivore, 0)
		self.longNeckCard = TraitCard(Trait.long_neck, 0)
		self.fertileCard1 = TraitCard(Trait.fertile, 2)
		self.climbingCard1 = TraitCard(Trait.climbing, 1)
		self.cooperationCard1 = TraitCard(Trait.cooperation, 1)
		self.carnivoreCard1 = TraitCard(Trait.carnivore, 1)
		self.longNeckCard1 = TraitCard(Trait.long_neck, 1)
		self.ambushCard = TraitCard(Trait.ambush, 1)


		self.deck = [self.warning_call_card, self.climbing_card, self.carnivore_card]

		self.deck2 = deck.generateDeck()[:12]

		self.dealer.setDeck(self.deck)
		self.dealer.setWateringHole(20)




	def tearDown(self):
		del self.player1
		del self.player2
		del self.player3
		del self.players
		del self.dealer
		del self.deck
		del self.species1
		del self.speciesscavenger
		del self.speciesforaging
		del self.speciescoop
		del self.species2
		del self.speciescarni
		del self.specieshorns
		del self.carnivore_card
		del self.climbing_card
		del self.warning_call_card
		del self.speciescarni1
		del self.specieshorns1
		del self.warning_call_card2
		del self.watering_hole

	# def testSetAndGetWateringHole(self):
	# 	self.dealer.setWateringHole(9)
	# 	self.assertEqual(self.dealer.getWateringHole(), 9)

	# def testSetAndGetListOfPlayer(self):
	# 	self.dealer.setListOfPlayers(self.players)
	# 	self.assertEqual(self.dealer.getListOfPlayers(), self.players)

	# def testSetAndGetDeck(self):
	# 	self.dealer.setDeck([])
	# 	self.assertEqual(self.dealer.getDeck(), [])

	# def testRemoveCardsFromDeck(self):
	# 	self.dealer.removeCardsFromDeck([self.warning_call_card])
#.........这里部分代码省略.........
开发者ID:mahaalkhairy,项目名称:Evolution,代码行数:103,代码来源:test_dealer.py


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