def __init__(self, player_state, watering_hole, other_player_states): """ Construct a Feeding :param player_state: The state of the player choosing the evolution :type player_state: IPlayer :param watering_hole: The number of food tokens in the watering hole :type watering_hole: int :param other_player_states: :type other_player_states: [Player, ...] :return: None """ if not isinstance(player_state, IPlayer): raise ValueError( "Feeding - constructor: Invalid PlayerState as player_state") elif not is_natural_plus(watering_hole): raise ValueError( "Feeding - constructor: Invalid NaturalPlus as watering_hole") elif not is_list_of(other_player_states, IPlayer): raise ValueError( "Feeding - constructor: Invalid List[PlayerState] as other_player_states" ) self.player_state = player_state # type: PlayerState self.player = Player() # type: Player self.watering_hole = watering_hole # type: NaturalPlus self.other_player_states = other_player_states # type: List[PlayerState]
def process_choice(py_json): """ Process the silly-player choice made for the PyJSON choice :param py_json: PyJSON Choice to be processed :type py_json: PyJSON :return: The PyJSON Action4 response :rtype: PyJSON """ (ps, before_ps, after_ps) = convert_choice_from_pj(py_json) silly_player = Player() #harness for silly player, which did not include wateringhole silly_player.start(ps, 0) choices = silly_player.get_card_choices(before_ps, after_ps) return convert_to_action4(choices)
def make_dealer(n): """ creates and returns an instance of a dealer :param n: number of players in the game :type n: Nat :return: the dealer :rtype: Dealer """ players = [Player() for i in range(n)] dealer = Dealer(players, Deck.make_deck()) return dealer
def convert_from_pj_player(pj_player): """ Convert the given PJ_Player to a PlayerState :param player_state: The player state in PyJSON :type player_state: PJ_Player :return: The PlayerState :rtype: IPlayer """ if not is_pj_player(pj_player): raise ValueError("convert_from_pj_player: Invalid PyJSON Player") return IPlayer(Player(), convert_from_id(pj_player[0]), convert_from_pj_player_species(pj_player[1]), convert_from_bag(pj_player[2]))
def make_dealer(player_states, deck, wateringhole): """ Creates a dealer with the given parameters :param player_states: the player states :type player_states: [PlayerState, ...] :param deck: the deck :type deck: Deck :param wateringhole: the watering hole :type wateringhole: Nat :return: Dealer """ players = [Player() for p in range(len(player_states))] dealer = Dealer(players, deck, wateringhole) dealer.player_states = player_states return dealer
class Feeding: """ Represents a Feeding where a Player must choose one of its Species to feed """ def __init__(self, player_state, watering_hole, other_player_states): """ Construct a Feeding :param player_state: The state of the player choosing the evolution :type player_state: IPlayer :param watering_hole: The number of food tokens in the watering hole :type watering_hole: int :param other_player_states: :type other_player_states: [Player, ...] :return: None """ if not isinstance(player_state, IPlayer): raise ValueError( "Feeding - constructor: Invalid PlayerState as player_state") elif not is_natural_plus(watering_hole): raise ValueError( "Feeding - constructor: Invalid NaturalPlus as watering_hole") elif not is_list_of(other_player_states, IPlayer): raise ValueError( "Feeding - constructor: Invalid List[PlayerState] as other_player_states" ) self.player_state = player_state # type: PlayerState self.player = Player() # type: Player self.watering_hole = watering_hole # type: NaturalPlus self.other_player_states = other_player_states # type: List[PlayerState] def player_choose_feeding(self): """ Tell the player to choice their feeder :return: The Feeding Choice of the Player :rtype: PlayerFeedingChoice or None """ return self.player.choose_feeding(self.watering_hole, self.other_player_states, self.player_state)
def __init__(self, player_state, watering_hole, other_player_states): """ Construct a Feeding :param player_state: The state of the player choosing the evolution :type player_state: IPlayer :param watering_hole: The number of food tokens in the watering hole :type watering_hole: int :param other_player_states: :type other_player_states: [Player, ...] :return: None """ if not isinstance(player_state, IPlayer): raise ValueError("Feeding - constructor: Invalid PlayerState as player_state") elif not is_natural_plus(watering_hole): raise ValueError("Feeding - constructor: Invalid NaturalPlus as watering_hole") elif not is_list_of(other_player_states, IPlayer): raise ValueError("Feeding - constructor: Invalid List[PlayerState] as other_player_states") self.player_state = player_state # type: PlayerState self.player = Player() # type: Player self.watering_hole = watering_hole # type: NaturalPlus self.other_player_states = other_player_states # type: List[PlayerState]
class Feeding: """ Represents a Feeding where a Player must choose one of its Species to feed """ def __init__(self, player_state, watering_hole, other_player_states): """ Construct a Feeding :param player_state: The state of the player choosing the evolution :type player_state: IPlayer :param watering_hole: The number of food tokens in the watering hole :type watering_hole: int :param other_player_states: :type other_player_states: [Player, ...] :return: None """ if not isinstance(player_state, IPlayer): raise ValueError("Feeding - constructor: Invalid PlayerState as player_state") elif not is_natural_plus(watering_hole): raise ValueError("Feeding - constructor: Invalid NaturalPlus as watering_hole") elif not is_list_of(other_player_states, IPlayer): raise ValueError("Feeding - constructor: Invalid List[PlayerState] as other_player_states") self.player_state = player_state # type: PlayerState self.player = Player() # type: Player self.watering_hole = watering_hole # type: NaturalPlus self.other_player_states = other_player_states # type: List[PlayerState] def player_choose_feeding(self): """ Tell the player to choice their feeder :return: The Feeding Choice of the Player :rtype: PlayerFeedingChoice or None """ return self.player.choose_feeding(self.watering_hole, self.other_player_states, self.player_state)
def __init__(self): self.player_states = ExamplePlayerStates() self.players = [Player(), Player(), Player(), Player()] self.dealer_all_veg = ExampleDealers.make_dealer(self.players[:2], [self.player_states.coop, self.player_states.fora], Deck([]), wateringhole=10) self.dealer_carn_fat = ExampleDealers.make_dealer(self.players[:2], [self.player_states.carn_fat, self.player_states.norm_pstart_2], Deck([]), wateringhole=10) self.dealer_burr_fat = ExampleDealers.make_dealer(self.players[:1], [self.player_states.burr_and_fat], Deck([]), wateringhole=10) self.dealer_carn_extinct = ExampleDealers.make_dealer(self.players[:2], [self.player_states.carn_fat, self.player_states.norm], Deck([]), wateringhole=10) self.dealer_feed_veg = ExampleDealers.make_dealer( self.players[:2], [ self.player_states.scav_and_carn_coop_and_veg, self.player_states.norm], Deck([]), wateringhole=2) self.dealer_feeding_order = ExampleDealers.make_dealer( self.players[:2], [ self.player_states.carn_scav_and_carn_coop_and_carn, self.player_states.norm], Deck([]), wateringhole=2) self.dealer_fert_long_fora = ExampleDealers.make_dealer( self.players[:2], [ self.player_states.fert_long_fora, self.player_states.norm ], Deck([]), 2 ) # Test fest self.test1_dealer = ExampleDealers.make_dealer(self.players[:3], [self.player_states.test1_player1, self.player_states.default, self.player_states.default], Deck([]), 7) self.dealer_forgo_friends = ExampleDealers.make_dealer(self.players[:2], [ self.player_states.carn_coop_and_warn, self.player_states.burr_veg], Deck([]), 3) self.dealer_step4_1 = ExampleDealers.make_dealer(self.players[:3], [self.player_states.step4_1_p1, self.player_states.step4_1_p2, self.player_states.step4_1_p3], Deck([]), 9) self.dealer_step4_2 = ExampleDealers.make_dealer(self.players[:3], [self.player_states.step4_2_p1, self.player_states.step4_2_p2, self.player_states.step4_2_p3], Deck([]), 0)
def __init__(self): self.ex_species = ExampleSpecies() self.default = IPlayer(Player(), 1) self.burr_veg = IPlayer(Player(), 2, [self.ex_species.burr_fstart1_pstart]) self.carn = IPlayer(Player(), 3, [self.ex_species.carn_default]) self.coop = IPlayer(Player(), 4, [self.ex_species.coop_default]) self.carn_coop = IPlayer(Player(), 5, [self.ex_species.carn_coop_default]) self.fat_default = IPlayer(Player(), 6, [self.ex_species.fat_default]) self.fat_min = IPlayer(Player(), 7, [self.ex_species.fat_min]) self.fat3 = IPlayer(Player(), 8, [self.ex_species.fat3]) self.fat5 = IPlayer(Player(), 9, [self.ex_species.fat5]) self.fat_max = IPlayer(Player(), 10, [self.ex_species.fat_max]) self.carn_fat = IPlayer(Player(), 11, [self.ex_species.carn_fat_default]) self.carn_fat_coop = IPlayer(Player(), 12, [ self.ex_species.carn_fat_coop_default]) self.fora = IPlayer(Player(), 13, [self.ex_species.fora_default]) self.carn_fora = IPlayer(Player(), 14, [self.ex_species.carn_fora_default]) self.burr_and_fat = IPlayer(Player(), 15, [self.ex_species.burr_fstart1_pstart, self.ex_species.fat5_fed1_b6]) self.carn_coop_and_fat = IPlayer(Player(), 16, [self.ex_species.carn_coop_default, self.ex_species.fat3_fed2_b5]) self.carn_coop_and_fat_and_fat = IPlayer(Player(), 17, [ self.ex_species.carn_coop_default, self.ex_species.fat_max_fed0_bmax, self.ex_species.fat_min_fedmax_bmax]) self.fat_and_carn_and_shell_veg = IPlayer(Player(), 18, [ self.ex_species.carn_coop_default, self.ex_species.fat_min_fedmax_bmax, self.ex_species.norm_bstartshell]) self.carn_coop_and_warn = IPlayer(Player(), 19, [ self.ex_species.carn_coop_default, self.ex_species.warn_default]) self.scav_and_carn_coop_and_veg = IPlayer( Player(), 2, [ self.ex_species.scav_default, self.ex_species.carn_coop_default, self.ex_species.norm_bstart3]) self.carn_scav_and_carn_coop_and_carn = IPlayer( Player(), 2, [ self.ex_species.carn_scav, self.ex_species.carn_coop_pstart1, self.ex_species.carn_default ] ) self.player_state_with_4 = IPlayer( Player(), 21, [self.ex_species.norm_default, self.ex_species.norm_bstart3, self.ex_species.norm_bstart4, self.ex_species.norm_fed3_p4]) self.norm = IPlayer(Player(), 1, [self.ex_species.norm_default]) self.norm_pstart_2 = IPlayer(Player(), 1, [self.ex_species.norm_pstart2]) self.fert_long_fora = IPlayer(Player(), 3, [self.ex_species.fert_long_fora]) # player states after evolution self.coop_fed = IPlayer(Player(), 4, [self.ex_species.coop_default_fed]) self.fora_fed = IPlayer(Player(), 13, [self.ex_species.fora_default_fed]) self.burr_and_fat_store = IPlayer(Player(), 15, [ self.ex_species.burr_fstart1_pstart, self.ex_species.fat6_fed1_b6]) # Player states after attacking self.carn_fat_attack = IPlayer(Player(), 11, [ self.ex_species.carn_fat_default_attack]) # player states after being attacked self.norm_pstart_2_attacked = IPlayer(Player(), 1, [ self.ex_species.norm_pstart2_attacked]) # player states with hand self.player_state_with_hand = IPlayer(Player(), 21, [self.ex_species.carn_default, self.ex_species.norm_bstart3], hand=[CarnivoreCard(1), CooperationCard(2)]) self.silly_choice_json_1 = IPlayer(Player(), 123, [self.ex_species.carn_default, self.ex_species.norm_bstart3], hand=[AmbushCard(-3), BurrowingCard(2), CarnivoreCard(3)]) self.silly_choice_json_3 = IPlayer(Player(), 34, [self.ex_species.carn_default, self.ex_species.norm_bstart3], hand=[AmbushCard(-3), BurrowingCard(2), CarnivoreCard(3), HornCard(0), PackHuntingCard(1), PackHuntingCard(2), PackHuntingCard(3)], ) # test fest self.test1_player1 = IPlayer(Player(), 1, [self.ex_species.test1_species1, self.ex_species.test1_species2, self.ex_species.test1_species3]) self.step4_1_p1 = IPlayer(Player(), 1, [self.ex_species.norm_bstart3, self.ex_species.norm_bstart3_f1, self.ex_species.carn_bstart3], hand=[CarnivoreCard(3), ClimbingCard(2)]) self.step4_1_p2 = IPlayer(Player(), 2, [copy(self.ex_species.norm_bstart3), self.ex_species.climb_bstart3], hand=[CarnivoreCard(-3), ClimbingCard(-2)]) self.step4_1_p3 = IPlayer(Player(), 3, [copy(self.ex_species.norm_bstart3_f1)], hand=[CarnivoreCard(0), ClimbingCard(0)]) self.step4_2_p1 = IPlayer(Player(), 1, [self.ex_species.coop_default_fed], hand=[CarnivoreCard(-3), ClimbingCard(2)]) self.step4_2_p2 = IPlayer(Player(), 2, [self.ex_species.fora_default_fed], hand=[CarnivoreCard(-4), ClimbingCard(-2)]) self.step4_2_p3 = IPlayer(Player(), 3, [self.ex_species.fora_default_fed], hand=[CarnivoreCard(3), ClimbingCard(0)]) self.step4_2_p3 = IPlayer(Player(), 3, [self.ex_species.fora_default_fed], hand=[CarnivoreCard(3), ClimbingCard(0), HornCard(3)]) self.attack_carnivore2 = IPlayer(Player(), 2, [Species(1,0,1,[AmbushCard(3)]), Species(1,0,2,[CarnivoreCard(-4)])]) self.attack_carnivore3 = IPlayer(Player(), 3, [Species(1,0,1,[]), Species(0,0,1,[CarnivoreCard(0)])]) self.attack_carnivore4 = IPlayer(Player(), 4, [Species(1,0,1,[]), Species(0,0,2,[CarnivoreCard(4)])]) self.attack_carnivore1 = IPlayer(Player(), 1, [Species(1,0,1,[AmbushCard(-1)]), Species(0,0,2,[CarnivoreCard(8)])])