def test_round_start_message(self): seats = self.__setup_seats() message = MessageBuilder.build_round_start_message(7, 1, seats) msg = message["message"] self.eq("notification", message["type"]) self.eq(MessageBuilder.ROUND_START_MESSAGE, msg["message_type"]) self.eq(7, msg["round_count"]) self.eq(DataEncoder.encode_seats(seats)["seats"], msg["seats"]) self.eq(["CA", "C2"], msg["hole_card"])
def test_round_start_message(self): seats = self.__setup_seats() message = MessageBuilder.build_round_start_message(7, 1, seats) msg = message['message'] self.eq('notification', message['type']) self.eq(MessageBuilder.ROUND_START_MESSAGE, msg['message_type']) self.eq(7, msg['round_count']) self.eq(DataEncoder.encode_seats(seats)['seats'], msg['seats']) self.eq(['2d', '3d'], msg['hole_card'])
def test_round_start_message(self): seats = self.__setup_seats() message = MessageBuilder.build_round_start_message(7, 1, seats) msg = message["message"] self.eq("notification", message["type"]) self.eq(MessageBuilder.ROUND_START_MESSAGE, msg["message_type"]) self.eq(7, msg["round_count"]) self.eq(DataEncoder.encode_seats(seats)["seats"], msg["seats"]) self.eq(["CA", "C2"], msg["hole_card"])
def build_round_start_message(self, round_count, player_pos, seats): player = seats.players[player_pos] hole_card = DataEncoder.encode_player(player, holecard=True)["hole_card"] message = { "message_type": self.ROUND_START_MESSAGE, "round_count": round_count, "hole_card": hole_card } message.update(DataEncoder.encode_seats(seats)) return self.__build_notification_message(message)
def build_round_start_message(self, round_count, player_pos, seats): player = seats.players[player_pos] hole_card = DataEncoder.encode_player(player, holecard=True)["hole_card"] message = { "message_type": self.ROUND_START_MESSAGE, "round_count": round_count, "hole_card": hole_card } message.update(DataEncoder.encode_seats(seats)) return self.__build_notification_message(message)
def test_encofe_game_information(self): config = { "initial_stack":100, "max_round":10, "small_blind_amount":5,\ "ante":1, "blind_structure": {1: {"ante": 3, "small_blind": 10} } } seats = setup_seats() hsh = DataEncoder.encode_game_information(config, seats) self.eq(3, hsh["player_num"]) self.eq(DataEncoder.encode_seats(seats)["seats"], hsh["seats"]) self.eq(config["small_blind_amount"], hsh["rule"]["small_blind_amount"]) self.eq(config["max_round"], hsh["rule"]["max_round"]) self.eq(config["initial_stack"], hsh["rule"]["initial_stack"]) self.eq(config["ante"], hsh["rule"]["ante"]) self.eq(config["blind_structure"], hsh["rule"]["blind_structure"])
def test_encofe_game_information(self): config = {"initial_stack": 100, "max_round": 10, "small_blind_amount": 5, \ "ante": 1, "blind_structure": {1: {"ante": 3, "small_blind": 10}}} seats = setup_seats() hsh = DataEncoder.encode_game_information(config, seats) self.eq(3, hsh["player_num"]) self.eq(DataEncoder.encode_seats(seats)["seats"], hsh["seats"]) self.eq(config["small_blind_amount"], hsh["rule"]["small_blind_amount"]) self.eq(config["max_round"], hsh["rule"]["max_round"]) self.eq(config["initial_stack"], hsh["rule"]["initial_stack"]) self.eq(config["ante"], hsh["rule"]["ante"]) self.eq(config["blind_structure"], hsh["rule"]["blind_structure"])
def test_encode_round_state(self): state = setup_round_state() state["table"].set_blind_pos(1, 3) hsh = DataEncoder.encode_round_state(state) self.eq("flop", hsh["street"]) self.eq(DataEncoder.encode_pot(state["table"].seats.players), hsh["pot"]) self.eq(DataEncoder.encode_seats(state["table"].seats)["seats"], hsh["seats"]) self.eq(["CA"], hsh["community_card"]) self.eq(state["table"].dealer_btn, hsh["dealer_btn"]) self.eq(state["next_player"], hsh["next_player"]) self.eq(1, hsh["small_blind_pos"]) self.eq(3, hsh["big_blind_pos"]) self.eq(DataEncoder.encode_action_histories(state["table"])["action_histories"], hsh["action_histories"]) self.eq(state["round_count"], hsh["round_count"]) self.eq(state["small_blind_amount"], hsh["small_blind_amount"])
def test_encode_round_state(self): state = setup_round_state() state["table"].set_blind_pos(1, 3) hsh = DataEncoder.encode_round_state(state) self.eq("flop", hsh["street"]) self.eq(DataEncoder.encode_pot(state["table"].seats.players), hsh["pot"]) self.eq( DataEncoder.encode_seats(state["table"].seats)["seats"], hsh["seats"]) self.eq(["CA"], hsh["community_card"]) self.eq(state["table"].dealer_btn, hsh["dealer_btn"]) self.eq(state["next_player"], hsh["next_player"]) self.eq(1, hsh["small_blind_pos"]) self.eq(3, hsh["big_blind_pos"]) self.eq( DataEncoder.encode_action_histories( state["table"])["action_histories"], hsh["action_histories"]) self.eq(state["round_count"], hsh["round_count"]) self.eq(state["small_blind_amount"], hsh["small_blind_amount"])
def test_encode_round_state(self): state = setup_round_state() state['table'].set_blind_pos(1, 3) hsh = DataEncoder.encode_round_state(state) self.eq('flop', hsh['street']) self.eq(DataEncoder.encode_pot(state['table'].seats.players), hsh['pot']) self.eq( DataEncoder.encode_seats(state['table'].seats)['seats'], hsh['seats']) self.eq(['2d'], hsh['community_card']) self.eq(state['table'].dealer_btn, hsh['dealer_btn']) self.eq(state['next_player'], hsh['next_player']) self.eq(1, hsh['small_blind_pos']) self.eq(3, hsh['big_blind_pos']) self.eq( DataEncoder.encode_action_histories( state['table'])['action_histories'], hsh['action_histories']) self.eq(state['round_count'], hsh['round_count']) self.eq(state['small_blind_amount'], hsh['small_blind_amount'])
def test_encofe_game_information(self): config = { 'initial_stack': 100, 'max_round': 10, 'small_blind_amount': 5, 'ante': 1, 'blind_structure': { 1: { 'ante': 3, 'small_blind': 10 } } } seats = setup_seats() hsh = DataEncoder.encode_game_information(config, seats) self.eq(3, hsh['player_num']) self.eq(DataEncoder.encode_seats(seats)['seats'], hsh['seats']) self.eq(config['small_blind_amount'], hsh['rule']['small_blind_amount']) self.eq(config['max_round'], hsh['rule']['max_round']) self.eq(config['initial_stack'], hsh['rule']['initial_stack']) self.eq(config['ante'], hsh['rule']['ante']) self.eq(config['blind_structure'], hsh['rule']['blind_structure'])
def test_encode_seats(self): seats = setup_seats() hsh = DataEncoder.encode_seats(seats) self.eq(3, len(hsh["seats"])) self.eq(DataEncoder.encode_player(seats.players[0]), hsh["seats"][0])
def test_encode_seats(self): seats = setup_seats() hsh = DataEncoder.encode_seats(seats) self.eq(3, len(hsh["seats"])) self.eq(DataEncoder.encode_player(seats.players[0]), hsh["seats"][0])