Virtual resource distribution method and apparatus, computer device, and storage medium
Patent Information
- Application Number
- CN202310843909.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-11
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-07-11
AI Technical Summary
[0004]然而,传统方法忽略数量变化对分发虚拟资源的影响,会使得部分种类的虚拟资源先于其他种类的虚拟资源分发完,不利于保证虚拟资源的随机分发
[0039]上述虚拟资源分发方法、装置、计算机设备、存储介质和计算机程序产品,通过在分发具有多种种类的虚拟资源的过程中,在当前时刻满足预设的采样时刻的情况下,获取在当前时刻下的虚拟资源总量和目标种类的虚拟资源的剩余数量;从而在采样时刻确定各种虚拟资源的数量和虚拟资源总量,根据目标种类的虚拟资源的剩余数量与虚拟资源总量之间的比值,确定针对目标种类的虚拟资源的概率快照,从而基于虚拟资源的数量分布情况,确定各种虚拟资源的概率快照;按照概率快照,分发目标种类的虚拟资源,实现在虚拟资源分发过程中,按照采样时间对虚拟资源的数量进行统计,并基于各种虚拟资源的数量相对于虚拟资源总量的分布情况,确定目标虚拟资源的概率快照,进而基于概率快照对目标虚拟资源进行分发,能够充分考虑虚拟资源分发过程中各种虚拟资源的数量变化情况,针对性地对目标虚拟资源进行分发概率的重新制定,利用目标虚拟资源的数量分布情况确定作为新的分发概率的概率快照,进而保证虚拟资源的随机分发。
Smart Images

