CN113434532B - Virtual article distribution method, device, equipment and storage medium - Google Patents
Virtual article distribution method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN113434532B CN113434532B CN202110798874.6A CN202110798874A CN113434532B CN 113434532 B CN113434532 B CN 113434532B CN 202110798874 A CN202110798874 A CN 202110798874A CN 113434532 B CN113434532 B CN 113434532B
- Authority
- CN
- China
- Prior art keywords
- item
- article
- random number
- identifier
- identifications
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000009826 distribution Methods 0.000 title claims abstract description 94
- 238000000034 method Methods 0.000 title claims abstract description 64
- 238000003860 storage Methods 0.000 title claims abstract description 12
- 230000011218 segmentation Effects 0.000 claims description 21
- 238000010586 diagram Methods 0.000 description 16
- 238000004590 computer program Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 4
- 230000009286 beneficial effect Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Information Transfer Between Computers (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a distribution method, a distribution device, distribution equipment and a storage medium of virtual articles. The method comprises the following steps: acquiring weights corresponding to the article identifications; generating a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers; determining a target identifier corresponding to the first random number in a pre-stored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise target identifications, and the indexes of the plurality of item identifications comprise first random numbers; and sending a target identifier to the client, wherein the target identifier is used for indicating the client to search and distribute the virtual article corresponding to the target identifier. The application provides a distribution method, a distribution device, a distribution equipment and a storage medium of virtual articles, which are used for reducing the time complexity required by a server to determine a target identifier.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for distributing virtual items.
Background
Currently, a game server communicates with a game client to enable players to play games through the game client to obtain virtual items. In the process of game entertainment, the game server determines a target identifier in the item identifiers corresponding to a plurality of virtual items (for example, including game props and/or game rewards), and sends the target identifier to the game client, so that the game client searches the virtual item corresponding to the target identifier in the cached plurality of item identifiers according to the target identifier and displays the virtual item corresponding to the target identifier.
In the related art, the game server determines a sum of weights of a plurality of item identifiers, generates a random number, and determines a first difference value between the random number and the weight of a first virtual item in the plurality of item identifiers; when the first difference is larger than or equal to 0, determining a second difference of the random number and the sum of the weights of the first two virtual articles in the plurality of article identifications; and when the second difference is greater than or equal to 0, continuing to determine the difference between the random number and the sum of the weights of the first three virtual articles in the plurality of article identifications, and sequentially continuing to execute similar operations until the difference between the random number and the sum of the weights of the first N virtual articles in the plurality of article identifications is less than 0, determining the identifier of the Nth virtual article in the plurality of article identifications as a target identifier, and sending the target identifier to the game client, wherein N is an integer greater than or equal to 1.
In the above process, the game server needs to calculate the difference between the random number and the sum of the weights of the top 1, or top 2, or top 3 of the plurality of item identifiers, for \8230 \ 8230, the virtual item, to determine the target identifier, so that the time complexity required by the game server to determine the target identifier is large.
Disclosure of Invention
The application provides a distribution method, a distribution device, a distribution equipment and a storage medium of virtual articles, which are used for solving the problem of large time complexity required by determining a target identifier by a game server in the related art.
In a first aspect, the present application provides a method for distributing virtual items, which is applied to a server, and includes:
acquiring weights corresponding to a plurality of article identifiers respectively;
generating a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers;
determining a target identifier corresponding to the first random number in a pre-stored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise target identifications, and the indexes of the plurality of item identifications comprise first random numbers;
and sending a target identifier to the client, wherein the target identifier is used for indicating the client to search and distribute the virtual article corresponding to the target identifier.
In one possible design, determining the target identifier corresponding to the first random number in a pre-stored index dictionary includes:
and determining the item identifier corresponding to the index with the same first random number in the plurality of item identifiers in the index dictionary as the target identifier corresponding to the first random number.
In one possible design, generating a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers includes:
determining a first sum of weights corresponding to the plurality of item identifiers;
and processing the first sum value and the first preset value through a preset random number generation model to obtain a first random number.
In one possible design, obtaining weights corresponding to each of the plurality of item identifiers includes:
obtaining random distribution probabilities corresponding to the article identifications;
and determining the weight corresponding to each of the plurality of item identifications according to the random distribution probability corresponding to each of the plurality of item identifications.
In one possible design, determining a weight corresponding to each of the plurality of item identifiers according to a random distribution probability corresponding to each of the plurality of item identifiers includes:
determining decimal digits of random distribution probabilities corresponding to the article identifications;
determining the largest decimal place number of decimal places of random distribution probabilities corresponding to the multiple article identifications as a target digit number;
and determining the random distribution probability corresponding to each of the plurality of article identifiers as the product of the preset integer corresponding to the target digit respectively.
In one possible design, determining a fractional number of random distribution probabilities corresponding to each of a plurality of item identifiers comprises:
for each article identifier in the article identifiers, segmenting the random distribution probability corresponding to the article identifier to obtain a segmentation sequence; each digit of the random distribution probability corresponding to the article identification is included in the segmentation sequence;
determining a first digit of a decimal point in a segmentation sequence;
and determining the total number of other digits after the first digit in the segmentation sequence as the decimal digit of the random distribution probability corresponding to the article identifier.
In one possible design, obtaining weights corresponding to each of the plurality of item identifiers includes:
acquiring a pre-stored virtual article list; the virtual article list comprises weights corresponding to the article identifications;
and acquiring weights corresponding to the plurality of item identifications from the virtual item list.
In one possible design, the method further includes:
step 1: acquiring an ith item identifier and a weight corresponding to the ith item identifier which are included in a pre-stored virtual item list; the virtual item list comprises a plurality of item identifications and weights corresponding to the item identifications;
step 2: recording the ith item identification with the jth index in an index dictionary; updating the weight corresponding to the ith article identifier into the difference value between the weight corresponding to the ith article identifier and a second preset value;
and step 3: judging whether the weight corresponding to the updated ith article identifier is less than or equal to 0; if not, executing the step 4, and if so, executing the step 5;
and 4, step 4: adding 1 to j, and repeatedly executing the step 2 and the step 3 until the weight corresponding to the ith item identifier is less than or equal to 0, and executing the step 5;
and 5: adding 1 to i, adding 1 to j, and repeatedly executing the step 1, the step 2 and the step 3 until an index dictionary is obtained when i is larger than the total number of the plurality of article identifications;
initially i equals 1 and j equals 1.
In a second aspect, the present application provides a virtual article distribution apparatus, applied to a server, the apparatus including: the device comprises an acquisition module, a generation module, a determination module and a sending module; wherein,
acquiring weights corresponding to the article identifications;
generating a first random number according to the weight and the first preset value corresponding to each article identifier;
determining a target identifier corresponding to the first random number in a pre-stored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise target identifications, and the indexes of the plurality of item identifications comprise first random numbers;
and sending a target identifier to the client, wherein the target identifier is used for indicating the client to search and distribute the virtual article corresponding to the target identifier.
In one possible design, the determining module is specifically configured to:
and determining the item identifier corresponding to the index with the same first random number as the object identifier corresponding to the first random number in the plurality of item identifiers in the index dictionary.
In one possible design, the generation module is specifically configured to:
determining a first sum of weights corresponding to the plurality of item identifiers;
and processing the first sum value and the first preset value through a preset random number generation model to obtain a first random number.
In one possible design, the obtaining module is specifically configured to:
obtaining random distribution probabilities corresponding to the article identifications;
and determining the weight corresponding to each of the plurality of item identifiers according to the random distribution probability corresponding to each of the plurality of item identifiers.
In one possible design, the obtaining module is specifically configured to:
determining decimal digits of random distribution probabilities corresponding to the article identifications;
determining the largest decimal place number in the decimal places of the random distribution probability corresponding to each of the plurality of article identifications as a target digit;
and determining the random distribution probability corresponding to each of the plurality of article identifiers as the product of the preset integer corresponding to the target digit respectively.
In one possible design, the obtaining module is specifically configured to:
for each article identifier in the article identifiers, segmenting the random distribution probability corresponding to the article identifier to obtain a segmentation sequence; each digit of the random distribution probability corresponding to the article identification is included in the segmentation sequence;
determining a first digit of a decimal point in a segmentation sequence;
and determining the total number of other digits after the first digit in the segmentation sequence as the decimal digit of the random distribution probability corresponding to the article identifier.
In one possible design, the obtaining module is specifically configured to:
acquiring a pre-stored virtual article list; the virtual article list comprises weights corresponding to the article identifications;
and acquiring weights corresponding to the plurality of item identifications from the virtual item list.
In one possible design, the apparatus further includes: a creation module; the creation module is used for executing the following steps:
step 1: acquiring an ith item identifier and a weight corresponding to the ith item identifier which are included in a pre-stored virtual item list; the virtual article list comprises a plurality of article identifications and weights corresponding to the article identifications;
step 2: recording the ith item identification with the jth index in the index dictionary; updating the weight corresponding to the ith article identifier into the difference value between the weight corresponding to the ith article identifier and a second preset value;
and step 3: judging whether the weight corresponding to the updated ith article identifier is less than or equal to 0; if not, executing the step 4, and if so, executing the step 5;
and 4, step 4: adding 1 to j, and repeatedly executing the step 2 and the step 3 until the weight corresponding to the ith item identifier is less than or equal to 0, executing the step 5;
and 5: adding 1 to i, adding 1 to j, and repeatedly executing the step 1, the step 2 and the step 3 until an index dictionary is obtained when i is larger than the total number of the plurality of article identifications;
initially i equals 1 and j equals 1.
In a third aspect, the present application provides a server, comprising: a memory and a processor;
a memory for storing program code;
a processor for invoking the extent code stored in the memory to implement the method for distributing a virtual item as described above in any one of the first aspects.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the method for distributing virtual items according to any one of the first aspect above when executed by a processor.
In a fifth aspect, the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the method of distribution of virtual items as in any one of the first aspect above.
The application provides a distribution method, a distribution device, a distribution equipment and a storage medium of virtual articles, wherein the method comprises the following steps: acquiring weights corresponding to a plurality of article identifiers respectively; generating a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers; determining a target identifier corresponding to the first random number in a pre-stored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise target identifications, and the indexes of the plurality of item identifications comprise first random numbers; and sending a target identifier to the client, wherein the target identifier is used for indicating the client to search and distribute the virtual article corresponding to the target identifier. In the method described above, after the first random number is generated, the target identifier corresponding to the first random number may be determined in the pre-stored index dictionary, so that the time complexity required by the server to determine the target identifier is O (1), and S103 in the embodiment of fig. 1 does not need to be repeatedly executed multiple times, thereby reducing the time complexity required by the server to determine the target identifier.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic flowchart of determining a target identifier in the prior art provided in an embodiment of the present application;
fig. 2 is a schematic diagram of determining a target identifier in the prior art according to an embodiment of the present application;
FIG. 3 is a schematic diagram of determining a target identifier according to an embodiment of the present application;
fig. 4 is a first flowchart illustrating a distribution method of a virtual item according to an embodiment of the present disclosure;
fig. 5 is a second flowchart illustrating a distribution method of virtual items according to an embodiment of the present application;
fig. 6 is a schematic flowchart of creating an index dictionary according to an embodiment of the present application;
FIG. 7 is a first schematic structural diagram of a virtual article distribution device provided in an embodiment of the present application;
fig. 8 is a schematic structural diagram of a virtual article distribution device according to an embodiment of the present application;
fig. 9 is a schematic hardware structure diagram of a server according to an embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
Fig. 1 is a schematic flowchart of determining a target identifier in the prior art. As shown in fig. 1, the game server determines the target identifier by S101 to S106 as follows:
s101, the game server acquires weights corresponding to a plurality of item identifications from a pre-stored item list and determines the sum of the weights corresponding to the item identifications.
Exemplary, item lists are shown in table 1 below.
TABLE 1
Article identification | Weight of |
A1 | W1 |
A2 | W2 |
A3 | W3 |
…… | …… |
Aj | Wj |
On the basis of the above table 1, the sum of the weights respectively corresponding to the plurality of article identifiers is equal to the sum of W1 to Wn.
S102, generating a random number, wherein the random number is any integer from 0 to the sum of weights corresponding to the plurality of article identifiers.
S103, determining a difference value between the random number and the sum of weights corresponding to the first i article identifications in the article list.
Specifically, the difference can be obtained by the following formula 1:
wherein R is a random number, W j For the weight corresponding to the jth item identifier in the first i item identifiers, R i The difference value of the random number R and the sum of the weights respectively corresponding to the first i article identifications in the article list.
And S104, judging whether the difference value is less than or equal to 0.
If yes, go to step S105, otherwise go to step S106.
S105, determining the ith item identifier in the previous i item identifiers as a target identifier, and sending the target identifier to the game client.
S106, adding 1 to i, and repeatedly executing S103-S104.
In S101 to S106, S103 may need to be repeatedly executed multiple times, for example, the maximum possible number of times S103 is executed multiple times is N (equal to the number of multiple item identifiers included in the item list), and therefore, the time complexity of determining the target identifier in the above prior art is O (N).
Fig. 2 is a schematic diagram of determining a target identifier in the prior art. As shown in fig. 2, the item list includes: the item identifiers A, B and C, and the weight 30 corresponding to the item identifier A, the weight 20 corresponding to the item identifier B, and the weight 50 corresponding to the item identifier C.
Illustratively, when the random number is 70, the item identifier C is determined as the target identifier, that is, the target identifier can be determined by performing the method shown in fig. 13 times (equal to the item identifiers a, B and C, including the first time, the second time and the third time), so that the time complexity required by the game server to determine the target identifier is large by the method shown in fig. 1.
In order to reduce the time complexity required by the server to determine the target identifier in the present application, the inventors thought of creating and storing an index dictionary in advance, the index dictionary including a plurality of item identifiers having indexes, the indexes of the plurality of item identifiers corresponding to a plurality of random numbers, and after generating the random numbers, determining an item identifier having the same index as the random number from among the plurality of item identifiers as the target identifier, thereby making the time complexity required by the server to determine the target identifier O (1).
Fig. 3 is a schematic diagram of determining a target identifier according to an embodiment of the present application. As shown in fig. 3, the index dictionary includes: an item identification Q1 with index 1, an item identification Q1 with index 2, an item identification Q1 with index 3, an item identification Q2 with index 4, an item identification Q3 with index 5, an item identification Q3 with index 6.
For example, when the random number is 4 after the random number is generated, the item identifier (i.e., Q2) of the same index as the random number 4 may be directly determined as the target identifier.
In the application, after the random number is generated, the item identifier with the same index as the random number in the plurality of item identifiers can be determined as the target identifier, so that the time complexity required by the server to determine the target identifier is O (1), and the time complexity of the server to determine the target identifier is reduced.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 4 is a first flowchart of a distribution method of a virtual item according to an embodiment of the present application. As shown in fig. 4, the method includes:
s401, obtaining weights corresponding to the plurality of article identifications.
Optionally, the execution subject of the embodiment of the present application is a server, and may also be a distribution apparatus of a virtual item disposed in the server, where the distribution apparatus may be implemented by a combination of software and/or hardware.
The item identification is an identification of a virtual item. A virtual item has a unique identification and may be, for example, a game item and/or a game award or the like.
The weight may indicate a value of the virtual item. The higher the value of the virtual item, the lower its corresponding weight. The lower the value of the virtual item, the greater its corresponding weight.
Alternatively, the weight corresponding to each of the plurality of item identifiers may be determined in the following two ways.
In the method 1, a virtual article list pre-stored by a server is obtained; the virtual article list comprises weights corresponding to the article identifications;
and acquiring weights corresponding to the plurality of item identifications from the virtual item list.
In the mode 2, the random distribution probability corresponding to each of the plurality of article identifiers is obtained; and determining the weight corresponding to each of the plurality of item identifiers according to the random distribution probability corresponding to each of the plurality of item identifiers.
Please refer to the embodiment in fig. 5 for a detailed description of the method 2.
S402, generating a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers.
Specifically, determining a first sum of weights corresponding to a plurality of article identifiers respectively; and processing the first sum value and the first preset value through a preset random number generation model to obtain a first random number.
Further, the following two methods may be adopted, and the first random number is obtained by presetting a random number generation model.
The method comprises the steps that 1, a first sum value, a first preset value and a first parameter value (1) are processed through a preset random number generation model to generate a first random number; wherein the first parameter value indicates that a random number is generated, and illustratively, the first parameter value is 1.
The method 2 comprises the steps of processing a first sum value, a first preset value and a second parameter value (N) through a preset random number generation model to generate N random numbers; and randomly selecting one random number from the N random numbers as a first random number. Wherein the second parameter value indicates that N random numbers are generated, N being an integer greater than or equal to 1.
S403, determining a target identifier corresponding to the first random number in a pre-stored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise target identifications, and the indexes of the plurality of item identifications comprise first random numbers.
Illustratively, when the index dictionary is { Q1, Q1, Q1, Q2, Q2, Q3, Q3, Q3, Q3} the index dictionary has Q1, Q2, Q3 as 3 different item identifiers, the item identifications of a plurality of items in the index dictionary are sequentially divided into 1, 2, 3, 4, 5, 6, 7, 8 and 9.
Illustratively, when the first random number is 7, the item identifier with index 7 is Q3, and therefore Q3 may be determined as the target identifier.
S404, sending a target identifier to the client, wherein the target identifier is used for indicating the client to search and distribute the virtual article corresponding to the target identifier.
The client can operate in an electronic device, such as a mobile phone, a tablet computer, a desktop computer, and the like.
After receiving the target identifier, the client may search for a virtual item corresponding to the target identifier from a plurality of virtual items cached in advance, and distribute the virtual item corresponding to the target identifier, so that the electronic device displays the virtual item corresponding to the target identifier.
In the distribution method of virtual items provided in the embodiment of fig. 4, after the first random number is generated, the target identifier corresponding to the first random number may be determined in the pre-stored index dictionary, so that the time complexity required by the server to determine the target identifier is O (1), and S103 in the embodiment of fig. 1 does not need to be repeatedly executed multiple times, thereby reducing the time complexity required by the server to determine the target identifier.
Based on the above embodiments, the following describes in further detail a distribution method of virtual items provided in the embodiments of the present application with reference to fig. 5.
Fig. 5 is a schematic flowchart of a second method for distributing virtual items according to an embodiment of the present application. As shown in fig. 5, the method includes:
s501, obtaining random distribution probabilities corresponding to the article identifications.
The virtual items have different values, and the random distribution probabilities corresponding to the item identifiers of the virtual items are also different. The higher the value of the virtual item, the lower the random distribution probability corresponding to the item identification of the virtual item.
The random distribution probability is a number greater than 0 and less than 1.
Illustratively, when the plurality of item identifiers includes Q1, Q2, and Q3, Q1 corresponds to a random distribution probability of 0.3, Q2 corresponds to a random distribution probability of 0.24, and Q3 corresponds to a random distribution probability of 0.46.
S502, determining the decimal number of random distribution probability corresponding to each of the article identifications.
Specifically, for each article identifier in the plurality of article identifiers, the random distribution probability corresponding to the article identifier is segmented to obtain a segmentation sequence; each digit of the random distribution probability corresponding to the article identification is included in the segmentation sequence;
determining a first digit of a decimal point in a segmentation sequence;
and determining the total number of other digits after the first digit in the segmentation sequence as the decimal digit of the random distribution probability corresponding to the article identification.
Illustratively, when an item is identified as Q3, Q3 corresponds to a random distribution probability of 0.46, and after 0.46 is segmented, the resulting segmentation sequences are [ "0", "-", "4", "6" ]. Further, it is determined that the first digit of the decimal point in the segmented sequence is 2, and since the total number of the other digits (i.e. the digit of "4" and the digit of "6") after the first digit in the segmented sequence is 2, the decimal digit of the random distribution probability corresponding to the item identifier is 2.
S503, the largest decimal place number in the decimal places of the random distribution probability corresponding to each of the plurality of article identifications is determined as the target digit.
Illustratively, the decimal place of the random distribution probability 0.3 corresponding to Q1 is 1, the decimal place of the random distribution probability 0.24 corresponding to Q2 is 2, and the decimal place of the random distribution probability 0.46 corresponding to Q3 is 2, so the largest decimal place of 2 is determined as the target digit.
S504, the random distribution probability corresponding to each of the plurality of article identifiers is multiplied by the preset integer corresponding to the target digit to determine the random distribution probability as the weight corresponding to each of the plurality of article identifiers.
Specifically, the server stores in advance a plurality of integers corresponding to the number of digits. Illustratively, when the plurality of digits includes 1, 2, and 3, the preset integer corresponding to the digit 1 is 10, the preset integer corresponding to the digit 2 is 100, and the preset integer corresponding to the digit 3 is 1000.
Illustratively, when Q1 corresponds to a random distribution probability of 0.3, Q2 corresponds to a random distribution probability of 0.24, Q3 corresponds to a random distribution probability of 0.46, and the target number corresponds to a predetermined integer of 100, Q1 corresponds to a weight equal to 30 (i.e., the product of 0.3 and 100), Q2 corresponds to a weight equal to 24 (i.e., the product of 0.24 and 100), and Q3 corresponds to a weight equal to 46 (i.e., the product of 0.46 and 100).
And S505, determining a first sum of weights corresponding to the plurality of item identifications respectively.
Illustratively, the first sum equals 100 (i.e., the sum of 30, 24 and 46) when Q1 corresponds to a weight equal to 30, Q2 corresponds to a weight equal to 24, and Q3 corresponds to a weight equal to 46.
S506, processing the first sum value and the first preset value through a preset random number generation model to obtain a first random number.
Specifically, the execution method of S402 is similar to the execution method of S506, and the execution process of S506 is not described herein again.
And S507, determining the item identifier corresponding to the index with the same first random number in the plurality of item identifiers in the index dictionary as the target identifier corresponding to the first random number.
In the present application, an index dictionary may be created in advance and stored. Specifically, a method of creating the index dictionary may be explained with reference to fig. 6.
Specifically, the index that is the same as the first random number is searched in the index dictionary, and the item identifier corresponding to the index that is the same as the first random number is determined as the target identifier corresponding to the first random number.
And S508, sending the target identification to the client.
In the embodiment of fig. 5, after the first random number is generated, an item identifier corresponding to an index that is the same as the first random number in the plurality of item identifiers included in the index dictionary is determined as a target identifier corresponding to the first random number, so that the time complexity required by the server to determine the target identifier is O (1), and S103 in the embodiment of fig. 1 does not need to be repeatedly executed for multiple times, thereby reducing the time complexity required by the server to determine the target identifier.
Unlike the prior art, in the prior art, the time complexity required by the game server to determine the target identifier is large, so that the efficiency of determining the target identifier by the game server is low, and the performance overhead of the game server is further improved. In the application, the time complexity required by the server to determine the target identifier is low, so that the efficiency of the server to determine the target identifier can be improved, and the performance overhead of the server is reduced.
On the basis of any of the above embodiments, a method for creating an index dictionary is described below with reference to fig. 6.
Fig. 6 is a schematic flowchart of creating an index dictionary according to an embodiment of the present application. As shown in fig. 6, the method includes:
s601, acquiring the ith item identifier and the weight corresponding to the ith item identifier included in the pre-stored virtual item list.
The virtual item list includes a plurality of item identifiers and weights corresponding to the plurality of item identifiers. Initially i equals 1.
S602, recording an ith item identifier with a jth index in an index dictionary; and updating the weight corresponding to the ith article identifier into the difference value between the weight corresponding to the ith article identifier and the second preset value.
Initially, j equals 1.
S603, judging whether the weight corresponding to the updated ith item identifier is less than or equal to 0.
If not, S604 is executed, and if yes, S605 to S608 are executed.
S604, adding 1 to j, and repeatedly executing S602 to S603 until the weight corresponding to the ith item identifier is less than or equal to 0, and executing S605.
And S605, adding 1 to i.
And S606, judging whether i is larger than the total number of the plurality of article identifiers.
If not, in step S607, if yes, step S608 is performed.
S607, adding 1 to j, and repeating the steps S601-S606.
And S608, obtaining an index dictionary.
Fig. 7 is a first schematic structural diagram of a virtual article distribution device according to an embodiment of the present application. As shown in fig. 7, the dispensing apparatus 10 includes: the device comprises an acquisition module 11, a generation module 12, a determination module 13 and a sending module 14; wherein,
an obtaining module 11, configured to obtain weights corresponding to multiple article identifiers;
a generating module 12, configured to generate a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers;
a determining module 13, configured to determine, in a pre-stored index dictionary, a target identifier corresponding to the first random number; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise target identifications, and the indexes of the plurality of item identifications comprise first random numbers;
and a sending module 14, configured to send the target identifier to the client, where the target identifier is used to instruct the client to search for and distribute a virtual item corresponding to the target identifier.
The distribution device for virtual articles provided in the embodiment of the present application may implement the technical solutions shown in the above method embodiments, and the implementation principle and beneficial effects are similar, which are not described herein again.
Fig. 8 is a schematic structural diagram of a virtual article distribution apparatus according to an embodiment of the present application. As shown in fig. 8, the dispensing apparatus 10 further includes: a creation module 15; the creation module 15 is configured to perform the following steps:
step 1: acquiring an ith item identifier and a weight corresponding to the ith item identifier which are included in a pre-stored virtual item list; the virtual item list comprises a plurality of item identifications and weights corresponding to the item identifications;
and 2, step: recording the ith item identification with the jth index in an index dictionary; updating the weight corresponding to the ith article identifier into the difference value between the weight corresponding to the ith article identifier and a second preset value;
and step 3: judging whether the weight corresponding to the updated ith item identifier is less than or equal to 0; if not, executing the step 4, and if so, executing the step 5;
and 4, step 4: adding 1 to j, and repeatedly executing the step 2 and the step 3 until the weight corresponding to the ith item identifier is less than or equal to 0, and executing the step 5;
and 5: adding 1 to i, adding 1 to j, and repeatedly executing the step 1, the step 2 and the step 3 until an index dictionary is obtained when i is larger than the total number of the plurality of article identifications;
initially i equals 1 and j equals 1.
The distribution device for virtual articles provided in the embodiment of the present application may implement the technical solutions shown in the above method embodiments, and the implementation principle and beneficial effects are similar, which are not described herein again.
In one possible design, the determining module 13 is specifically configured to:
and determining the item identifier corresponding to the index with the same first random number in the plurality of item identifiers in the index dictionary as the target identifier corresponding to the first random number.
In one possible design, the generation module 12 is specifically configured to:
determining a first sum of weights corresponding to the plurality of item identifiers;
and processing the first sum value and the first preset value through a preset random number generation model to obtain a first random number.
In one possible design, the obtaining module 11 is specifically configured to:
obtaining random distribution probabilities corresponding to the article identifications;
and determining the weight corresponding to each of the plurality of item identifications according to the random distribution probability corresponding to each of the plurality of item identifications.
In one possible design, the obtaining module 11 is specifically configured to:
determining decimal digits of random distribution probabilities corresponding to the article identifications;
determining the largest decimal place number in the decimal places of the random distribution probability corresponding to each of the plurality of article identifications as a target digit;
and determining the random distribution probability corresponding to each of the plurality of article identifiers as the product of the preset integer corresponding to the target digit respectively.
In one possible design, the obtaining module 11 is specifically configured to:
for each article identifier in the article identifiers, segmenting the random distribution probability corresponding to the article identifier to obtain a segmentation sequence; each digit of the random distribution probability corresponding to the item identification is included in the segmentation sequence;
determining a first digit of a decimal point in a segmentation sequence;
and determining the total number of other digits after the first digit in the segmentation sequence as the decimal digit of the random distribution probability corresponding to the article identification.
In one possible design, the obtaining module 11 is specifically configured to:
acquiring a pre-stored virtual article list; the virtual article list comprises weights corresponding to the article identifications;
and acquiring weights corresponding to the plurality of item identifications from the virtual item list.
The distribution device for virtual articles provided in the embodiment of the present application can implement the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects thereof are similar and will not be described herein again.
Fig. 9 is a schematic hardware structure diagram of a server according to an embodiment of the present application. As shown in fig. 9, the server 20 includes: a transceiver 21, a memory 22, a processor 23.
The transceiver 21 may include: a transmitter and/or a receiver.
The transmitter may also be referred to as a sender, a transmitter, a sending port or a sending interface, and the like, and the receiver may also be referred to as a receiver, a receiving port or a receiving interface, and the like.
The transceiver 21 is used for receiving data transmitted by other devices or transmitting data to other devices.
The transceiver 21, the memory 22, and the processor 23 are illustratively interconnected via a bus 34.
The memory 22 is used to store computer-executable instructions.
The processor 23 is configured to execute the computer-executable instructions stored in the memory 22, so that the processor 23 executes the distribution method of the virtual item shown in any one of the above method embodiments. For a specific implementation process of the processor 23, reference may be made to the above method embodiments, which implement the principle and the technical effect similarly, and details of this embodiment are not described herein again.
In the embodiment shown in fig. 9, it should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in the incorporated application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
The memory may comprise high speed RAM memory, and may also include non-volatile storage NVM, such as disk memory.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The application also provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the processor executes the computer-executable instructions, the distribution method of the virtual article is realized.
The present application also provides a computer program product comprising a computer program which, when executed by a processor, implements a method of distribution of a virtual item as above.
All or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The aforementioned program may be stored in a readable memory. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid state disk, magnetic tape (magnetic tape), floppy disk (optical disk), and any combination thereof.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processing unit of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the embodiments of the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to encompass such modifications and variations.
In the present application, the terms "include" and variations thereof may refer to non-limiting inclusions; the term "or" and variations thereof may mean "and/or". The terms "first," "second," and the like in this application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. In the present application, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
Claims (10)
1. A method for distributing virtual articles, applied to a server, the method comprising:
acquiring weights corresponding to the article identifications;
generating a first random number according to the weight and a first preset value corresponding to each of the plurality of article identifiers, wherein the first preset value is 0;
determining a target identifier corresponding to the first random number in a pre-stored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise the target identification, and the indexes of the plurality of item identifications comprise the first random number;
sending the target identification to a client, wherein the target identification is used for indicating the client to search and distribute virtual articles corresponding to the target identification;
generating a first random number according to the weight and the first preset value corresponding to each of the plurality of article identifiers, including:
determining a first sum of the weights corresponding to the plurality of item identifiers;
processing the first sum, the first preset value and the first parameter value through a preset random number generation model to generate a first random number; wherein the first parameter value indicates generation of a random number; or,
processing the first sum, the first preset value and the second parameter value through the preset random number generation model to generate N random numbers; randomly selecting one random number from the N random numbers as the first random number; wherein the second parameter value indicates that N random numbers are generated, N being an integer greater than or equal to 1.
2. The method of claim 1, wherein determining the target identifier corresponding to the first random number in a pre-stored index dictionary comprises:
and determining the item identifier corresponding to the index with the same first random number in the plurality of item identifiers in the index dictionary as the target identifier corresponding to the first random number.
3. The method according to any one of claims 1-2, wherein obtaining weights corresponding to each of the plurality of item identifiers comprises:
obtaining random distribution probabilities corresponding to the article identifications;
and determining the weights corresponding to the item identifications according to the random distribution probabilities corresponding to the item identifications.
4. The method according to claim 3, wherein the determining the weights corresponding to the item identifiers according to the random distribution probabilities corresponding to the item identifiers comprises:
determining the decimal digit of the random distribution probability corresponding to each of the plurality of article identifications;
determining the largest decimal place number in the decimal places of the random distribution probability corresponding to each article identifier as a target digit number;
and determining the random distribution probability corresponding to each of the plurality of article identifiers as the product of the preset integer corresponding to the target digit respectively, and determining the product as the weight corresponding to each of the plurality of article identifiers.
5. The method of claim 4, wherein determining the fractional number of random distribution probabilities for each of the plurality of item identifiers comprises:
for each article identifier in the article identifiers, segmenting the random distribution probability corresponding to the article identifier to obtain a segmentation sequence; the segmentation sequence comprises each digit of the random distribution probability corresponding to the item identification;
determining a first digit of a decimal point in the segmentation sequence;
and determining the total number of other digits after the first digit in the segmentation sequence as the decimal digit of the random distribution probability corresponding to the article identification.
6. The method according to any one of claims 1-2, wherein obtaining weights corresponding to each of the plurality of item identifiers comprises:
acquiring a pre-stored virtual article list; the virtual article list comprises weights corresponding to the article identifications;
and acquiring weights corresponding to the plurality of item identifications from the virtual item list.
7. The method according to any one of claims 1-2, further comprising:
step 1: acquiring an ith item identifier included in a pre-stored virtual item list and a weight corresponding to the ith item identifier; the virtual item list comprises the plurality of item identifications and weights corresponding to the plurality of item identifications;
and 2, step: recording the ith item identifier with the jth index in an index dictionary; updating the weight corresponding to the ith article identifier to be the difference value between the weight corresponding to the ith article identifier and a second preset value;
and 3, step 3: judging whether the updated weight corresponding to the ith item identifier is less than or equal to 0; if not, executing the step 4, and if so, executing the step 5;
and 4, step 4: adding 1 to j, and repeatedly executing the step 2 and the step 3 until the step 5 is executed when the weight corresponding to the ith item identifier is less than or equal to 0;
and 5: adding 1 to i, adding 1 to j, and repeatedly executing the step 1, the step 2 and the step 3 until an index dictionary is obtained when i is larger than the total number of the plurality of article identifications;
initially i equals 1 and j equals 1.
8. An apparatus for distributing virtual articles, the apparatus being applied to a server, the apparatus comprising: the device comprises an acquisition module, a generation module, a determination module and a sending module; wherein,
the acquisition module is used for acquiring weights corresponding to the article identifications;
the generating module is used for generating a first random number according to the weight and a first preset value corresponding to each of the article identifiers, wherein the first preset value is 0;
the determining module is used for determining the target identifier corresponding to the first random number in a prestored index dictionary; the index dictionary comprises a plurality of item identifications with indexes, the plurality of item identifications comprise the target identification, and the indexes of the plurality of item identifications comprise the first random number;
the sending module is used for sending the target identifier to a client, wherein the target identifier is used for indicating the client to search and distribute a virtual article corresponding to the target identifier;
the generation module is specifically configured to:
determining a first sum of the weights corresponding to the plurality of item identifiers;
processing the first sum, the first preset value and the first parameter value through a preset random number generation model to generate a first random number; wherein the first parameter value indicates generation of a random number; or,
processing the first sum, the first preset value and the second parameter value through the preset random number generation model to generate N random numbers; randomly selecting one random number from the N random numbers as the first random number; wherein the second parameter value indicates that N random numbers are generated, N being an integer greater than or equal to 1.
9. A server, comprising: a memory and a processor;
the memory for storing program code;
the processor, configured to invoke the extent code stored in the memory, to implement the distribution method of the virtual item according to any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer-executable instructions for implementing the method of distributing virtual items according to any one of claims 1 to 7 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110798874.6A CN113434532B (en) | 2021-07-15 | 2021-07-15 | Virtual article distribution method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110798874.6A CN113434532B (en) | 2021-07-15 | 2021-07-15 | Virtual article distribution method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113434532A CN113434532A (en) | 2021-09-24 |
CN113434532B true CN113434532B (en) | 2022-10-04 |
Family
ID=77760501
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110798874.6A Active CN113434532B (en) | 2021-07-15 | 2021-07-15 | Virtual article distribution method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113434532B (en) |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2016101261A (en) * | 2014-11-27 | 2016-06-02 | 株式会社コロプラ | Sound message system |
CN109663364A (en) * | 2017-10-13 | 2019-04-23 | 腾讯科技(深圳)有限公司 | Virtual prize provides control method and device, electronic equipment |
CN108874923B (en) * | 2018-05-31 | 2023-07-04 | 康键信息技术(深圳)有限公司 | Virtual article distribution method, server, and computer-readable storage medium |
CN112090074B (en) * | 2020-09-18 | 2022-03-01 | 腾讯科技(深圳)有限公司 | Virtual article control method, device, equipment and medium in application |
-
2021
- 2021-07-15 CN CN202110798874.6A patent/CN113434532B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN113434532A (en) | 2021-09-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112074818A (en) | Method and node for enabling access to past transactions in a blockchain network | |
CN114281793A (en) | Data verification method, device and system | |
US12019839B2 (en) | User-specific graphical user interface based on a graphical user interface template | |
CN110099112A (en) | Date storage method, device, medium and terminal device based on point to point network | |
CN111159211A (en) | Order information generation method, device and system, computer equipment and storage medium | |
US10262081B2 (en) | Method and apparatus for improved database searching | |
CN113434532B (en) | Virtual article distribution method, device, equipment and storage medium | |
CN113128821A (en) | Method and device for determining task | |
CN110334104A (en) | A kind of list update method, device, electronic equipment and storage medium | |
CN109345252A (en) | A kind of online trading control method, device and computer equipment | |
CN116303418A (en) | Mass rule processing method, system and storage medium based on Internet of things platform | |
CN111045700B (en) | Data updating method, device, system, storage medium and electronic equipment | |
CN113205578B (en) | Layer processing method, layer rendering method and related equipment | |
CN111754059A (en) | Task combination method and device | |
CN111291801B (en) | Data processing method and device | |
CN109885622B (en) | Data processing equipment, system and multi-node data processing method | |
CN113689524A (en) | Method, device, electronic equipment and medium for constructing convex hull facing to plane point set | |
CN110377019B (en) | Route generation method and device | |
CN110348250B (en) | Hardware overhead optimization method and system of multi-chain hash stack | |
CN110442612B (en) | Data query method, electronic device and computer-readable storage medium | |
CN108573012B (en) | Data processing method, device, equipment and storage medium | |
CN113515495B (en) | Data file distribution method and device, intelligent equipment and computer storage medium | |
CN111339134B (en) | Data query method and device | |
CN105677318A (en) | Method for preventing game from being modified by memory modifier | |
CN112380440A (en) | Information searching method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |