Пример #1
0
 def test_delete_volume(cls, data):
     extra_data = {}
     extra_data.update(data)
     order_id = CommonMethods.post_volume(extra_data)
     if not order_id:
         print('  Test Failed. Volume was not created')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     get_response = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_volume)
     if (get_response.status_code == GeneralConfigurations.not_found_status
         ):
         print('  Test Failed. Volume was not found')
         return
     CommonMethods.delete_order(order_id, GeneralConfigurations.type_volume)
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     get_response = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_volume)
     if (get_response.status_code !=
             GeneralConfigurations.not_found_status):
         print('  Failed. Expecting http status %d, but got: %d' %
               (GeneralConfigurations.not_found_status,
                get_response.status_code))
         return
     print('  Ok. Volume removed')
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(30)
     else:
         time.sleep(10)
Пример #2
0
 def test_get_by_id_network(cls, data):
     extra_data = {}
     extra_data.update(data)
     fake_id = 'fake-id'
     response_get = CommonMethods.get_order_by_id(
         fake_id, GeneralConfigurations.type_network)
     if response_get.status_code != GeneralConfigurations.not_found_status:
         print('  Failed. Expecting %d status, but got: %d' %
               (GeneralConfigurations.not_found_status,
                response_get.status_code))
         return
     order_id = CommonMethods.post_network(extra_data)
     if not order_id:
         print('  Failed when creating network, trying next test')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     response_get = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_network)
     if response_get.status_code == GeneralConfigurations.ok_status:
         print('  Ok. Removing network')
     else:
         print(
             '  Failed. Expecting %d status, but got: %d. Removing network'
             % (GeneralConfigurations.ok_status, response_get.status_code))
     CommonMethods.delete_order(order_id,
                                GeneralConfigurations.type_network)
     time.sleep(10)
Пример #3
0
    def player_close_attack(self, _damage, _range):
        # 获取6位判定点
        _index = [
            self.player.face_to_index, self.player.face_to_index - 1,
            self.player.face_to_index + 1
        ]
        if _index[2] > 7:
            _index[2] = 0
        _points = []
        for i in range(0, 3):
            _points.append((self.player.pos_pixel_x +
                            self.player.FACE_TO[_index[i]][0] * _range,
                            self.player.pos_pixel_y +
                            self.player.FACE_TO[_index[i]][1] * _range))
            _points.append((self.player.pos_pixel_x +
                            self.player.FACE_TO[_index[i]][0] * _range * 2,
                            self.player.pos_pixel_y +
                            self.player.FACE_TO[_index[i]][1] * _range * 2))
        _points.append((self.player.pos_pixel_x, self.player.pos_pixel_y))

        # 检查被命中unit
        for _unit in self.awake_units:
            _x_range = (_unit.pos_pixel_x - _unit.collision_half_width,
                        _unit.pos_pixel_x + _unit.collision_half_width)
            _y_range = (_unit.pos_pixel_y - 2 * _unit.collision_half_height,
                        _unit.pos_pixel_y)
            for i in range(0, 6):
                if _x_range[0] < _points[i][0] < _x_range[1] and _y_range[
                        0] < _points[i][1] < _y_range[1]:
                    CommonMethods.handle_mixer('spl Hit 1', self)
                    if 'hp' in _unit.data:
                        _unit.data['hp'] -= _damage
                    break
Пример #4
0
 def test_post_volumes(cls, data):
     extra_data = {}
     extra_data.update(data)
     order_id = CommonMethods.post_volume(extra_data)
     if not order_id:
         print('  Failed, volume was not created')
         return
     if CommonMethods.wait_instance_ready(
             order_id, GeneralConfigurations.type_volume):
         print('  Ok. Removing volume')
     else:
         print('  Failed. Removing volume')
     CommonMethods.delete_order(order_id, GeneralConfigurations.type_volume)
 def test_get_by_id_images(cls, data):
     extra_data = {}
     extra_data.update(data)
     response_get_all = CommonMethods.get_all_order(
         GeneralConfigurations.type_image)
     images_id = list(response_get_all.json().keys())
     random_id = random.choice(images_id)
     response_get = CommonMethods.get_order_by_id(
         random_id, GeneralConfigurations.type_image)
     if response_get.status_code != GeneralConfigurations.ok_status:
         print("  Failed. Expected status %d, but got %d" %
               (GeneralConfigurations.ok_status, response_get.status_code))
         return
     print('  Ok')
