Resource allocation methods, devices, equipment and storage media
By setting probabilities and controlling the number of times specific resources are allocated, the problem of network resource allocation when the number of users is unknown is solved, enabling precise control and improved experience for users to collect resources during offline activities.
Patent Information
- Application Number
- CN202410962550.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2044-07-17
AI Technical Summary
When the number of users is unknown, how to allocate network resources to users has become an urgent problem to be solved in the field of computer network technology. Especially in offline activities, it is difficult to accurately control the number of times and the success rate of users collecting specific network resources.
By receiving users' resource allocation requests, network resources are allocated to users according to a set probability. When a user collects a certain type of network resource and the number of times that specific type of resource is allocated is reached, the allocation frequency of that specific type of resource is controlled. By combining random generation and user database records, the allocation of resources is ensured to meet the expected quantity and success rate.
It enables precise control over the number of specific network resources a user collects even when the number of users is unknown, improving user experience and ensuring the winning rate of the activity, while avoiding uneven resource allocation caused by randomness.
Smart Images

Figure CN118972438B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer network technology, and in particular to a resource allocation method, apparatus, resource allocation device, and storage medium. Background Technology
[0002] With the rapid development of computer network technology, the increasing prevalence of computers, and the growing abundance of network resources, computer applications have permeated all aspects of society. Network resources primarily refer to the sum of various information resources available through the network environment. These resources typically exist in the form of electronic data, including text, images, sound, animation, and other forms of information, stored on non-printed media such as optical and magnetic media. Simultaneously, with the continuous development of mobile internet technology, the number of users of electronic devices such as smartphones and tablets is also increasing. Given the unknown number of users, how to allocate network resources to them has become a pressing technical problem for those skilled in the art. Summary of the Invention
[0003] This application provides a resource allocation method, apparatus, device, and storage medium that can allocate network resources to users even when the number of users is unknown.
[0004] According to a first aspect of this application, a resource allocation method is disclosed, applied to a resource allocation device, the resource allocation device being capable of allocating N types of network resources, where N is an integer greater than 1, the method comprising:
[0005] Receive a first resource allocation request sent by a first user in the target scenario, wherein the first resource allocation request is used to request the allocation of a network resource;
[0006] In response to the first resource allocation request, a network resource is allocated to the first user according to a first probability, and the type information of the network resource allocated to the first user is recorded in the user database. The user database includes: the number of various network resources allocated to each first user and the type of each network resource. The first probability is a manually set probability that the first user has collected all N types of network resources.
[0007] Based on the user database, determine whether the number of first users who have collected all N types of network resources has reached a first quantity threshold. If so, set the number of times a specific type of network resource is allocated among the N types of network resources.
[0008] Receive a second resource allocation request sent by a first user in the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource;
[0009] In response to the second resource allocation request, a network resource is allocated to the first user according to the set number of allocations.
[0010] Optionally, as an embodiment, allocating a network resource to the first user according to the set number of allocations includes:
[0011] Based on the set number of allocations and the second probability, a network resource is randomly generated, wherein the second probability is the probability set by the user that the first user collects all N types of network resources.
[0012] Based on the user database and the type information of randomly generated network resources, a third probability and the actual number of times the specific type of network resources are allocated after the number of first users who have collected all N types of network resources reaches a first quantity threshold are determined, wherein the third probability is the actual probability that the first user has collected all N types of network resources.
[0013] Based on the second probability, the third probability, the set number of allocations, and the actual number of allocations, a network resource is allocated to the first user.
[0014] Optionally, as an embodiment, the number of types of the specific type of network resource is 1;
[0015] The step of allocating a network resource to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations includes:
[0016] Determine whether the third probability is less than or equal to the second probability;
[0017] If the third probability is less than or equal to the second probability, then determine whether the actual number of allocations is less than or equal to the set number of allocations;
[0018] If the actual number of allocations is less than or equal to the set number of allocations, the randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database.
[0019] If the third probability is greater than the second probability, or the actual number of allocations is greater than the set number of allocations, then return to the step of randomly selecting a network resource based on the set number of allocations and the second probability.
[0020] Optionally, as an embodiment, the number of types of the specific type of network resource is M, where M is an integer greater than 1 and less than N;
[0021] The step of allocating a network resource to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations includes:
[0022] Determine whether the third probability is less than or equal to the second probability;
[0023] If the third probability is less than or equal to the second probability, then determine whether the actual allocation counts corresponding to each of the M specific types of network resources are all less than or equal to the set allocation counts;
[0024] If all the actual allocation counts are less than or equal to the set allocation counts, then the randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database.
[0025] If the third probability is greater than the second probability, or at least one of the actual allocation counts is greater than the set allocation count, then return to the step of randomly selecting a network resource based on the set allocation count and the second probability.
[0026] Optionally, as an example, the resource allocation request is triggered by the user scanning a barcode in the target scene using their electronic device, which then sends the request to the resource allocation device.
[0027] Optionally, as an embodiment, the network resources include any one of the following: images, text, video, and audio.
[0028] Optionally, as an embodiment, the network resources include text; the N types of network resources include: N different specific texts; the target scenario is a scenario where the N different specific texts are collected to redeem a gift, and the first quantity threshold is the quantity value of the gift in the target scenario.
[0029] According to a second aspect of this application, a resource allocation device is disclosed, applied to a resource allocation equipment, the resource allocation equipment being capable of allocating N types of network resources, where N is an integer greater than 1, the device comprising:
[0030] The first receiving module is used to receive a first resource allocation request sent by a first user in the target scenario, wherein the first resource allocation request is used to request the allocation of a network resource;
[0031] The first allocation module is configured to respond to the first resource allocation request, allocate a network resource to the first user according to a first probability, and record the type information of the network resource allocated to the first user in the user database. The user database includes: the number of various network resources allocated to each first user and the type of each network resource. The first probability is a manually set probability that the first user collects all N types of network resources.
[0032] The determining module is used to determine, based on the user database, whether the number of first users who have collected all N types of network resources has reached a first quantity threshold.
[0033] The setting module is used to set the number of times a specific type of network resource among the N types of network resources is allocated when the number of first users who have collected all N types of network resources reaches a first quantity threshold.
[0034] The second receiving module is used to receive a second resource allocation request sent by a first user in the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource;
[0035] The second allocation module is used to respond to the second resource allocation request and allocate a network resource to the first user according to the set number of allocations.
[0036] Optionally, as one embodiment, the second allocation module includes:
[0037] The generation submodule is used to randomly generate a network resource based on the set number of allocations and the second probability, wherein the second probability is the probability set by the user that the first user collects all N types of network resources.
[0038] The determination submodule is used to determine, based on the user database and the type information of randomly generated network resources, a third probability and the actual number of times the specific type of network resources are allocated after the number of first users who have collected all N types of network resources reaches a first quantity threshold. The third probability is the actual probability that the first user has collected all N types of network resources.
[0039] The allocation submodule is used to allocate a network resource to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations.
[0040] Optionally, as an embodiment, the number of types of the specific type of network resource is 1;
[0041] The allocation submodule includes:
[0042] The first determining unit is used to determine whether the third probability is less than or equal to the second probability;
[0043] The second determining unit is used to determine whether the actual number of allocations is less than or equal to the set number of allocations if the third probability is less than or equal to the second probability.
[0044] The first allocation unit is configured to allocate the randomly selected network resources to the first user if the actual allocation count is less than or equal to the set allocation count, and record the type information of the network resources allocated to the first user in the user database.
[0045] The first loop unit is configured to return to the step of randomly selecting a network resource based on the set number of allocations and the second probability if the third probability is greater than the second probability, or if the actual number of allocations is greater than the set number of allocations.
[0046] Optionally, as an embodiment, the number of types of the specific type of network resource is M, where M is an integer greater than 1 and less than N;
[0047] The allocation submodule includes:
[0048] The third determining unit is used to determine whether the third probability is less than or equal to the second probability;
[0049] The fourth determining unit is used to determine whether the actual allocation counts corresponding to each of the M specific types of network resources are all less than or equal to the set allocation counts if the third probability is less than or equal to the second probability.
[0050] The second allocation unit is configured to allocate the randomly selected network resources to the first user if all the actual allocation counts are less than or equal to the set allocation counts, and record the type information of the network resources allocated to the first user in the user database.
[0051] The second loop unit is configured to return to the step of randomly selecting a network resource based on the set number of allocations and the second probability if the third probability is greater than the second probability, or if at least one of the actual allocation counts is greater than the set number of allocations.
[0052] Optionally, as an example, the resource allocation request is triggered by the user scanning a barcode in the target scene using their electronic device, which then sends the request to the resource allocation device.
[0053] Optionally, as an embodiment, the network resources include any one of the following: images, text, video, and audio.
[0054] Optionally, as an embodiment, the network resources include text; the N types of network resources include: N different specific texts; the target scenario is a scenario where the N different specific texts are collected to redeem a gift, and the first quantity threshold is the quantity value of the gift in the target scenario.
[0055] According to a third aspect of this application, a resource allocation device is disclosed, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the resource allocation method as described in the first aspect.
[0056] According to a fourth aspect of this application, a computer-readable storage medium is disclosed having a computer program / instructions stored thereon, which, when executed by a processor, implements the resource allocation method as described in the first aspect.
[0057] According to a fifth aspect of this application, a computer program product is disclosed, comprising a computer program / instructions that, when executed by a processor, implement the resource allocation method as described in the first aspect.
[0058] In this embodiment, the resource allocation device receives a first resource allocation request sent by a first user in a target scenario, wherein the first resource allocation request is used to request the allocation of a network resource; in response to the first resource allocation request, a network resource is allocated to the first user according to a first probability, and the type information of the network resource allocated to the first user is recorded in a user database, wherein the user database includes: the number of various network resources allocated to each first user and the type of each network resource, and the first probability is a manually set probability that the first user has collected N types of network resources; based on the user database, it is determined whether the number of first users who have collected N types of network resources has reached a first quantity threshold, and if so, the allocation frequency of a specific type of network resource among the N types of network resources is set; a second resource allocation request sent by the first user in the target scenario is received, wherein the second resource allocation request is used to request the allocation of a network resource; in response to the second resource allocation request, a network resource is allocated to the first user according to the set allocation frequency, thereby realizing the allocation of network resources to users when the number of users is unknown. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0060] Figure 1 This is a flowchart of a resource allocation method provided in an embodiment of this application;
[0061] Figure 2 This is an application scenario diagram of a resource allocation method provided in an embodiment of this application;
[0062] Figure 3 This is a flowchart of one implementation of step 105 provided in this application embodiment;
[0063] Figure 4 This is one of the flowcharts for one implementation of step 303 provided in the embodiments of this application;
[0064] Figure 5 This is a second flowchart of one implementation of step 303 provided in the embodiments of this application;
[0065] Figure 6 This is an example diagram of a resource allocation method provided in an embodiment of this application;
[0066] Figure 7 This is a schematic diagram of the structure of a resource allocation device provided in an embodiment of this application;
[0067] Figure 8 This is a structural block diagram of a resource allocation device provided in an embodiment of this application. Detailed Implementation
[0068] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0069] To facilitate understanding, some relevant concepts and application scenarios involved in the embodiments of this application will be introduced below.
[0070] I. Related Concepts
[0071] Network resources refer to the sum of various information resources that can be utilized through the network environment. These resources usually exist in the form of electronic resource data, including information in various forms such as text, images, sound, and animation, and are stored in non-printed media such as optical and magnetic materials.
[0072] Collections.shuffle is a Java Collections class method that randomly replaces elements in a specified list. There are two different types of Java shuffle() methods, which can be distinguished by their parameters: Java Collections shuffle(list) and Java Collections shuffle(list, random).
[0073] The Java Collections shuffle(list) method works by randomly reordering the elements of a specified list using default randomness.
[0074] The Java Collections shuffle(list, random) method works by randomly reordering the elements of a list using a specified randomness.
[0075] `getRandomHanzi` is a function used to generate random Chinese characters. It can be used in various scenarios that require random character generation, such as generating verification codes, test data, and random character sets. The implementation of this function can vary depending on the scenario.
[0076] II. Application Scenarios
[0077] With the rapid development of computer network technology, the increasing popularity of computers, and the growing abundance of network resources, computer applications have permeated all aspects of society. At the same time, with the continuous development of mobile internet technology, the number of users of electronic devices such as smartphones and tablets is also increasing. Given the unknown number of users, how to allocate network resources to them has become a pressing technical problem for those skilled in the art.
[0078] For example, in many event scenarios, it is necessary to randomly generate specific Chinese characters from a set of Chinese characters to complete the event task. However, when planning similar events, it is difficult to control the number of users and ensure the number of attempts and successes.
[0079] Taking a specific scenario as an example, in this scenario, online resources refer to Chinese characters. For instance, in some important promotional events, organizers may attract attention by offering prizes on-site. Currently, with the widespread use of smartphones, tablets, and other electronic devices, as well as the popularity of mini-programs, more promotional activities are combining on-site events with mini-programs. For example, for a promotional event for a newly opened museum, a mini-program could be designed. Users could scan a QR code on-site (each scan yields one Chinese character, with no limit on the number of scans per user) to randomly collect characters. If a user collects a specific sequence of characters, such as the six characters for "Museum Night," they can redeem souvenirs or gifts on-site by following the instructions on the mini-program. However, the number of gifts is usually limited, while the number of users and the number of scans is unpredictable. Therefore, how to control the number of times users need to collect a specific sequence of characters in the planning of such events is a problem worth studying.
[0080] In related technologies, when encountering this problem, the first consideration is to achieve it by collecting a specific sequence of Chinese characters with a probability P1. However, in character collection activities, it is impossible to predict the total number of users in such promotional activities, so there is no way to set a probability P1, where P1 = number of successful attempts / total number of attempts, and total number of attempts = number of successful attempts / P1.
[0081] This means that if you want to generate a specific Chinese character sequence with a probability of P1, theoretically you should try approximately the number of successful attempts / P1. However, due to randomness, it may actually take many more attempts to reach this probability. Therefore, in the code, the maximum number of attempts (MAX_TRIES) should be set larger than the actual value to ensure that the probability of P1 is reached in actual operation.
[0082] However, it's important to note that this method is not mathematically rigorous, as it relies on the number of trials and randomness. Due to the nature of randomness, directly controlling the probability of generating a specific sequence to P1 is quite difficult, as it involves complex probability calculations. In practice, it may be necessary to calibrate the value of MAX_TRIES by running the program multiple times and statistically analyzing the results to more precisely control the probability of generating a specific Chinese character sequence.
[0083] Suppose that the organizers of an event intend to offer 100 gifts on-site, but they don't know the exact number of users participating in the character collection activity. This problem cannot be solved by setting the probability of collecting a specific sequence of Chinese characters as described above. To solve the above technical problem, embodiments of this application provide a resource allocation method, apparatus, resource allocation device, and storage medium.
[0084] The resource allocation method provided in this application will now be described in detail with reference to the accompanying drawings.
[0085] Figure 1 This is a flowchart illustrating a resource allocation method provided in an embodiment of this application, applied to a resource allocation device. This resource allocation device can allocate N types of network resources, where N is an integer greater than 1, such as... Figure 1 As shown, the method may include the following steps: step 101, step 102, step 103, step 104 and step 105;
[0086] In step 101, a first resource allocation request sent by a first user in the target scenario is received, wherein the first resource allocation request is used to request the allocation of a network resource.
[0087] In this embodiment of the application, network resources may include any one of the following: images, text, video, and audio, and the application scenarios are quite extensive.
[0088] In this application embodiment, the target scenario refers to any scenario involving the allocation of network resources. In practical applications, the target scenario can be an online scenario or an offline scenario, such as an offline scenario of scanning a QR code to collect a specific sequence of Chinese characters.
[0089] In some embodiments, network resources include text, and N types of network resources include: N different specific texts, the target scenario is a scenario where N different specific texts are collected to redeem a gift, and the first quantity threshold is the quantity value of the gift in the target scenario.
[0090] In this embodiment, considering that there are usually many users in the target scenario, some users will participate in the resource allocation activity, while others will not. For example, in an offline promotional event, some users participate in the activity of scanning QR codes to collect Chinese characters, while others simply browse and do not participate. Therefore, for ease of distinction, the users in the target scenario who participate in the resource allocation activity are referred to as the first users.
[0091] In this embodiment of the application, the resource allocation request may be triggered by the user scanning a barcode in the target scene using their own electronic device, which then sends the request to the resource allocation device.
[0092] For example, the barcode can specifically be a QR code, such as... Figure 2 As shown, many users (it could be 500, 1000, or some other number) participated in the "Scan QR Code to Collect All the 'Night at the Museum' Items" activity offline, and the organizer provided 100 gifts.
[0093] From the user's perspective, for User 1, every time User 1 scans a QR code using Mobile Phone 1, one Chinese character is obtained. After scanning the QR code multiple times, multiple Chinese characters are obtained. Similarly, for User 2, every time User 2 scans a QR code using Mobile Phone 2, one Chinese character is obtained. After scanning the QR code multiple times, multiple Chinese characters are obtained. Multiple users can scan a QR code simultaneously.
[0094] Taking User 1 as an example, every time User 1 scans a QR code using Mobile Phone 1, it triggers Mobile Phone 1 to send a resource allocation request to the resource allocation device in the cloud. The resource allocation device responds to the resource allocation request and returns one Chinese character to Mobile Phone 1. For example, if User 1 scans the QR code 3 times in sequence using Mobile Phone 1, Mobile Phone 1 sends 3 resource allocation requests to the resource allocation device in sequence. The resource allocation device responds to the 3 resource allocation requests successively and returns 3 Chinese characters, such as "Bo", "Bo", and "Ye" respectively. Similarly, User 2 scans the QR code 4 times using Mobile Phone 2 and obtains 4 Chinese characters, such as "Bo", "Guan", "Ye", and "Wu" respectively. The expectation of the user is that through multiple QR code scans, the multiple Chinese characters obtained can form "The Night at the Museum", and at this time, the user can obtain a gift.
[0095] In step 102, in response to the first resource allocation request, according to the first probability, a network resource is allocated to the first user, and the type information of the network resource allocated to the first user is recorded in the user database.
[0096] In the embodiment of the present application, the user database includes: the quantity of various network resources already allocated to each first user and the types to which each network resource belongs. The first probability is the probability set by humans for the first user to集齐 N types of network resources.
[0097] In the embodiment of the present application, after receiving the first resource allocation request, the resource allocation device can randomly generate a network resource according to the first probability and return this network resource to the first user, thereby achieving the allocation of a network resource to the first user. Or, if a resource pool is set in the resource allocation device and multiple network resources are pre-stored in the resource pool, after receiving the first resource allocation request, the resource allocation device can randomly select a network resource from the resource pool according to the first probability and return this network resource to the first user, thereby achieving the allocation of a network resource to the first user.
[0098] In step 103, according to the user database, it is determined whether the number of first users who have集齐 N types of network resources reaches the first quantity threshold. If so, the allocation times of a specific type of network resource among the N types of network resources are set.
[0099] In this embodiment of the application, since the user database records the quantity of various network resources allocated to each first user and the type of each network resource, the number of first users who have collected N types of network resources can be accurately determined based on the user database.
[0100] In this application embodiment, a specific type of network resource can be one type of network resource or at least two types of network resources.
[0101] In this application embodiment, the first quantity threshold typically refers to the upper limit of the number of users who can collect all N types of network resources, which is preset manually. For example, the number of gifts provided by the event organizer for the "scan the code to collect all the <Night at the Museum>" event.
[0102] In this embodiment of the application, when allocating resources to each first user in the target scenario in the network resource allocation scenario, the allocation is carried out according to a set probability. As network resources are continuously allocated, when the number of users who have collected N types of network resources reaches the set upper limit, the number of users who have collected N types of network resources is controlled by controlling the subsequent allocation of a specific network resource.
[0103] In step 104, a second resource allocation request is received from a first user in the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource.
[0104] In this embodiment of the application, although the number of users who have collected N types of network resources has reached the set upper limit, since the number of users in the target scenario is usually large, other users who have not collected N types of network resources may not know the above situation and will continue to participate in the resource allocation activity. At this time, these users will continue to send resource allocation requests (i.e., second resource allocation requests) to the resource allocation device.
[0105] In step 105, in response to the second resource allocation request, a network resource is allocated to the first user according to the set number of allocations.
[0106] In this embodiment, a network resource is allocated to a user who has not collected all N types of network resources according to the set number of allocations, so that the user cannot collect all N types of network resources in the future, thereby controlling the number of users who have collected all N types of network resources in the target scenario to not exceed the set upper limit.
[0107] In some embodiments, such as Figure 3 As shown, step 105 above may include the following steps: step 301, step 302 and step 303;
[0108] In step 301, a network resource is randomly generated according to the set number of allocations and the second probability; wherein, the second probability is the probability set by the user that the first user collects all N types of network resources.
[0109] In this embodiment of the application, the values of the second probability and the first probability may be the same or different.
[0110] In step 302, based on the user database and the type information of randomly generated network resources, the third probability and the actual number of times a specific type of network resource is allocated after the number of first users who have collected N types of network resources reaches a first quantity threshold are determined; wherein, the third probability is the actual probability of the first user collecting N types of network resources.
[0111] In step 303, a network resource is allocated to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations.
[0112] Optionally, when the number of types of a particular type of network resource is 1, such as Figure 4 As shown, step 303 above may include the following steps: step 3031, step 3032, step 3033 and step 3034;
[0113] In step 3031, it is determined whether the third probability is less than or equal to the second probability; if so, step 3032 is executed, otherwise step 3034 is executed.
[0114] In step 3032, it is determined whether the actual number of allocations is less than or equal to the set number of allocations; if so, step 3033 is executed; otherwise, step 3034 is executed.
[0115] In this embodiment of the application, when the third probability is less than or equal to the second probability, it is determined whether the actual number of allocations is less than or equal to the set number of allocations.
[0116] In step 3033, randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database.
[0117] In this embodiment of the application, when the actual number of allocations is less than or equal to the set number of allocations, randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database.
[0118] In step 3034, the process returns to the step of randomly selecting a network resource based on the set number of allocations and the second probability.
[0119] In this embodiment of the application, if the third probability is greater than the second probability, or the actual number of allocations is greater than the set number of allocations, the process returns to execute the above step 301.
[0120] Optionally, when the number of types of a specific type of network resource is M, M is an integer greater than 1 and less than N, such as... Figure 5 As shown, step 303 above may include the following steps: step 3035, step 3036, step 3037 and step 3038;
[0121] In step 3035, it is determined whether the third probability is less than or equal to the second probability; if so, step 3036 is executed, otherwise step 3038 is executed.
[0122] In step 3036, it is determined whether the actual allocation counts corresponding to each of the M specific types of network resources are all less than or equal to the set allocation counts; if so, step 3037 is executed, otherwise step 3038 is executed.
[0123] In this embodiment of the application, when the third probability is less than or equal to the second probability, it is determined whether the actual number of allocations for each of the M specific types of network resources is less than or equal to the set number of allocations.
[0124] In step 3037, randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database.
[0125] In this embodiment of the application, when all actual allocation counts are less than or equal to the set allocation counts, randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database.
[0126] In step 3038, the process returns to the step of randomly selecting a network resource based on the set number of allocations and the second probability.
[0127] In this embodiment of the application, if the third probability is greater than the second probability, or if at least one actual allocation number is greater than the set allocation number, the process returns to execute step 301 above.
[0128] As can be seen from the above embodiments, in this embodiment, the resource allocation device receives a first resource allocation request sent by a first user in a target scenario, where the first resource allocation request is used to request the allocation of a network resource; in response to the first resource allocation request, according to a first probability, a network resource is allocated to the first user, and the type information of the network resource allocated to the first user is recorded in the user database, where the user database includes: the quantity of various network resources already allocated to each first user and the types to which each network resource belongs, and the first probability is the probability, set artificially, that the first user集齐N types of network resources; according to the user database, it is determined whether the number of first users who have集齐N types of network resources has reached a first quantity threshold, and if so, the allocation times of a specific type of network resource among the N types of network resources are set; the resource allocation device receives a second resource allocation request sent by a first user in the target scenario, where the second resource allocation request is used to request the allocation of a network resource; in response to the second resource allocation request, according to the set allocation times, a network resource is allocated to the first user, thereby achieving the allocation of network resources to users when the number of users is unknown.
[0129] For ease of understanding, the resource allocation method provided in the embodiments of the present application will be described in detail with reference to a specific example below.
[0130] The network resources include text, and the N types of network resources include: N different specific texts. The target scenario is a scenario where N different specific texts are collected to exchange for gifts, and the first quantity threshold is the quantity value of the gifts in the target scenario.
[0131] For example, the N types of network resources are specifically the six Chinese characters "Museum of the Night". For example, in an offline activity scenario, 1000 users participate in the activity of scanning QR codes to obtain Chinese characters, and the activity organizer provides 100 gifts.
[0132] The activity organizer sets the initial probability that the first user集齐N types of network resources as P2 (i.e., the first probability). 1000 users use their mobile phones to continuously scan the QR codes in the activity scenario, and the resource allocation device returns Chinese characters to the 1000 users according to the probability P1. As these users continuously scan the codes, the users continuously obtain Chinese characters from the resource allocation device, and more and more users集齐the six Chinese characters "Museum of the Night". When the resource allocation device detects that the number of users who have集齐the six Chinese characters "Museum of the Night" has reached the gift quantity of 100, it will enable the backend code to interfere with the allocation times of one of the six Chinese characters "Museum of the Night", for example, control the allocation times of the character "奇" among the six Chinese characters "Museum of the Night" so that the successful times are 100. By this method, it is possible to both control the upper limit of the number of users who集齐the Chinese characters and not affect the user experience.
[0133] As shown Figure 6 in the figure, the process of controlling the collection of a specific Chinese character sequence by controlling the distribution times of a certain Chinese character can include the following steps: Step 601, Step 602, Step 603, Step 604, Step 605, Step 606 and Step 607;
[0134] In step 601, determine the target Chinese character sequence. For example, "Night at the Museum".
[0135] In step 602, set the initial probability P2 for the target Chinese character sequence to be collected.
[0136] In step 603, set the distribution times of a certain specific Chinese character to K; where K = 1,.... For example, the distribution times of the character "qi" is 2.
[0137] In step 604, randomly generate Chinese characters according to the probability P2 and K.
[0138] In step 605, calculate the actual probability P3 for the target Chinese character sequence to be collected according to the final actual generated Chinese character result.
[0139] In step 606, judge whether P3 is less than or equal to P2. If so, judge whether the actual distribution times of the specific Chinese character is greater than K. If so, recursively execute step 602; otherwise, execute step 607.
[0140] In step 607, return the randomly generated Chinese characters to the user and update the user database.
[0141] If the above process is written in Java code, the getRandomHanzi method will generate random Chinese character characters, not just the characters in "Night at the Museum". Therefore, if you want the randomly generated Chinese characters to be limited to several specific Chinese characters such as "Night at the Museum", you need to modify the getRandomHanzi method to make it only select from this limited character set.
[0142] First, ensure that the generated sequence always contains the six characters "Night at the Museum" (only the number of the character "qi" is fixed), and then add the other Chinese characters in "Night at the Museum" to the sequence first. By using a certain parameter in the function body to check whether to avoid generating results containing too many "qi" characters. The specific logic and probability setting of the function are as follows:
[0143] function randomFun(){
[0144] var yecount = context.getArg('yecount');
[0145] var str = 'Museum Night';
[0146] var result = "";
[0147] var totalProbability = 0.12;
[0148] for (var i = 0; i < str.length; i++) {
[0149] var randomNum = Math.random();
[0150] var charProbability = 1 / (str.length - i); / / Calculate the probability of each character
[0151] if (randomNum <= totalProbability) {
[0152] result += str.charAt(i);
[0153] totalProbability -= charProbability;
[0154] if (result == '奇' && yecount > 100) {
[0155] result = '博'; / / Here, restarting the randomFun() loop or making a recursive function call to generate a new random substring might be the best design choice.
[0156] }
[0157] context.setReturn('suijijieguo', result);
[0158] return;
[0159] }
[0160] }
[0161] if (result == "") {
[0162] randomFun();
[0163] }
[0164] }
[0165] randomFun();
[0166] This JavaScript code implements a function called randomFun. The goal of this function is to randomly generate a substring composed of characters from the given string "Night at the Museum". Input parameter: The function accepts a parameter called yecount, which is used within the function to check whether to avoid generating results that contain too many "qi" characters. Initialization: The str variable stores the original string "Night at the Museum" from which characters will be randomly selected. The result variable is used to store the final generated random substring. The totalProbability variable is set to 0.12, representing the initial random selection probability. Loop: The function traverses each character in str through a for loop. Random selection and probability: In each iteration of the loop, a random number randomNum between 0 and 1 is generated; the probability charProbability of the current character being selected is calculated, which is 1 divided by the number of remaining unselected characters. Character selection: If randomNum is less than or equal to totalProbability, the current character is selected and added to result; after each character is selected, totalProbability is subtracted by charProbability, so that as the loop progresses, the probability of selecting the next character gradually decreases. Special condition: If the generated result happens to be "qi" and yecount is greater than 100, then result is reset to "bo". This can be regarded as a strategy to avoid generating too many identical characters. Return result: Once a character is selected, the function sets a return value through context.setReturn('suijijieguo', result) and ends the function execution through the return statement. This function attempts to implement a probability-based random substring generator.
[0167] It can be seen that in the embodiments of this application, by controlling the number of times of a certain parameter to control the overall number of successful times that need to be controlled in the business, and by using the Java Collections shuffle method to achieve randomness to randomly reorder the list elements to work, the randomness and upper limit number predetermined in the business are ensured, thus solving the problem of being unable to control the number of successful times in various promotional business scenarios, improving the user experience and ensuring the winning rate.
[0168] Corresponding to the above method embodiments, the embodiments of this application also provide a resource allocation device. The resource allocation device described below can be mutually corresponded and referred to with the resource allocation method described above.
[0169] Figure 7This is a schematic diagram of a resource allocation device provided in an embodiment of this application. It is applied to a resource allocation equipment, which can allocate N types of network resources, where N is an integer greater than 1, such as... Figure 7 As shown, the resource allocation device 700 may include: a first receiving module 701, a first allocation module 702, a determining module 703, a setting module 704, a second receiving module 705, and a second allocation module 706;
[0170] The first receiving module 701 is used to receive a first resource allocation request sent by a first user in the target scenario, wherein the first resource allocation request is used to request the allocation of a network resource;
[0171] The first allocation module 702 is used to respond to the first resource allocation request, allocate a network resource to the first user according to a first probability, and record the type information of the network resource allocated to the first user in the user database. The user database includes: the number of various network resources allocated to each first user and the type of each network resource. The first probability is a manually set probability that the first user collects all N types of network resources.
[0172] The determining module 703 is used to determine, based on the user database, whether the number of first users who have collected all N types of network resources has reached a first quantity threshold.
[0173] Setting module 704 is used to set the number of times a specific type of network resource is allocated among the N types of network resources when the number of first users who have collected all the N types of network resources reaches a first quantity threshold.
[0174] The second receiving module 705 is used to receive a second resource allocation request sent by a first user in the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource;
[0175] The second allocation module 706 is used to allocate a network resource to the first user in response to the second resource allocation request, according to the set number of allocations.
[0176] As can be seen from the above embodiments, in this embodiment, the resource allocation device receives a first resource allocation request sent by a first user in the target scene, wherein the first resource allocation request is used to request the allocation of a network resource; in response to the first resource allocation request, a network resource is allocated to the first user according to a first probability, and the type information of the network resource allocated to the first user is recorded in the user database, wherein the user database includes: the number of various network resources allocated to each first user and the type to which each network resource belongs, and the first probability is a manually set probability that the first user has collected N types of network resources; according to the user database, it is determined whether the number of first users who have collected N types of network resources has reached a first quantity threshold, and if so, the allocation frequency of a specific type of network resource among the N types of network resources is set; a second resource allocation request sent by the first user in the target scene is received, wherein the second resource allocation request is used to request the allocation of a network resource; in response to the second resource allocation request, a network resource is allocated to the first user according to the set allocation frequency, thereby realizing the allocation of network resources to users when the number of users is unknown.
[0177] Optionally, as an embodiment, the second allocation module 706 may include:
[0178] The generation submodule is used to randomly generate a network resource based on the set number of allocations and the second probability, wherein the second probability is the probability set by the user that the first user collects all N types of network resources.
[0179] The determination submodule is used to determine, based on the user database and the type information of randomly generated network resources, a third probability and the actual number of times the specific type of network resources are allocated after the number of first users who have collected all N types of network resources reaches a first quantity threshold. The third probability is the actual probability that the first user has collected all N types of network resources.
[0180] The allocation submodule is used to allocate a network resource to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations.
[0181] Optionally, as an embodiment, the number of types of the specific type of network resource is 1;
[0182] The allocation submodule may include:
[0183] The first determining unit is used to determine whether the third probability is less than or equal to the second probability;
[0184] The second determining unit is used to determine whether the actual number of allocations is less than or equal to the set number of allocations if the third probability is less than or equal to the second probability.
[0185] The first allocation unit is configured to allocate the randomly selected network resources to the first user if the actual allocation count is less than or equal to the set allocation count, and record the type information of the network resources allocated to the first user in the user database.
[0186] The first loop unit is configured to return to the step of randomly selecting a network resource based on the set number of allocations and the second probability if the third probability is greater than the second probability, or if the actual number of allocations is greater than the set number of allocations.
[0187] Optionally, as an embodiment, the number of types of the specific type of network resource is M, where M is an integer greater than 1 and less than N;
[0188] The allocation submodule may include:
[0189] The third determining unit is used to determine whether the third probability is less than or equal to the second probability;
[0190] The fourth determining unit is used to determine whether the actual allocation counts corresponding to each of the M specific types of network resources are all less than or equal to the set allocation counts if the third probability is less than or equal to the second probability.
[0191] The second allocation unit is configured to allocate the randomly selected network resources to the first user if all the actual allocation counts are less than or equal to the set allocation counts, and record the type information of the network resources allocated to the first user in the user database.
[0192] The second loop unit is configured to return to the step of randomly selecting a network resource based on the set number of allocations and the second probability if the third probability is greater than the second probability, or if at least one of the actual allocation counts is greater than the set number of allocations.
[0193] Optionally, as an example, the resource allocation request is triggered by the user scanning a barcode in the target scene using their electronic device, which then sends the request to the resource allocation device.
[0194] Optionally, as an embodiment, the network resources may include any one of the following: images, text, video, and audio.
[0195] Optionally, as an embodiment, the network resources include text; the N types of network resources include: N different specific texts; the target scenario is a scenario where the N different specific texts are collected to redeem a gift, and the first quantity threshold is the quantity value of the gift in the target scenario.
[0196] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0197] Corresponding to the above method embodiments, this application embodiment also provides a resource allocation device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the above resource allocation method.
[0198] like Figure 8 The diagram shows the structural composition of a resource allocation device, which may include a processor 810, a memory 820, a communication interface 830, and a communication bus 840. The processor 810, memory 820, and communication interface 830 all communicate with each other through the communication bus 840.
[0199] In this embodiment, the processor 810 may be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic devices.
[0200] The processor 810 can call programs stored in the memory 820. Specifically, the processor 810 can execute the operations in the embodiments of the system management method. The memory 820 is used to store one or more programs, which may include program code and computer operation instructions. In this embodiment, the memory 820 stores at least a program for implementing the following functions:
[0201] The system receives a first resource allocation request sent by a first user within the target scenario, wherein the first resource allocation request is used to request the allocation of a network resource; in response to the first resource allocation request, a network resource is allocated to the first user according to a first probability, and the type information of the network resource allocated to the first user is recorded in a user database, wherein the user database includes: the number of various network resources allocated to each first user and the type to which each network resource belongs, and the first probability is a manually set probability that the first user has collected all N types of network resources; based on the user database, it is determined whether the number of first users who have collected all N types of network resources has reached a first quantity threshold, and if so, the allocation count of a specific type of network resource among the N types of network resources is set; the system receives a second resource allocation request sent by the first user within the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource; in response to the second resource allocation request, a network resource is allocated to the first user according to the set allocation count.
[0202] In one possible implementation, the memory 820 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.
[0203] Furthermore, memory 820 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device. Communication interface 830 can be an interface for a communication module, used for connecting to other devices or systems. Of course, it should be noted that... Figure 8 The structure shown does not constitute a limitation on the resource allocation device in the embodiments of this application. In practical applications, the resource allocation device may include more than Figure 8 More or fewer components as shown, or combinations of certain components.
[0204] Corresponding to the above method embodiments, this application embodiment also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above resource allocation method.
[0205] Furthermore, it should be noted that this application also provides a computer program product or computer program, which may include computer instructions, which may be stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor can execute the computer instructions, causing the computer device to perform the resource allocation method described in the corresponding embodiments above; therefore, it will not be repeated here. Additionally, the beneficial effects of using the same method will not be repeated here either. For technical details not disclosed in the embodiments of the computer program product or computer program involved in this application, please refer to the description of the method embodiments of this application.
[0206] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Those skilled in the art will further recognize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0207] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0208] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A resource allocation method, characterized in that, The method is applied to a resource allocation device that can allocate N types of network resources, where N is an integer greater than 1. The network resources include any one of the following: images, text, video, and audio. Receive a first resource allocation request sent by a first user in the target scenario, wherein the first resource allocation request is used to request the allocation of a network resource; In response to the first resource allocation request, a network resource is allocated to the first user according to a first probability, and the type information of the network resource allocated to the first user is recorded in the user database. The user database includes: the number of various network resources allocated to each first user and the type of each network resource. The first probability is a manually set probability that the first user has collected all N types of network resources. Based on the user database, determine whether the number of first users who have collected all N types of network resources has reached a first quantity threshold. If so, set the number of times a specific type of network resource is allocated among the N types of network resources. Receive a second resource allocation request sent by a first user in the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource; In response to the second resource allocation request, a network resource is allocated to the first user according to the set number of allocations.
2. The method according to claim 1, characterized in that, The step of allocating a network resource to the first user according to the set number of allocations includes: Based on the set number of allocations and the second probability, a network resource is randomly selected, wherein the second probability is the probability set by the user that the first user has collected all N types of network resources. Based on the user database and the type information of randomly selected network resources, a third probability and the actual number of times the specific type of network resources are allocated after the number of first users who have collected all N types of network resources reaches a first quantity threshold are determined, wherein the third probability is the actual probability that the first user has collected all N types of network resources. Based on the second probability, the third probability, the set number of allocations, and the actual number of allocations, a network resource is allocated to the first user.
3. The method according to claim 2, characterized in that, The number of types of the specific type of network resource is 1; The step of allocating a network resource to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations includes: Determine whether the third probability is less than or equal to the second probability; If the third probability is less than or equal to the second probability, then determine whether the actual number of allocations is less than or equal to the set number of allocations; If the actual number of allocations is less than or equal to the set number of allocations, the randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database. If the third probability is greater than the second probability, or the actual number of allocations is greater than the set number of allocations, then return to the step of randomly selecting a network resource based on the set number of allocations and the second probability.
4. The method according to claim 2, characterized in that, The number of types of the specific type of network resource is M, where M is an integer greater than 1 and less than N; The step of allocating a network resource to the first user based on the second probability, the third probability, the set number of allocations, and the actual number of allocations includes: Determine whether the third probability is less than or equal to the second probability; If the third probability is less than or equal to the second probability, then determine whether the actual allocation counts corresponding to each of the M specific types of network resources are all less than or equal to the set allocation counts; If all the actual allocation counts are less than or equal to the set allocation counts, then the randomly selected network resources are allocated to the first user, and the type information of the network resources allocated to the first user is recorded in the user database. If the third probability is greater than the second probability, or at least one of the actual allocation counts is greater than the set allocation count, then return to the step of randomly selecting a network resource based on the set allocation count and the second probability.
5. The method according to any one of claims 1 to 4, characterized in that, The resource allocation request is triggered when a user scans a barcode within the target scene using their electronic device, causing the electronic device to send the request to the resource allocation device.
6. The method according to claim 1, characterized in that, The network resources include text; the N types of network resources include: N different specific texts; the target scenario is a scenario where the N different specific texts are collected to redeem a gift, and the first quantity threshold is the quantity value of the gift in the target scenario.
7. A resource allocation device, characterized in that, An application is made to a resource allocation device, which can allocate N types of network resources, where N is an integer greater than 1. The network resources include any one of the following: images, text, video, and audio. The device comprises: The first receiving module is used to receive a first resource allocation request sent by a first user in the target scenario, wherein the first resource allocation request is used to request the allocation of a network resource; The first allocation module is configured to respond to the first resource allocation request, allocate a network resource to the first user according to a first probability, and record the type information of the network resource allocated to the first user in the user database. The user database includes: the number of various network resources allocated to each first user and the type of each network resource. The first probability is a manually set probability that the first user collects all N types of network resources. The determining module is used to determine, based on the user database, whether the number of first users who have collected all N types of network resources has reached a first quantity threshold. The setting module is used to set the number of times a specific type of network resource among the N types of network resources is allocated when the number of first users who have collected all N types of network resources reaches a first quantity threshold. The second receiving module is used to receive a second resource allocation request sent by a first user in the target scenario, wherein the second resource allocation request is used to request the allocation of a network resource; The second allocation module is used to respond to the second resource allocation request and allocate a network resource to the first user according to the set number of allocations.
8. A resource allocation device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the resource allocation method according to any one of claims 1-6.
9. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by the processor, they implement the resource allocation method according to any one of claims 1-6.
Citation Information
Patent Citations
Interaction method based on vehicle machine terminal screensaver
CN111614836A
Live broadcast interaction method and device, electronic equipment and storage medium
CN112188297A