Figure CN116846844B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a virtual resource distribution method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] In the scenario of virtual resource distribution, the quantity of virtual resources will change continuously as the virtual resource distribution operation proceeds. Specifically, in the scenario where the virtual resource is an electronic voucher, the distribution of electronic vouchers will involve the replenishment and reduction of some types of electronic vouchers. At this time, it is necessary to consider the balance problem of the electronic voucher distribution system.
[0003] In traditional technologies, virtual resource distribution can ignore changes in the quantity of virtual resources, meaning it is always distributed in a specific manner.
[0004] However, traditional methods ignore the impact of quantity changes on the distribution of virtual resources, which may cause some types of virtual resources to be distributed before other types of virtual resources, making it difficult to ensure the random distribution of virtual resources. Summary of the Invention
[0005] Therefore, it is necessary to provide a virtual resource distribution method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can guarantee the random distribution of virtual resources, addressing the aforementioned technical problems.
[0006] Firstly, this application provides a virtual resource distribution method, the method comprising:
[0007] In the process of distributing virtual resources of various types, if the current time meets the preset sampling time, the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time are obtained; the total amount of virtual resources is the sum of the remaining amounts of the various types of virtual resources.
[0008] A probability snapshot of the virtual resources for the target type is determined based on the ratio between the remaining quantity of virtual resources of the target type and the total quantity of virtual resources.
[0009] The virtual resources of the target type are distributed according to the probability snapshot.
[0010] In one embodiment, the method further includes:
[0011] Obtain a sampling time mapping table; the sampling time mapping table is used to represent the mapping relationship between various types of virtual resources and the corresponding sampling time intervals of the various types of virtual resources;
[0012] Based on the sampling time mapping table, determine the sampling time interval for the virtual resources of the target type;
[0013] The sampling time is determined based on the sampling time interval.
[0014] In one embodiment, determining the sampling time interval for the virtual resource of the target type includes:
[0015] Obtain the current distribution speed of the virtual resources of the target type;
[0016] If the current distribution speed is greater than a preset distribution speed threshold, determine the adjustment amount of the sampling time interval for the virtual resources of the target type;
[0017] The initial sampling time interval is adjusted according to the sampling time interval adjustment amount to obtain the sampling time interval; the sampling time interval is negatively correlated with the current distribution speed.
[0018] In one embodiment, determining the sampling time based on the sampling time interval includes:
[0019] Obtain the initial sampling time for the virtual resources of the target type;
[0020] Based on the sampling time interval, the sampling interval duration for the sampling time is determined; the sampling interval duration is a positive integer multiple of the sampling time interval.
[0021] The sampling time is determined based on the initial sampling time and the sampling interval duration.
[0022] In one embodiment, obtaining the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current moment includes:
[0023] A resource quantity query request is sent to the server; in response to the resource quantity query request, the server calculates the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time; the server uses the total amount of virtual resources and the remaining amount of virtual resources of the target type as resource quantity information.
[0024] The resource quantity information returned by the server is parsed to determine the total amount of virtual resources and the remaining quantity of the target type of virtual resources at the current moment.
[0025] In one embodiment, the method further includes:
[0026] A resource acquisition request is sent to the server; in response to the resource acquisition request, the server selects one type of virtual resource from the various types of virtual resources as the target type of virtual resource; the server acquires the resource content information of the target type of virtual resource; the selection probability corresponding to the target type of virtual resource satisfies a probability snapshot for the target type of virtual resource;
[0027] The resource content information returned by the server is displayed to the user according to the preset display method.
[0028] In one embodiment, the method further includes:
[0029] Obtain the current probability snapshot weight corresponding to the probability snapshot at the current time and the previous probability snapshot weight corresponding to the probability snapshot at the previous sampling time corresponding to the current time;
[0030] Based on the current probability snapshot weight and the previous probability snapshot weight, the probability snapshot at the current time and the probability snapshot at the previous sampling time corresponding to the current time are weighted and summed to obtain a weighted probability snapshot.
[0031] The virtual resources of the target type are distributed according to the weighted probability snapshot.
[0032] Secondly, this application also provides a virtual resource distribution device, the device comprising:
[0033] The quantity acquisition module is used to acquire, during the distribution of virtual resources of various types, the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time, provided that a preset sampling time is met at the current time; the total amount of virtual resources is the sum of the remaining amounts of the various types of virtual resources.
[0034] The snapshot determination module is used to determine a probabilistic snapshot of the virtual resources of the target type based on the ratio between the remaining quantity of virtual resources of the target type and the total quantity of virtual resources.
[0035] The resource distribution module is used to distribute virtual resources of the target type according to the probability snapshot.
[0036] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program that, when executed by the processor, implements the steps of the method described above.
[0037] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the above-described method.
[0038] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the above-described method.
[0039] The aforementioned virtual resource distribution method, apparatus, computer equipment, storage medium, and computer program product, during the distribution of virtual resources of various types, obtains the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time, assuming a preset sampling time is met. This allows for the determination of the quantity and total amount of various virtual resources at the sampling time. Based on the ratio between the remaining quantity of virtual resources of the target type and the total amount of virtual resources, a probability snapshot of the target type of virtual resources is determined. This, in turn, determines the probability snapshots of various virtual resources based on their quantity distribution. The target type of virtual resources are then distributed according to these probability snapshots. This process involves statistically analyzing the quantity of virtual resources at the sampling time and determining the probability snapshot of the target virtual resources based on the distribution of the quantity of various virtual resources relative to the total amount of virtual resources. The distribution of the target virtual resources based on these probability snapshots fully considers the changes in the quantity of various virtual resources during the distribution process, allowing for a targeted redefinition of the distribution probability of the target virtual resources. The probability snapshot, determined using the quantity distribution of the target virtual resources, serves as the new distribution probability, thus ensuring the random distribution of virtual resources. Attached Figure Description
[0040] Figure 1 This is an application environment diagram of a virtual resource distribution method in one embodiment;
[0041] Figure 2 This is a flowchart illustrating a virtual resource distribution method in one embodiment;
[0042] Figure 3 This is a schematic diagram of a virtual resource distribution system in one embodiment;
[0043] Figure 4 This is a schematic diagram illustrating a virtual resource distribution probability in one embodiment;
[0044] Figure 5 This is a schematic diagram illustrating another virtual resource distribution probability in one embodiment;
[0045] Figure 6 This is a structural block diagram of a virtual resource distribution device in one embodiment;
[0046] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0048] The virtual resource distribution method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, the distribution terminal 102 communicates with the server 104 via a network. A data storage system can store the data that the server 104 needs to process. The data storage system can be integrated onto the server 104 or placed on a cloud or other network server. During the distribution of virtual resources of various types, if a preset sampling time is met at the current moment, the distribution terminal 102 obtains the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current moment; the total amount of virtual resources is the sum of the remaining quantities of virtual resources of various types; the distribution terminal 102 determines a probability snapshot of the virtual resources of the target type based on the ratio between the remaining quantity of virtual resources of the target type and the total amount of virtual resources; the distribution terminal 102 distributes the virtual resources of the target type according to the probability snapshot. The distribution terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0049] In some embodiments, such as Figure 2 As shown, a virtual resource distribution method is provided. This embodiment illustrates the method applied to a terminal, but it is understood that the method can also be applied to a server, and to a system including both a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0050] Step S202: During the distribution of virtual resources of various types, if the preset sampling time is met at the current time, obtain the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time.
[0051] Among them, various types of virtual resources can refer to electronic coupons of various denominations. In practical applications, various types of virtual resources can include, but are not limited to, electronic coupons with a face value of 10, electronic coupons with a face value of 20, electronic coupons with a face value of 50, and electronic coupons with a face value of 100.
[0052] The current time can refer to the real-time time based on Beijing time.
[0053] The preset sampling time can refer to the time set in advance according to actual needs to determine when to perform virtual resource quantity statistics operation. In practical applications, there can be one or more preset sampling times, and the time difference between two adjacent sampling times is the sampling time interval.
[0054] The total amount of virtual resources can refer to the sum of the remaining quantities of various types of virtual resources.
[0055] Among them, the target type of virtual resource can refer to the research object that determines the distribution probability of virtual resources. In practical applications, the type of virtual resource to be distributed is taken as the target type of virtual resource.
[0056] The remaining quantity of virtual resources of the target type can refer to the quantity of virtual resources of the target type at the current moment. Since the distribution of virtual resources is carried out in real time, the quantity of virtual resources at each moment can be regarded as the remaining quantity of virtual resources compared to the initial quantity of virtual resources.
[0057] As an example, a virtual resource (such as electronic coupons) distribution system needs to distribute various virtual resources. During the distribution of these diverse virtual resources, the quantity of each type changes. Furthermore, if the quantity of a certain type of virtual resource increases or decreases significantly in a short period due to human error, distributing the various types of virtual resources according to the pre-set distribution probability might result in a large surplus or premature exhaustion of that type of virtual resource, affecting the random distribution of virtual resources. Therefore, the distribution probability of virtual resources needs to be revised. The distribution terminal obtains the current time. If the current time meets the preset sampling time, the distribution terminal sends a resource quantity query request to the virtual resource server. The virtual resource server counts the (current remaining) quantity of each type of virtual resource and sums the remaining quantities of each type of virtual resource to obtain the total virtual resource quantity. The virtual resource server returns the quantity of each type of virtual resource and the total virtual resource quantity to the distribution terminal, allowing the distribution terminal to obtain the total virtual resource quantity and the remaining quantity of the target type of virtual resource at the current time.
[0058] Step S204: Determine a probability snapshot of the virtual resources for the target type based on the ratio between the remaining quantity of virtual resources of the target type and the total amount of virtual resources.
[0059] Among them, the probability snapshot can refer to data that characterizes the distribution probability of virtual resources of the target type. In practical applications, the probability snapshot can include the ratio between the remaining quantity of virtual resources of the target type and the total amount of virtual resources.
[0060] As an example, based on a greedy algorithm, it is assumed that the distribution (or probability distribution) of the number of virtual resources does not change during the time period between the current sampling time and the next sampling time. The distribution terminal calculates the ratio between the remaining quantity of virtual resources of the target type and the total amount of virtual resources, and uses this ratio as a probability snapshot of virtual resources for the target type.
[0061] Step 206: Distribute virtual resources of the target type according to the probability snapshot.
[0062] As an example, the distribution terminal uses a probability snapshot of virtual resources for a target type as the distribution probability of virtual resources for that target type. The distribution terminal distributes virtual resources of the target type according to the probability snapshot of virtual resources for the target type. In a specific implementation, the distribution probability can refer to the probability snapshot of virtual resources for the target type when randomly selecting a virtual resource from various types of virtual resources as the virtual resource to be distributed to the user account.
[0063] In the aforementioned virtual resource distribution method, during the distribution of virtual resources of various types, if a preset sampling time is met at the current time, the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time are obtained. Thus, the quantity and total amount of each type of virtual resource are determined at the sampling time. Based on the ratio between the remaining quantity of virtual resources of the target type and the total amount of virtual resources, a probability snapshot of the virtual resources of the target type is determined. Based on the distribution of the quantity of virtual resources, probability snapshots of each type of virtual resource are determined. The target type of virtual resources are distributed according to the probability snapshots. This method achieves the goal of statistically analyzing the quantity of virtual resources according to the sampling time during the virtual resource distribution process, determining the probability snapshot of the target virtual resources based on the distribution of the quantity of each type of virtual resource relative to the total amount of virtual resources, and then distributing the target virtual resources based on the probability snapshots. This approach fully considers the changes in the quantity of various virtual resources during the virtual resource distribution process, specifically re-determines the distribution probability of the target virtual resources, and uses the distribution of the quantity of the target virtual resources to determine the probability snapshot as the new distribution probability, thereby ensuring the random distribution of virtual resources.
[0064] In some embodiments, the method further includes: obtaining a sampling time mapping table; determining a sampling time interval for virtual resources of a target type based on the sampling time mapping table; and determining a sampling time based on the sampling time interval.
[0065] The sampling time mapping table can be a data table used to represent the mapping relationship between various types of virtual resources and the corresponding sampling time intervals.
[0066] The sampling time interval can refer to the time difference between any two adjacent sampling times.
[0067] As an example, since the quantity or importance of various types of virtual resources may not be the same, the distribution strategies for various types of virtual resources may not be the same. For example, if it is necessary to focus on type A virtual resources, the frequency of obtaining the quantity distribution of type A virtual resources should be higher, that is, the quantity statistical interval (sampling time interval) for type A virtual resources should be shorter. Therefore, it is necessary to determine the sampling time interval for various types of virtual resources. The distribution terminal obtains the sampling time mapping table, queries the sampling time mapping table to determine the sampling time interval for the target type of virtual resources, and determines the sampling time for the target type of virtual resources based on the sampling time interval for the target type of virtual resources.
[0068] In this embodiment, by obtaining a sampling time mapping table; determining the sampling time interval for the target type of virtual resources based on the sampling time mapping table; and determining the sampling time based on the sampling time interval, it is possible to determine the quantity statistics method (sampling method) for various types of virtual resources based on the sampling time mapping table, thereby obtaining an accurate distribution of the number of virtual resources and improving the accuracy of the distribution of the number of virtual resources.
[0069] In some embodiments, determining the sampling time interval for a target type of virtual resource includes: obtaining the current distribution speed of the target type of virtual resource; if the current distribution speed is greater than a preset distribution speed threshold, determining the sampling time interval adjustment amount for the target type of virtual resource; and adjusting the preset initial sampling time interval according to the sampling time interval adjustment amount to obtain the sampling time interval.
[0070] The current distribution speed can refer to the data that characterizes the rate of change of the quantity of virtual resources of the target type. In practical applications, the current distribution speed can refer to the ratio of the difference between the quantity M1 of the virtual resources of the target type at the previous sampling time T1 and the quantity M2 at the current time T2 to the time difference between the previous sampling time and the current time. That is, the current distribution speed V1 can be expressed as (M1-M2) / (T1-T2).
[0071] The preset distribution speed threshold can refer to data used to determine whether the current distribution speed meets the actual needs. In practice, the preset distribution speed threshold can be flexibly adjusted by staff.
[0072] The sampling time interval adjustment amount can refer to adjusting the value of the data based on the duration of the sampling time interval.
[0073] The preset initial sampling time interval can refer to the initial value of the sampling time interval set by the staff in advance. In practical applications, if the sampling time interval adjustment can be expressed as t and the initial sampling time interval is t0, then the sampling time interval can be expressed as t0+t.
[0074] The sampling time interval can be negatively correlated with the current distribution speed.
[0075] As an example, the distribution terminal obtains the current distribution speed of virtual resources of a target type. For instance, the distribution terminal sends a distribution speed query request to the virtual resource server. The virtual resource server determines the current distribution speed of the virtual resources of the target type based on the ratio of the difference between the quantity of virtual resources of the target type at the previous sampling time and the quantity at the current time to the time difference between the previous sampling time and the current time. The virtual resource server returns the current distribution speed of the virtual resources of the target type to the distribution terminal. The distribution terminal compares the current distribution speed of the virtual resources of the target type with a corresponding preset distribution speed threshold. If the current distribution speed is greater than the preset distribution speed threshold, the distribution terminal determines the current distribution speed based on the sampling time interval. The negative correlation between the current distribution speeds determines the adjustment amount of the sampling time interval for the target type of virtual resources. For example, if the current distribution speed is greater than a preset distribution speed threshold, the sampling time interval adjustment amount can be negative, which shortens the sampling time interval; if the current distribution speed is less than or equal to the preset distribution speed threshold, the sampling time interval adjustment amount can be positive, which increases the sampling time interval. The distribution terminal adjusts the preset initial sampling time interval according to the sampling time interval adjustment amount to obtain the sampling time interval. The distribution terminal sends the sampling time interval to the virtual resource server, and the virtual resource server updates the sampling time interval of the corresponding type of virtual resources according to the sampling time interval.
[0076] In this embodiment, the current distribution speed of virtual resources of the target type is obtained; when the current distribution speed is greater than a preset distribution speed threshold, the sampling time interval adjustment amount of the virtual resources of the target type is determined; according to the sampling time interval adjustment amount, the preset initial sampling time interval is adjusted to obtain the sampling time interval. Based on the current distribution speed of virtual resources, the frequency of virtual resource quantity statistics can be adjusted in a timely manner, taking into account the quantity distribution and distribution speed of virtual resources in real time, and adjusting the distribution strategy to ensure the random distribution of virtual resources.
[0077] In some embodiments, determining the sampling time based on the sampling time interval includes: obtaining the initial sampling time for the virtual resource of the target type; determining the sampling interval duration for the sampling time based on the sampling time interval; and determining the sampling time based on the initial sampling time and the sampling interval duration.
[0078] The initial sampling time can refer to the moment when the quantity of virtual resources of the target type is counted for the first time.
[0079] The sampling interval duration can refer to the time difference between any two sampling moments. In practical applications, the sampling interval duration can include positive integer multiples of the sampling time interval. For example, the sampling time interval can be represented as tc. If the sampling moments of a certain type of virtual group are T1, T2, T3, T4, T5, and T6, then the sampling interval duration can include, but is not limited to, 1 time interval, 2 time interval, 3 time interval, 4 time interval, and 5 time interval; T2-T1=tc, T3-T1=2*tc, T4-T1=3*tc, T5-T1=4*tc, T6-T1=5*tc.
[0080] As an example, the distribution terminal obtains the initial sampling time of the virtual resources for the target type; determines the sampling interval duration based on the sampling time interval; and determines the sampling time based on the initial sampling time and the sampling interval duration. For example, the initial sampling time can be represented as T1, and the sampling time interval can be represented as tc. The distribution terminal determines the sampling time T2 based on the initial sampling time and 1 times the sampling time interval tc, where T2 = T1 + tc. The distribution terminal determines the sampling time T3 based on the initial sampling time and 2 times the sampling time interval tc, where T2 = T1 + 2 * tc. The distribution terminal determines the sampling time T4 based on the initial sampling time and 3 times the sampling time interval tc, where T2 = T1 + 3 * tc. The sampling times for the virtual resources of the target type can be represented as T1, T2, T3, and T4 in one sequence.
[0081] In this embodiment, by obtaining the initial sampling time of virtual resources for the target type; determining the sampling interval duration based on the sampling time interval; and determining the sampling time based on the initial sampling time and the sampling interval duration, several sampling times can be determined based on the initial sampling time and the sampling time interval, thereby counting the number of virtual resources at the sampling time and improving the real-time performance and flexibility of virtual resource quantity counting.
[0082] In some embodiments, obtaining the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current moment includes: sending a resource quantity query request to the server; parsing the resource quantity information returned by the server, and determining the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current moment.
[0083] Among them, a resource quantity query request can refer to data used to instruct the server to determine and return the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current moment.
[0084] Here, "server" can refer to a virtual resource server.
[0085] The server can respond to resource quantity query requests by calculating the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current moment; the server can use the total amount of virtual resources and the remaining amount of virtual resources of the target type as resource quantity information.
[0086] As an example, the distribution terminal sends a resource quantity query request to the server. The virtual resource server responds to the resource quantity query request by calculating the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time. The virtual resource server uses the total amount of virtual resources and the remaining quantity of virtual resources of the target type as resource quantity information. The virtual resource server returns the resource quantity information to the distribution terminal. The distribution terminal parses the resource quantity information returned by the virtual resource server to determine the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time.
[0087] In this embodiment, a resource quantity query request is sent to the server; the resource quantity information returned by the server is parsed to determine the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current moment. Through data transmission between the terminal and the server, the total amount of virtual resources and the remaining quantity of various types of virtual resources can be determined, thereby improving the security of virtual resources.
[0088] In some embodiments, the method further includes: sending a resource acquisition request to the server; and displaying the resource content information returned by the server to the user in a preset display manner.
[0089] The server can respond to resource acquisition requests by selecting one type of virtual resource from a variety of virtual resources as the target type of virtual resource; the server can obtain the resource content information of the target type of virtual resource; and the selection probability of the target type of virtual resource satisfies a probability snapshot for the target type of virtual resource.
[0090] As an example, such as Figure 3 As shown, a virtual resource distribution system is provided. The virtual resource distribution system may include a coupon issuance front-end system (electronic coupon distribution terminal), a back-end storage system (virtual resource server), and a data transmission system between the coupon issuance front-end system and the back-end storage system. The coupon issuance front-end system may include a page for user accounts to receive electronic coupons. The user account triggers a coupon issuance instruction through the coupon issuance front-end system. The coupon issuance front-end system requests an electronic coupon from the back-end (virtual resource) database according to the corresponding distribution probability as the electronic coupon to be distributed to the user account. The back-end storage system sends the electronic coupon information of the electronic coupon to the coupon issuance front-end system through the data transmission system between the coupon issuance front-end system and the back-end storage system. The coupon issuance front-end system can display the electronic coupon information to the user account in the form of text or image.
[0091] In this embodiment, a resource acquisition request is sent to the server; the resource content information returned by the server is displayed to the user according to a preset display method. Based on the data transmission between the distribution terminal and the virtual resource server, the information of the virtual resources distributed to the user account can be displayed to the user account, thus optimizing the distribution and display effect of virtual resources.
[0092] In some embodiments, the above method further includes: obtaining the current probability snapshot weight corresponding to the probability snapshot at the current time and the previous probability snapshot weight corresponding to the probability snapshot at the previous sampling time corresponding to the current time; performing a weighted summation of the probability snapshot at the current time and the probability snapshot at the previous sampling time corresponding to the current time based on the current probability snapshot weight and the previous probability snapshot weight to obtain a weighted probability snapshot; and distributing virtual resources of the target type according to the weighted probability snapshot.
[0093] The current probability snapshot weight can refer to the weight information corresponding to the probability snapshot at the current moment.
[0094] The weight of the previous probability snapshot can refer to the weight information of the probability snapshot corresponding to the previous sampling time at the current time.
[0095] The weighted probability snapshot refers to the data obtained by weighting and summing the probability snapshot at the current time and the probability snapshot at the previous sampling time corresponding to the current time, based on the weight of the current probability snapshot and the weight of the previous probability snapshot. In practical applications, the weight of the current probability snapshot can be represented as Q1, the weight of the previous probability snapshot can be represented as Q2, the probability snapshot at the current time can be represented as P1, and the probability snapshot at the previous sampling time corresponding to the current time can be represented as P2. Then the weighted probability snapshot can be represented as P1*Q1+P2*Q2.
[0096] As an example, to avoid errors in the statistical data on the distribution of virtual resources, which could lead to incorrect probability snapshots of the target type of virtual resources at the current moment and consequently affect the distribution probability of virtual resources, a weighted summation can be performed on the probability snapshots at the current moment and those at historical sampling moments, based on actual needs. The weighted probability snapshot is then used to distribute virtual resources. For instance, the distribution terminal obtains the current probability snapshot weight and the previous probability snapshot weight (or historical probability snapshot weight) corresponding to the probability snapshot at the previous sampling moment. Based on the current probability snapshot weight and the previous probability snapshot weight (or historical probability snapshot weight), the distribution terminal performs a weighted summation on the probability snapshots at the current moment and those at the previous sampling moment (or historical sampling moment) to obtain a weighted probability snapshot. The distribution terminal then distributes the target type of virtual resources according to the weighted probability snapshot.
[0097] In this embodiment, the current probability snapshot weight and the previous probability snapshot weight corresponding to the probability snapshot at the previous sampling time are obtained. Based on the current probability snapshot weight and the previous probability snapshot weight, the probability snapshot at the current time and the probability snapshot at the previous sampling time are weighted and summed to obtain a weighted probability snapshot. Virtual resources of the target type are distributed according to the weighted probability snapshot. This method combines the probability snapshot at the current time and the probability snapshots at historical sampling times to distribute virtual resources, avoiding errors in the distribution of virtual resources due to incorrect statistics of the number of virtual resources, and ensuring the random distribution of virtual resources.
[0098] In some embodiments, when dealing with the distribution of virtual resources, if the impact of changes in the quantity of virtual resources on the distribution strategy is ignored, the distribution probability of virtual resources will not change in real time. In this case, the distribution probability of virtual resources can be as follows: Figure 4 As shown, Figure 4This paper presents a virtual resource distribution probability that ignores the impact of changes in the number of virtual resources on the distribution strategy, where t is the initial sampling time and C is the time interval. However, during the distribution process, the number of virtual resources changes in real time, requiring the real-time or pre-set time intervals to reset the distribution strategies (distribution probabilities) for various types of virtual resources. Therefore, the virtual resource distribution probability changes over time. In this case, the virtual resource distribution probability can be expressed as follows: Figure 5 As shown, Figure 5Provided is a virtual resource distribution probability under the condition that the influence of the change in the number of virtual resources on the distribution strategy is fully considered, where t is the initial sampling time, C is the time interval, and the number of virtual resources of the target type increases significantly after the time t+C; in order to realize real-time update of the distribution probability of virtual resources, every C seconds (i.e., the sampling time interval), the distribution terminal acquires the quantity distribution information of the virtual resources through the virtual resource server, and based on the greedy algorithm, it is considered that the distribution situation of the virtual resources will not change in the next C seconds, then the distribution probability of the virtual resources will not change, and the virtual resources are randomly distributed according to this distribution probability; the distribution terminal acquires the remaining quantity of various types of virtual resources through the virtual resource server, where the various types of virtual resources can be denoted as A1, A2, ..., An, where n represents the type of virtual resources, and the remaining quantity of various types of virtual resources at the current moment can be denoted as X1, X2, ..., Xn, where any X is greater than 0, and the distribution terminal calculates the distribution proportion of the virtual resources as a probability snapshot, for example, the probability snapshot corresponding to virtual resource A1 can be denoted as P1=X1 / (X1+X2+...+Xn), the probability snapshot corresponding to virtual resource A2 can be denoted as P2=X2 / (X1+X2+...+Xn), and the probability snapshot corresponding to virtual resource An can be denoted as Pn=Xn / (X1+X2+...+Xn). When the virtual resources change (such as quantity change and type change), after C seconds, the distribution terminal updates the virtual resource quantity information through the virtual resource server, for example, the updated various types of virtual resources can be denoted as Ax1, Ax2, ..., Axm, where m represents the updated type of virtual resources. If m>n, it means that the number of types of virtual resources increases (for example, the types of virtual resources are artificially supplemented), if m<n, it means that the number of types of virtual resources decreases (for example, a certain type of virtual resource is artificially removed or a certain type of virtual resource is completely distributed), the remaining quantity of the updated various types of virtual resources can be denoted as Xx1, Xx2, ..., Xxn, and the distribution terminal updates the probability snapshot of various types of virtual resources, for example, the probability snapshot corresponding to virtual resource Ax1 can be denoted as Px1=Xx1 / (Xx1+Xx2+...+Xxm), the probability snapshot corresponding to virtual resource Ax2 can be denoted as Px2=Xx2 / (Xx1+Xx2+...+Xxm), and the probability snapshot corresponding to virtual resource Axm can be denoted as Pxn=Xxn / (Xx1+Xx2+...+Xxm); the distribution terminal performs distribution according to the probability snapshot of each type of virtual resource at the current moment. When the probability snapshot is 0, the distribution terminal judges that the virtual resource corresponding to the probability snapshot with a value of 0 has been completely distributed, and the quantity of this type of virtual resource is 0. Since the distribution probability distribution involves n dimensions, for the convenience of understanding, it is assumed that n=2 (one dimension is fixed, and the remaining n-1 dimensions are regarded as a whole, which can be easily analogized to the n-dimensional situation);Since n=2, P1+P2=1, therefore P2=1-P1. We only need to focus on the case of P1. Furthermore, the sampling time interval C represents how many seconds the virtual resource server refreshes the probability snapshot. The sampling time interval C can be determined based on the distribution speed. If the distribution speed is relatively slow, C can be set longer, such as 600 seconds, then distribution will be based on a probability every 10 minutes. When it is similar to a time-limited or quantity-limited distribution, C can be set smaller, such as 5 seconds. If the distribution of virtual resources changes, the new virtual resource distribution probability can be determined within a maximum of 5 seconds.
[0099] In this embodiment, the virtual resource distribution system can randomly distribute virtual resources as the quantity of virtual resources changes through a probability snapshot based on the greedy algorithm principle. This eliminates the impact of virtual resource replenishment / reduction on virtual resource distribution. Furthermore, it statistically analyzes the quantity distribution of virtual resources according to the sampling time interval without intruding on the original virtual resource distribution process, ensuring the efficiency and stability of the virtual resource distribution operation and guaranteeing the random distribution of virtual resources.
[0100] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0101] Based on the same inventive concept, this application also provides a virtual resource distribution apparatus for implementing the virtual resource distribution method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more virtual resource distribution apparatus embodiments provided below can be found in the limitations of the virtual resource distribution method described above, and will not be repeated here.
[0102] In one embodiment, such as Figure 6 As shown, a virtual resource distribution device is provided, including: a quantity acquisition module 602, a snapshot determination module 604, and a resource distribution module 606, wherein:
[0103] The quantity acquisition module 602 is used to acquire, during the distribution of virtual resources of various types, the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time, provided that a preset sampling time is met at the current time; the total amount of virtual resources is the sum of the remaining amounts of the various types of virtual resources.
[0104] The snapshot determination module 604 is used to determine a probabilistic snapshot of the virtual resources of the target type based on the ratio between the remaining quantity of the virtual resources of the target type and the total quantity of the virtual resources.
[0105] Resource distribution module 606 is used to distribute virtual resources of the target type according to the probability snapshot.
[0106] In an exemplary embodiment, the above-described apparatus further includes a sampling module, which is specifically used to acquire a sampling time mapping table; the sampling time mapping table is used to characterize the mapping relationship between various types of virtual resources and the corresponding sampling time intervals of the various types of virtual resources; the sampling time interval is determined according to the sampling time mapping table; and the sampling time is determined according to the sampling time interval.
[0107] In an exemplary embodiment, the sampling module is further configured to obtain the current distribution speed of the virtual resources of the target type; if the current distribution speed is greater than a preset distribution speed threshold, determine the sampling time interval adjustment amount of the virtual resources of the target type; adjust the preset initial sampling time interval according to the sampling time interval adjustment amount to obtain the sampling time interval; the sampling time interval and the current distribution speed are negatively correlated.
[0108] In an exemplary embodiment, the sampling module is further configured to acquire the initial sampling time of the virtual resource for the target type; determine the sampling interval duration for the sampling time based on the sampling time interval; the sampling interval duration is a positive integer multiple of the sampling time interval; and determine the sampling time based on the initial sampling time and the sampling interval duration.
[0109] In an exemplary embodiment, the quantity acquisition module 602 is further configured to send a resource quantity query request to the server; the server responds to the resource quantity query request by calculating the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time; the server uses the total amount of virtual resources and the remaining quantity of virtual resources of the target type as resource quantity information; and parses the resource quantity information returned by the server to determine the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current time.
[0110] In an exemplary embodiment, the above-described apparatus further includes a display module, which is specifically configured to send a resource acquisition request to a server; the server, in response to the resource acquisition request, selects one type of virtual resource from the various types of virtual resources as a target type of virtual resource; the server acquires the resource content information of the target type of virtual resource; the selection probability corresponding to the target type of virtual resource satisfies a probability snapshot for the target type of virtual resource; and displays the resource content information returned by the server to the user according to a preset display method.
[0111] In an exemplary embodiment, the above-described apparatus further includes a probability weighting module, which is specifically used to obtain the current probability snapshot weight corresponding to the probability snapshot at the current time and the previous probability snapshot weight corresponding to the probability snapshot at the previous sampling time corresponding to the current time; to perform a weighted summation on the probability snapshot at the current time and the probability snapshot at the previous sampling time corresponding to the current time based on the current probability snapshot weight and the previous probability snapshot weight to obtain a weighted probability snapshot; and to distribute the virtual resources of the target type according to the weighted probability snapshot.
[0112] Each module in the aforementioned virtual resource distribution device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0113] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a virtual resource distribution method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0114] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0115] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0116] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0117] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0118] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0119] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0120] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0121] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for distributing virtual resources, characterized in that, The method includes: In the process of distributing virtual resources of various types, if the current time meets the preset sampling time, the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time are obtained; the total amount of virtual resources is the sum of the remaining amounts of the various types of virtual resources. Based on the ratio between the remaining quantity of virtual resources of the target type and the total quantity of virtual resources, a probability snapshot of virtual resources of the target type is determined, wherein the probability snapshot refers to data characterizing the distribution probability of virtual resources of the target type; Based on the probability snapshot, distribute the virtual resources of the target type; The method further includes: obtaining a sampling time mapping table; the sampling time mapping table is used to characterize the mapping relationship between various types of virtual resources and the corresponding sampling time intervals of the various types of virtual resources; determining the sampling time interval for the target type of virtual resource according to the sampling time mapping table; and determining the sampling time according to the sampling time interval.
2. The method according to claim 1, characterized in that, The step of determining the sampling time interval for the virtual resources of the target type includes: Obtain the current distribution speed of the virtual resources of the target type; If the current distribution speed is greater than a preset distribution speed threshold, determine the adjustment amount of the sampling time interval for the virtual resources of the target type; The initial sampling time interval is adjusted according to the sampling time interval adjustment amount to obtain the sampling time interval; the sampling time interval is negatively correlated with the current distribution speed.
3. The method according to claim 1, characterized in that, Determining the sampling time based on the sampling time interval includes: Obtain the initial sampling time for the virtual resources of the target type; Based on the sampling time interval, the sampling interval duration for the sampling time is determined; the sampling interval duration is a positive integer multiple of the sampling time interval. The sampling time is determined based on the initial sampling time and the sampling interval duration.
4. The method according to claim 1, characterized in that, The step of obtaining the total amount of virtual resources and the remaining quantity of virtual resources of the target type at the current moment includes: A resource quantity query request is sent to the server; in response to the resource quantity query request, the server calculates the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time; the server uses the total amount of virtual resources and the remaining amount of virtual resources of the target type as resource quantity information. The resource quantity information returned by the server is parsed to determine the total amount of virtual resources and the remaining quantity of the target type of virtual resources at the current moment.
5. The method according to claim 1, characterized in that, The method further includes: A resource acquisition request is sent to the server; in response to the resource acquisition request, the server selects one type of virtual resource from the various types of virtual resources as the target type of virtual resource; the server acquires the resource content information of the target type of virtual resource; the selection probability corresponding to the target type of virtual resource satisfies a probability snapshot for the target type of virtual resource; The resource content information returned by the server is displayed to the user according to the preset display method.
6. The method according to claim 1, characterized in that, The method further includes: Obtain the current probability snapshot weight corresponding to the probability snapshot at the current time and the previous probability snapshot weight corresponding to the probability snapshot at the previous sampling time corresponding to the current time; Based on the current probability snapshot weight and the previous probability snapshot weight, the probability snapshot at the current time and the probability snapshot at the previous sampling time corresponding to the current time are weighted and summed to obtain a weighted probability snapshot. The virtual resources of the target type are distributed according to the weighted probability snapshot.
7. A virtual resource distribution device, characterized in that, The device includes: The quantity acquisition module is used to acquire, during the distribution of virtual resources of various types, the total amount of virtual resources and the remaining amount of virtual resources of the target type at the current time, provided that a preset sampling time is met at the current time; the total amount of virtual resources is the sum of the remaining amounts of the various types of virtual resources. The snapshot determination module is used to determine a probability snapshot for the virtual resources of the target type based on the ratio between the remaining quantity of virtual resources of the target type and the total quantity of virtual resources, wherein the probability snapshot refers to data characterizing the distribution probability of the virtual resources of the target type; The resource distribution module is used to distribute virtual resources of the target type according to the probability snapshot; The device further includes a sampling module, configured to: acquire a sampling time mapping table; the sampling time mapping table is used to characterize the mapping relationship between various types of virtual resources and the corresponding sampling time intervals of the various types of virtual resources; determine the sampling time interval for the target type of virtual resource according to the sampling time mapping table; and determine the sampling time according to the sampling time interval.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Electronic bill issuing method and device, equipment and storage medium
CN113919864A