Пример #6
0
 def test_post_networks(cls, data):
     extra_data = {}
     extra_data.update(data)
     order_id = CommonMethods.post_network(extra_data)
     if not order_id:
         print('  Failed. Could not create network')
         return False
     if CommonMethods.wait_instance_ready(
             order_id, GeneralConfigurations.type_network):
         print('  Ok. Removing network')
     else:
         print('  Failed. Network was not ready')
     CommonMethods.delete_order(order_id,
                                GeneralConfigurations.type_network)
Пример #7
0
 def test_delete_network(cls, data):
     extra_data = {}
     extra_data.update(data)
     order_id = CommonMethods.post_network(extra_data)
     if not order_id:
         print('  Failed. Could not crete network')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     get_response = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_network)
     if (get_response.status_code == GeneralConfigurations.not_found_status
         ):
         print('  Failed. Got http status: %d' % (get_response.status_code))
         CommonMethods.delete_order(order_id,
                                    GeneralConfigurations.type_network)
         return
     CommonMethods.delete_order(order_id,
                                GeneralConfigurations.type_network)
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(30)
     get_response = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_network)
     if (get_response.status_code !=
             GeneralConfigurations.not_found_status):
         print('  Failed. Got http status %d and was expected: %d' %
               (get_response.status_code,
                GeneralConfigurations.not_found_status))
         return
     print('  Ok. Network removed')
     time.sleep(10)
Пример #8
0
 def test_post_compute(cls, data):
     extra_data = {}
     extra_data.update(data)
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if not CommonMethods.wait_compute_available(1, member):
         print('  Failed. There is not %d instance(s) available.' % 1)
         return
     order_id = CommonMethods.post_compute(extra_data)
     if not order_id:
         print('  Failed, trying next test')
         return
     if cls.wait_instance_ready(order_id,
                                GeneralConfigurations.type_compute):
         print('  Ok. Removing compute')
     else:
         print('  Failed. Removing compute')
     CommonMethods.delete_order(order_id,
                                GeneralConfigurations.type_compute)
Пример #9
0
 def update_continuous_events(self):
     # 处理帧模式持续事件
     for event in self.f_event_list:
         _method_str = event[0]
         CommonMethods.handle_interact(_interact_str=_method_str,
                                       _data=self)
         event[1] -= 1
         if event[1] <= 0:
             self.f_event_list.remove(event)
     # 处理秒模式持续事件
     if self.frames % 30 == 0:
         for event in self.s_event_list:
             _method_str = event[0]
             CommonMethods.handle_interact(_interact_str=_method_str,
                                           _data=self)
             event[1] -= 1
             if event[1] <= 0:
                 self.s_event_list.remove(event)
     # 处理10帧模式延时事件
     if self.frames % 10 == 0:
         for event in self.d_event_list:
             if event[1] <= 0:
                 _method_str = event[0]
                 CommonMethods.handle_interact(_interact_str=_method_str,
                                               _data=self)
                 self.d_event_list.remove(event)
             else:
                 event[1] -= 1
Пример #10
0
 def test_quota(cls, data):
     extra_data = {}
     extra_data.update(data)
     response_get_quota = None
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if GeneralConfigurations.provider in data:
         #if remote
         response_get_quota = CommonMethods.get_quota(
             data[GeneralConfigurations.provider])
     else:
         response_get_quota = CommonMethods.get_quota(member)
     if response_get_quota.status_code != GeneralConfigurations.ok_status:
         print('  Failed. Got HTTP status: %d and message: %s' %
               (response_get_quota.status_code, response_get_quota.text))
         return
     #review this test
     if response_get_quota.json() != '':
         print('  Ok')
     else:
         print('  Failed, trying next test')
Пример #11
0
 def test_get_all_networks(cls, data):
     extra_data = {}
     extra_data.update(data)
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_network)
     time.sleep(10)
     if response_get.status_code != GeneralConfigurations.ok_status or response_get.text != '[]':
         print(
             '  Failed. There was a network created already. Received http status %d and message: %s'
             % (response_get.status_code, response_get.text))
         return
     orders_id = CommonMethods.post_multiple_orders(
         extra_data, GeneralConfigurations.max_networks,
         GeneralConfigurations.type_network)
     if not orders_id:
         print('  Failed. Could not create networks')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_network)
     test_ok = not (
         response_get.status_code != GeneralConfigurations.ok_status
         or response_get.text == '[]'
         or len(response_get.json()) != GeneralConfigurations.max_networks)
     if test_ok:
         print('  Ok. Removing networks')
     else:
         print('  Failed. Removing networks')
     CommonMethods.delete_multiple_orders(
         orders_id, GeneralConfigurations.type_network)
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(40)
     else:
         time.sleep(10)
 def test_get_all_images(cls, data):
     extra_data = {}
     extra_data.update(data)
     response_get_all = CommonMethods.get_all_order(
         GeneralConfigurations.type_image)
     if response_get_all.status_code != GeneralConfigurations.ok_status:
         print("  Failed. Expected status %d, but got %d" %
               (GeneralConfigurations.ok_status,
                response_get_all.status_code))
         return
     images_id = response_get_all.json().keys()
     if (len(images_id) <= 0):
         print(
             "  Failed. Expected at least 1 imageId available, but got %d" %
             len(images_id))
         return
     print('  Ok')
Пример #13
0
 def test_get_by_id_compute(cls, data):
     extra_data = {}
     extra_data.update(data)
     fake_id = 'fake-id'
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if not CommonMethods.wait_compute_available(
             GeneralConfigurations.max_computes, member):
         print('  Failed. There is not %d instances available.' %
               GeneralConfigurations.max_computes)
         return
     response_get = CommonMethods.get_order_by_id(
         fake_id, GeneralConfigurations.type_compute)
     if response_get.status_code != GeneralConfigurations.not_found_status:
         print('  Failed. Expecting %d status, but got: %d' %
               (GeneralConfigurations.not_found_status,
                response_get.status_code))
         return
     order_id = CommonMethods.post_compute(extra_data)
     if not order_id:
         print('  Failed when creating compute, trying next test')
         CommonMethods.delete_order(order_id,
                                    GeneralConfigurations.type_compute)
         #time to wait order to be deleted
         time.sleep(20)
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     response_get = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_compute)
     if response_get.status_code == GeneralConfigurations.ok_status:
         print('  Ok. Removing compute')
     else:
         print(
             '  Failed. Expecting %d status, but got: %d. Removing compute'
             % (GeneralConfigurations.ok_status, response_get.status_code))
     CommonMethods.delete_order(order_id,
                                GeneralConfigurations.type_compute)
     #time to wait order to be deleted
     time.sleep(20)
Пример #14
0
 def wait_instance_ready(cls, order_id, order_type):
     state_key = 'state'
     ready_state = 'READY'
     for x in range(GeneralConfigurations.max_tries + 1):
         response = CommonMethods.get_order_by_id(order_id, order_type)
         if response.status_code != GeneralConfigurations.ok_status:
             if (x < GeneralConfigurations.max_tries):
                 time.sleep(GeneralConfigurations.sleep_time_secs)
                 continue
             return False
         json_response = response.json()
         if json_response[state_key] != ready_state:
             if (x < GeneralConfigurations.max_tries):
                 time.sleep(GeneralConfigurations.sleep_time_secs)
                 continue
             return False
         break
     return True
Пример #15
0
 def test_allocation(cls, data):
     extra_data = {}
     extra_data.update(data)
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if not CommonMethods.wait_compute_available(
             GeneralConfigurations.max_computes, member):
         print('  Failed. There is not %d instances available.' %
               GeneralConfigurations.max_computes)
         return
     response_get_allocation = cls.get_allocation(member)
     if response_get_allocation.status_code != 200:
         print('  Failed, trying next test')
         return
     if not cls.empty_allocation(response_get_allocation.json()):
         print(response_get_allocation.json())
         print('  Failed, allocationMode already in use, trying next test')
         return
     orders_id = CommonMethods.post_multiple_orders(
         extra_data, GeneralConfigurations.max_computes,
         GeneralConfigurations.type_compute)
     if not orders_id:
         print('  Failed. Could not create computes')
         return
     for order in orders_id:
         cls.wait_instance_ready(order, GeneralConfigurations.type_compute)
     response_get_allocation = cls.get_allocation(member)
     allocationMode = response_get_allocation.json()
     if cls.empty_allocation(allocationMode):
         CommonMethods.delete_multiple_orders(
             orders_id, GeneralConfigurations.type_compute)
         print(
             '  Failed. Allocation was not in use. Actual allocationMode was: %s'
             % allocationMode)
         return
     if allocationMode['instances'] == GeneralConfigurations.max_computes:
         print('  Ok. Removing compute')
     else:
         print('  Failed. Removing compute')
     CommonMethods.delete_multiple_orders(
         orders_id, GeneralConfigurations.type_compute)
Пример #16
0
 def test_delete_compute(cls, data):
     extra_data = {}
     extra_data.update(data)
     order_id = CommonMethods.post_compute(extra_data)
     if not order_id:
         print('  Failed. Could not create a compute')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     get_response = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_compute)
     if (get_response.status_code != GeneralConfigurations.ok_status):
         print(get_response.status_code)
         CommonMethods.delete_order(order_id,
                                    GeneralConfigurations.type_compute)
         #time to wait order to be deleted
         time.sleep(20)
         print('  Failed. Could not get order by id')
         return
     CommonMethods.delete_order(order_id,
                                GeneralConfigurations.type_compute)
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait delete request to be received
         time.sleep(10)
     get_response = CommonMethods.get_order_by_id(
         order_id, GeneralConfigurations.type_compute)
     if (get_response.status_code !=
             GeneralConfigurations.not_found_status):
         print(' Failed. Expected %d HTTP status, but got: %d' %
               (GeneralConfigurations.not_found_status,
                get_response.status_code))
         return
     print('  Ok. Compute removed')
     #time to wait order to be deleted
     time.sleep(20)
Пример #17
0
 def test_get_all_compute(cls, data):
     extra_data = {}
     extra_data.update(data)
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if not CommonMethods.wait_compute_available(
             GeneralConfigurations.max_computes, member):
         print('  Failed. There is not %d instances available.' %
               GeneralConfigurations.max_computes)
         return
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_compute)
     if response_get.status_code != GeneralConfigurations.ok_status or response_get.text != '[]':
         print(
             '  Failed. Wrong status in get request, got status: %d, and message: %s'
             % (response_get.status_code, response_get.text))
         return
     orders_id = CommonMethods.post_multiple_orders(
         extra_data, GeneralConfigurations.max_computes,
         GeneralConfigurations.type_compute)
     if not orders_id:
         print('  Failed. Could not create computes')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_compute)
     test_ok = not (
         response_get.status_code != GeneralConfigurations.ok_status
         or response_get.text == '[]'
         or len(response_get.json()) != GeneralConfigurations.max_computes)
     if test_ok:
         print('  Ok. Removing computes')
     else:
         print('  Failed. Removing computes')
     CommonMethods.delete_multiple_orders(
         orders_id, GeneralConfigurations.type_compute)
Пример #18
0
 def test_post_compute_with_private_network(cls, data):
     extra_data_network = {}
     extra_data_network.update(data)
     networks = []
     network_id = CommonMethods.post_network(extra_data_network)
     networks.append(network_id)
     if not network_id:
         CommonMethods.delete_order(network_id,
                                    GeneralConfigurations.type_network)
         print('  Failed, could not create new network')
         return
     if not cls.wait_instance_ready(network_id,
                                    GeneralConfigurations.type_network):
         print('  Failed. Network did not transitioned to \'ready\' state')
         CommonMethods.delete_order(network_id,
                                    GeneralConfigurations.type_network)
         return
     extra_data_compute = {GeneralConfigurations.networksId_key: networks}
     extra_data_compute.update(data)
     compute_id = CommonMethods.post_compute(extra_data_compute)
     if not compute_id:
         CommonMethods.delete_order(network_id,
                                    GeneralConfigurations.type_network)
         print('  Failed, could not create new compute')
         return
     #for now, we do not check any get, because fogbow-core doesn't provide the extra network interface for users
     if cls.wait_instance_ready(compute_id,
                                GeneralConfigurations.type_compute):
         print('  Ok. Removing compute and network')
     else:
         print('  Failed. Removing compute and network')
     response_get = CommonMethods.get_order_by_id(
         compute_id, GeneralConfigurations.type_compute)
     CommonMethods.delete_order(compute_id,
                                GeneralConfigurations.type_compute)
     CommonMethods.delete_order(network_id,
                                GeneralConfigurations.type_network)
Пример #19
0
    def __init__(self):
        # 初始化设置 settings
        self.settings = settings.Settings(800, 600)
        # 初始化字典 dictionary
        self.dictionary = dictionary.Dictionary()
        # 强化学习q-table
        self.q_table_close_hit_time = [80, 80, 20, 30, 100]
        self.q_table_close_shoot_time = [100, 100, 100, 100, 100]
        self.q_table_far_hit_time = [0, 0, 50, 50, 100]
        self.q_table_far_shoot_time = [100, 100, 100, 100, 100]
        self.Q_TABLE_SKILL_NAME = [
            'SmallFire', 'FireSurroundBlast', 'FireBall', 'FireStorm',
            'MapFire'
        ]
        self.Q_TABLE_SKILL_DAMAGE = [20, 100, 20, 50, 1000]
        self.NEXT_RATIO = 0.1
        # 初始化玩家 player
        self.player = player.Player()
        # 初始化主环境 main_environment
        self.main_environment = environment.Environment(
            name='main',
            matrix_width=256,
            matrix_height=256,
            _dictionary=self.dictionary)
        self.main_environment.SURROUND_GROUND = 'Blue'
        self.main_environment.MAIN_GROUND = 'Grass'
        self.main_environment.GROUND_NAME_LIST = [
            'Grass', 'Forest', 'Clay', 'YellowGrass', 'Snow', 'Swamp',
            'Autumn', 'Blue'
        ]
        self.main_environment.BLOCK_NAME_LIST = [
            'Rock', 'Flint', 'Twig', 'CutGrass', 'Apple', 'Carrot',
            'RedMushroom', 'BlueMushroom', 'Pepper', 'Decorate', 'Tree',
            'GoldStone', 'BoneHeap', 'ClayStone'
        ]
        self.main_environment.BLOCK_CHANCE_LIST = [
            [25, 25, 25, 25, 25, 25, 25, 5, 5, 100, 25, 5, 5, 5],  # Grass
            [5, 5, 50, 25, 50, 0, 25, 5, 5, 100, 100, 0, 0, 0],  # Forest
            [75, 75, 5, 5, 0, 0, 10, 0, 5, 100, 0, 20, 20, 20],  # Clay
            [25, 25, 25, 25, 25, 25, 25, 5, 5, 100, 50, 5, 5,
             5],  # YellowGrass
            [25, 25, 25, 25, 25, 25, 10, 0, 5, 100, 50, 5, 0, 0],  # Snow
            [25, 25, 25, 25, 25, 25, 25, 10, 5, 100, 50, 5, 50, 0],  # Swamp
            [25, 25, 25, 25, 25, 25, 25, 5, 5, 100, 50, 5, 5, 5],  # Autumn
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]  # Blue
        ]
        self.main_environment.randomize_ground()
        self.main_environment.add_sand()
        self.main_environment.randomize_block()
        for i in range(0, 100):
            self.main_environment.units.append(
                unit.Unit('Deer', self.dictionary))
            mx, my = self.main_environment.get_random_xy()
            self.main_environment.units[
                -1].pos_pixel_x, self.main_environment.units[
                    -1].pos_pixel_y = CommonMethods.pos_matrix_to_pos_pixel(
                        mx, my)
            self.main_environment.units[-1].data['speed'] = 5
            self.main_environment.units[-1].data['hp'] = 20
            self.main_environment.units[-1].data['movement'] = (0, 0)
            self.main_environment.units[-1].data['alert_distance'] = 0
            self.main_environment.units[-1].data['drop_thing'] = 'Meat'
            self.main_environment.units[-1].data['face'] = 0
        for i in range(0, 4):
            mx, my = self.main_environment.get_random_xy()
            self.main_environment.block[mx][my] = environment.Block(
                'HellDoor', self.dictionary.block_dict)

        mx, my = self.main_environment.get_random_xy()
        self.player.pos_pixel_x, self.player.pos_pixel_y = CommonMethods.pos_matrix_to_pos_pixel(
            mx, my)
        self.player.pos_matrix_x, self.player.pos_matrix_y = mx, my

        # 初始化地狱环境 hell_environment
        self.hell_environment = environment.Environment(
            name='hell',
            matrix_width=64,
            matrix_height=96,
            _dictionary=self.dictionary)
        self.hell_environment.SURROUND_GROUND = 'Red'
        self.hell_environment.MAIN_GROUND = 'Stone'
        self.hell_environment.GROUND_NAME_LIST = [
            'Stone', 'Deep Stone', 'Hell', 'Obsidian'
        ]
        self.hell_environment.randomize_hell_ground()
        self.hell_environment.randomize_block()

        self.hell_environment.units.append(unit.Unit('PigMan',
                                                     self.dictionary))
        mx, my = self.hell_environment.get_random_xy_2()
        self.hell_environment.units[
            -1].pos_pixel_x, self.hell_environment.units[
                -1].pos_pixel_y = CommonMethods.pos_matrix_to_pos_pixel(
                    mx, my)
        self.hell_environment.units[-1].data['attack_cd'] = False
        self.hell_environment.units[-1].data['attack'] = 5
        self.hell_environment.units[-1].data['speed'] = 5
        self.hell_environment.units[-1].data['hp'] = 600
        self.hell_environment.units[-1].data['movement'] = (0, 0)
        self.hell_environment.units[-1].data['alert_distance'] = 5000
        self.hell_environment.units[-1].data['drop_thing'] = 'RedMushroom'
        self.hell_environment.units[-1].data['face'] = 0
        self.hell_environment.units[-1].data['action'] = 1
        for str in self.Q_TABLE_SKILL_NAME:
            self.hell_environment.units[-1].data[str] = False
            self.hell_environment.units[-1].data[str + 'CD'] = False
        # 家
        self.home_index_dict = dict()
        self.homes = []

        # 当前绘制场景为main_environment
        self.environment = self.main_environment
        self.transforming = False
        self.fighting_boss = False
        self.victory = False
        self.next_environment = ''
        self.player_next_pos_pixel_x = 0
        self.player_next_pos_pixel_y = 0

        # 初始化awake_units
        self.awake_units = []
        self.colliding_unit = ''

        # 初始化储物箱box
        self.box_items = dict()
        self.box_items_count = dict()

        # 初始化ui控制变量
        self.show_box_ui = False
        self.show_ex_items_ui = False

        # 初始化常量
        self.PLAYER_SCREEN_OFFSET = (
            int(self.settings.get_screen_width() / 2) - 20,  # 玩家屏幕偏移
            int(self.settings.get_screen_height() / 2) - 40)
        self.UNIT_SCREEN_OFFSET = (int(self.settings.get_screen_width() / 2),
                                   int(self.settings.get_screen_height() / 2))
        self.ONE_DAY_FRAMES = 2000
        self.CHECK_AWAKE_UNITS_X = 500
        self.CHECK_AWAKE_UNITS_Y = 400

        # 初始化计时器
        self.frames = 0
        self.frame_time_sec = 0
        self.frame_time_min = 0
        self.frame_time_hour = 0
        self.night = False

        # 初始化滤镜
        self.filter_name = 'Day'

        # 初始化延时事件集合
        self.f_event_list = []
        self.s_event_list = []
        self.d_event_list = []