Random number generation method, device, equipment and medium
By pre-generating and displaying random numbers on the client side, combined with server verification, the problem of low efficiency in random number generation in existing technologies is solved, achieving efficient front-end feedback of random events and game security.
Patent Information
- Application Number
- CN202210993740.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-18
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-08-18
AI Technical Summary
In existing technologies, random number generation schemes involve many steps, resulting in low efficiency and affecting the efficiency of random event feedback in games.
The client pre-generates a random number and performs a front-end display action. After the server verifies the number, it performs a back-end calculation action to ensure that the random number matches and improve the efficiency of front-end feedback.
By pre-executing the foreground display actions of random events on the client side, the efficiency of foreground feedback of random events is improved, and server verification ensures the game's non-cheating nature.
Smart Images

Figure CN115357219B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and medium for generating random numbers. Background Technology
[0002] Games typically include a "critical hit" mechanic to enhance gameplay and competitiveness. Whether a critical hit occurs is determined by its probability. For example, if game character A has a 50% critical hit probability, it means that each of character A's attacks has a 50% chance of resulting in a critical hit, dealing more damage to the enemy character.
[0003] The relevant technology determines whether a critical hit has occurred through random number generation. For example, the server generates a random number and determines the critical hit result based on the random number. Then, the server sends the critical hit result to the client. If the critical hit result indicates that a critical hit has occurred, the client displays a critical hit effect based on the result.
[0004] However, the related technologies involve many steps, which makes the solution time-consuming and results in low efficiency. Summary of the Invention
[0005] This application provides a method, apparatus, device, and medium for generating random numbers. This method allows the client to pre-display random events without waiting for server-side decisions, thus improving efficiency. The technical solution is as follows:
[0006] According to one aspect of this application, a method for generating random numbers is provided, the method being performed by a client, the method comprising:
[0007] The first random number is generated based on a random seed and a random number index i. The random seed is synchronized from the server to the client, and i is a positive integer.
[0008] The front-end display action of the random event is executed based on the i-th first random number;
[0009] Send the i-th first random number and the random number sequence number to the server;
[0010] Based on the confirmation message returned by the server, perform the background calculation action for the random event;
[0011] The confirmation information is sent by the server when the i-th second random number matches the i-th first random number, and the i-th second random number is generated by the server based on the random seed and the random number sequence number.
[0012] According to another aspect of this application, a random number generation apparatus is provided, the apparatus comprising:
[0013] The first calculation module is used to generate the i-th first random number based on the random seed and the random number index i, wherein the random seed is synchronized from the server to the client, and i is a positive integer;
[0014] The display module is used to perform a front-end display action of a random event based on the i-th first random number;
[0015] The first interaction module is used to send the i-th first random number and the random number sequence number to the server;
[0016] The first calculation module is further configured to perform background calculations of the random event based on the confirmation message returned by the server.
[0017] The confirmation information is sent by the server when the i-th second random number matches the i-th first random number, and the i-th second random number is generated by the server based on the random seed and the random number sequence number.
[0018] According to one aspect of this application, a method for generating random numbers is provided, the method being performed by a server, the method comprising:
[0019] The client receives the i-th first random number and the random number index i. The i-th first random number is generated by the client based on the random seed and the random number index. The random seed is synchronized to the client by the server. The i-th first random number is used by the client to perform a front-end display action of a random event. i is a positive integer.
[0020] The i-th second random number is determined based on the random seed and the random number index;
[0021] If the i-th second random number matches the i-th first random number, a confirmation message is sent to the client. The confirmation message is used by the client to perform background calculations for the random event.
[0022] According to one aspect of this application, a random number generation apparatus is provided, the apparatus comprising:
[0023] The first calculation module is used to generate the i-th first random number based on the random seed and the random number index i, wherein the random seed is synchronized from the server to the client, and i is a positive integer;
[0024] The display module is used to perform a front-end display action of a random event based on the i-th first random number;
[0025] The interaction module is used to send the i-th first random number and the random number sequence number to the server;
[0026] The first calculation module is further configured to perform background calculations of the random event based on the confirmation message returned by the server.
[0027] The confirmation information is sent by the server when the i-th second random number matches the i-th first random number, and the i-th second random number is generated by the server based on the random seed and the random number sequence number.
[0028] According to another aspect of this application, a computer device is provided, comprising: a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, wherein the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement the random number generation method as described above.
[0029] According to another aspect of this application, a computer storage medium is provided, wherein at least one piece of program code is stored in the computer-readable storage medium, the program code being loaded and executed by a processor to implement the random number generation method as described above.
[0030] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the random number generation method described above.
[0031] The beneficial effects of the technical solutions provided in this application include at least the following:
[0032] After generating a random number, the client directly executes the foreground display action of the random event based on the random number. Then, based on the confirmation message returned by the server, the client executes the background calculation action of the random event. Therefore, this embodiment can execute the foreground display action in advance, improving the foreground feedback efficiency of random events. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.
[0034] Figure 1 This is a schematic diagram of the structure of a computer system provided in an exemplary embodiment of this application;
[0035] Figure 2 This is a flowchart of a random number generation method provided in an exemplary embodiment of this application;
[0036] Figure 3 This is a flowchart of a random number generation method provided in an exemplary embodiment of this application;
[0037] Figure 4 This is a flowchart of a random number generation method provided in an exemplary embodiment of this application;
[0038] Figure 5 This is a flowchart of a random number generation method provided in an exemplary embodiment of this application;
[0039] Figure 6 This is a flowchart of a critical hit determination method provided in an exemplary embodiment of this application;
[0040] Figure 7 This is a flowchart of a method for determining the drop of items provided in an exemplary embodiment of this application;
[0041] Figure 8 This is a flowchart of a method for determining attack effects provided in an exemplary embodiment of this application;
[0042] Figure 9 This is a schematic diagram of the structure of a random number generation apparatus provided in an exemplary embodiment of this application;
[0043] Figure 10 This is a schematic diagram of the structure of a random number generation apparatus provided in an exemplary embodiment of this application;
[0044] Figure 11 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0046] Random numbers: Based on how they are generated, random numbers can be divided into true random numbers and pseudo random numbers. True random numbers are generated through physical phenomena; their values are completely unpredictable and possess genuine randomness.
[0047] Pseudo-random numbers are random numbers generated through random algorithms. Although pseudo-random numbers can also have high entropy, or even full entropy, they are generated based on algorithms, so the values of the pseudo-random numbers are theoretically predictable and do not possess true randomness.
[0048] Random seed: Ensures that the random numbers generated by the random algorithm are consistent each time. For example, if two identical random algorithms are chosen and the same random seed is used as the input value for both algorithms, then both algorithms will output the same random number.
[0049] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the user information involved in this application was obtained with full authorization.
[0050] Figure 1 A schematic diagram of the structure of a computer system provided in an exemplary embodiment of this application is shown. The computer system 100 includes a client 120 and a server 140.
[0051] Client 120 is a game-related application. This application can be a small app within an app, a dedicated application, or a web client. Optionally, client 120 can be at least one of a smartphone, tablet, e-book reader, MP3 player, MP4 player, laptop, and desktop computer.
[0052] Client 120 connects to server 140 via wireless or wired network.
[0053] Server 140 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 140 provides background services for the game and sends the game screen to client 120. Optionally, server 140 undertakes the main computing work, and client 120 undertakes the secondary computing work; or, server 140 undertakes the secondary computing work, and client 120 undertakes the main computing work; or, server 140 and client 120 use a distributed computing architecture for collaborative computing. Optionally, server 140 and client 120 communicate based on KCP (a reliable transport layer automatic retransmission request protocol) or TCP (Transmission Control Protocol).
[0054] Figure 2 This application illustrates a method for generating random numbers according to an embodiment of the present application. This method can be implemented by... Figure 1 The client 120 shown executes a method that includes:
[0055] Step 202: Generate the i-th first random number based on the random seed and the random number index i. The random seed is synchronized from the server to the client.
[0056] Optionally, a random number sequence is generated based on a random seed and a random algorithm; the i-th first random number is determined from the random number sequence based on the random number index and the random number sequence. For example, if the generated random number sequence is "1524874" based on the random seed and random algorithm, and if i = 3, the third first random number determined from this random number sequence is 2.
[0057] In some embodiments, the random algorithm is an iterative algorithm. Then, based on the random seed, the random algorithm, and the random number index, the i-th first random number is determined. For example, based on the random seed and the random algorithm, the first first random number is determined to be 2; based on the first first random number and the random algorithm, the second first random number is determined to be 8; based on the second first random number and the random algorithm, the third first random number is determined to be 0.
[0058] Step 204: Execute the front-end display action of the random event based on the i-th first random number.
[0059] Alternatively, a random event is an event in the game that has a probability of occurring.
[0060] For example, a random event is a random critical hit event. A random critical hit event refers to an increase in the damage dealt by a virtual character's attack. For example, if a virtual character's single attack deals 100 points of damage, after a random critical hit event occurs, the virtual character's single attack will deal 150 points of damage. In some embodiments, a random critical hit event refers to a virtual character's attack dealing 2x or 1.5x damage.
[0061] For example, a random event is a random item drop event. A random item drop event refers to a virtual character randomly obtaining a virtual item after completing a task. For example, after defeating an enemy character, the virtual character can randomly obtain a virtual item, where the enemy character is a character from a different faction than the virtual character, or the enemy character and the virtual character are in competition. In some embodiments, virtual items have an item rarity, and the item rarity is negatively correlated with the drop probability; that is, the higher the item rarity, the lower the drop probability. For example, item rarity includes, but is not limited to, at least one of common, rare, fine, epic, and legendary. In other embodiments, item rarity is represented by color, for example, using at least one of white, blue, green, purple, and orange to represent item rarity.
[0062] For example, a random event is an attack effect random event. An attack effect random event refers to a virtual character randomly displaying different attack effects when attacking. For example, attack effects include, but are not limited to, at least one of the following: flying sword effects, bleeding effects, snowflake effects, light effects, shattering effects, and splashing effects. When attacking, the virtual character will randomly display one of the aforementioned attack effects.
[0063] For example, a random event is a character draw event. A character draw event refers to a user account randomly obtaining a virtual character by paying for virtual resources. For example, the game store launches a "Character Draw" event, where players can pay 6000 gold coins for one draw, and a single draw can randomly obtain one of the following characters: character A, character B, or character C.
[0064] Optionally, the foreground display action is used to display the foreground display effect of random events, and the foreground display effect includes at least one of visual effects, sound effects, and vibration feedback.
[0065] For example, in the case of a random critical hit event, the foreground display action is used to show the critical hit effect. For instance, after a critical hit event is determined to have occurred, the visual effect of the critical hit is displayed on the client's display interface, along with the sound effect of the critical hit.
[0066] For example, when the random event is a random item drop event, the foreground display action is used to display the rarity effect corresponding to the item's rarity. For instance, if the item's rarity is Rare, the rarity effect is to emit a blue glow, and the foreground display action is used to display the blue glow around the item; if the item's rarity is Legendary, the rarity effect is to emit an orange glow and play a sound effect, and the foreground display action is used to display the orange glow around the item and play a sound effect.
[0067] Step 206: Send the i-th first random number and the random number sequence number to the server.
[0068] Optionally, the client also sends a client identifier to the server, which is used to uniquely identify the client. In some embodiments, the client identifier is a sequence of IDs (Identity Documents) for a user account.
[0069] In some embodiments, the client sends at least two first random numbers and / or random number sequences to the server. The client may send the at least two first random numbers to the server sequentially, or the client may send the at least two first random numbers to the server all at once. For example, the client sends random number 1, random number 2, and random number 3 to the server sequentially, or the client sends random number 1, random number 2, and random number 3 to the server all at once.
[0070] Step 208: Based on the confirmation message returned by the server, perform background calculations for random events.
[0071] The confirmation message is sent by the server when the i-th second random number matches the i-th first random number. The i-th second random number is generated by the server based on the random seed and the random number sequence number.
[0072] Optionally, background calculation actions are used to generate the calculation results of random events.
[0073] For example, in the case of a random critical hit event, the background calculation action is used to determine the damage value generated by the critical hit event. For instance, the client first displays the critical hit effect of the critical hit event based on the i-th first random number, and after receiving a confirmation message from the server, the client determines the damage value generated by the critical hit event based on the confirmation message.
[0074] For example, when the random event is a random item drop event, the background calculation action is used to determine the type of virtual item corresponding to the item drop event. For instance, the client first determines the item rarity of the virtual item corresponding to the item drop event based on the i-th first random number, and then, after receiving the confirmation message returned by the server, the client determines the type of virtual item corresponding to the item drop event based on the confirmation message.
[0075] For example, when the random event is an attack effect random event, the background calculation action is used to determine the damage value generated by the attack effect event. For instance, the client first displays the attack effect of the attack effect event based on the i-th first random number, and after receiving the confirmation message returned by the server, the client determines the damage value generated by the attack effect event based on the confirmation message.
[0076] It should be noted that in some cases, the actions performed by the user or virtual character are sequential, and the same random event may be repeated multiple times. Optionally, i can be updated to i+1, and the above four steps can be repeated. For example, in the case of a critical hit event, the virtual character may launch multiple attacks on the enemy character. Steps 202 to 208 above can only determine whether a single attack will trigger a critical hit event. Therefore, it is necessary to repeat the above four steps to determine whether a critical hit event is triggered in the case of multiple attacks.
[0077] Correspondingly, in other cases, the actions performed by the user or virtual character are singular, and the random event will only occur once, so there is no need to repeat steps 202 to 208 above.
[0078] In summary, after generating a random number, the client directly executes the foreground display action of the random event based on the random number. Then, based on the confirmation message returned by the server, the client executes the background calculation action of the random event. Therefore, the embodiments of this application can execute the foreground display action in advance, improving the foreground feedback efficiency of random events.
[0079] In the following embodiments, the server verifies the validity of the random numbers generated by the client to prevent the random numbers from being forged by the client, thus ensuring that the game cannot be cheated. Furthermore, foreground display actions related to the random numbers are executed in advance, allowing users to perceive the foreground display actions ahead of time and ensuring timely feedback of game effects.
[0080] Figure 3 This application illustrates a method for generating random numbers according to an embodiment of the present application. This method can be implemented by... Figure 1 The computer system 100 shown executes the method, which includes:
[0081] Step 301: The server generates a random seed.
[0082] Optionally, the random seed is a true random number. For example, the server obtains the random seed based on physical phenomena.
[0083] Step 302: The server and client synchronize the random seed.
[0084] Optionally, the server also synchronizes random number sequences with the client.
[0085] Step 303: The client generates the i-th first random number based on the random seed and the random number sequence number.
[0086] Optionally, the client generates a sequence of random numbers based on a random seed and a random algorithm; the client then determines the i-th first random number from the sequence of random numbers based on the random number index and the random number sequence.
[0087] In some embodiments, the random algorithm is an iterative algorithm. The client then determines the i-th first random number based on the random seed, the random algorithm, and the random number index.
[0088] Step 304: The client sends the i-th first random number and the random number sequence number to the server.
[0089] Optionally, the client also sends a client identifier to the server, which is used to uniquely identify the client. In some embodiments, the client identifier is a sequence of user account IDs.
[0090] In some embodiments, the client sends at least two first random numbers and / or random number sequences to the server. The client may send at least two first random numbers to the server sequentially, or the client may send at least two first random numbers to the server all at once.
[0091] Step 305: The server determines the i-th second random number based on the random seed and the random number sequence number.
[0092] The method by which the server determines the i-th second random number is the same as the method by which the client determines the i-th first random number.
[0093] Optionally, the server generates a sequence of random numbers based on a random seed and a random algorithm; the server then determines the i-th second random number from the sequence of random numbers based on the random number index and the random number sequence.
[0094] In some embodiments, the random algorithm is an iterative algorithm. The server then determines the i-th second random number based on the random seed, the random algorithm, and the random number index.
[0095] Step 306: If the i-th second random number matches the i-th first random number, the server sends a confirmation message to the client.
[0096] Optionally, the confirmation message includes a random number sequence.
[0097] Optionally, at least two first random numbers and at least two second random numbers are matched according to the random number sequence to obtain at least two matching results; if at least two matching results are successful, the server sends an acknowledgment message to the client. For example, the first random numbers include random number 1, random number 2, random number 3, and random number 4, and the second random numbers include random number 1', random number 2', random number 3', and random number 4'. When random number 1 and random number 1' are the same, and random number 2 and random number 2' are the same, and random number 3 and random number 3' are the same, and random number 4 and random number 4' are the same, the server sends an acknowledgment message to the client.
[0098] Step 307: The client performs background calculations for random events based on the confirmation message returned by the server.
[0099] Optionally, the client generates the (i+1)th first random number based on the random seed and random number sequence number, according to the confirmation message returned by the server.
[0100] In summary, after generating a random number, the client directly executes the foreground display action of the random event based on the random number. Then, based on the confirmation message returned by the server, the client executes the background calculation action of the random event. Therefore, the embodiments of this application can execute the foreground display action in advance, improving the foreground feedback efficiency of random events.
[0101] In the following embodiments, there may be a mismatch between the first random number generated by the client and the second random number generated by the server. In this case, the first random number needs to be corrected in a timely manner to avoid other problems in the subsequent calculation of the first random number.
[0102] Figure 4 This application illustrates a method for generating random numbers according to an embodiment of the present application. This method can be implemented by... Figure 1 The computer system 100 shown executes the method, which includes:
[0103] Step 301: The server generates a random seed.
[0104] Step 302: The server and client synchronize the random seed.
[0105] Step 303: The client generates the i-th first random number based on the random seed and the random number sequence number.
[0106] Step 304: The client sends the i-th first random number and the random number sequence number to the server.
[0107] Step 305: The server determines the i-th second random number based on the random seed and the random number sequence number.
[0108] For details on steps 301 to 305, please refer to [link / reference]. Figure 3 Steps 301 to 305 in the illustrated embodiment will not be repeated here.
[0109] Step 401: If the i-th second random number does not match the i-th first random number, the server performs a freeze operation.
[0110] Optionally, the freeze operation is used to interrupt the step of determining the i-th second random number based on the random seed and random number index. Since a mismatch between the i-th second random number and the i-th first random number indicates an error in the client's calculation of the i-th first random number, performing the freeze operation here means that subsequent calculations of the first random number will also be incorrect if the i-th first random number has already failed. Therefore, the server does not need to continue calculating the second random number, which can appropriately reduce the server's computational burden. Furthermore, if the server does not perform the freeze operation, it will cause an accumulation of second random numbers, subsequent synchronization completion messages, and subsequent synchronization instructions within the server, making the server prone to other errors.
[0111] In some embodiments, the i-th second random number not matching the i-th first random number means that the i-th second random number is different from the i-th first random number.
[0112] Step 402: The server sends a synchronization command to the client.
[0113] Optionally, the synchronization instruction includes a random number sequence number and the i-th second random number.
[0114] Step 403: The client synchronizes the i-th first random number to the i-th second random number according to the synchronization instruction.
[0115] The synchronization completion message is used to notify the server that the client has completed the synchronization of the i-th first random number. Optionally, the synchronization completion message includes the synchronized i-th first random number and the random number index.
[0116] Step 404: The client sends a synchronization completion message to the server.
[0117] The synchronization completion message is used to notify the server that the client has completed the synchronization of the i-th first random number. Optionally, the synchronization completion message includes the synchronized i-th first random number and the random number index.
[0118] Step 405: The server unfreezes the operation based on the synchronization completion message sent by the client.
[0119] Optionally, if the i-th first random number after synchronization matches the i-th second random number, the freeze operation is lifted.
[0120] In summary, after generating a random number, the client will directly execute the foreground display action of the random event based on the random number. If the server detects a mismatch between the first and second random numbers, the server will send a synchronization command to the client to synchronize the random numbers on the client and server, ensuring that the random number generation process on both the client and server is normal and accurate.
[0121] Figure 5 This application illustrates a method for generating random numbers according to an embodiment of the present application. This method can be implemented by... Figure 1 The server 140 shown executes a method that includes:
[0122] Step 502: Receive the i-th first random number and random number index i sent by the client. The i-th first random number is generated by the client based on the random seed and random number index. The random seed is synchronized to the client by the server. The i-th first random number is used by the client to perform the front-end display action of the random event. i is a positive integer.
[0123] Alternatively, a random event is an event in the game that has a probability of occurring.
[0124] For example, a random event is a random critical hit event. A random critical hit event refers to an increased damage output from a virtual character's attack. For example, a random event is a random item drop event. A random item drop event refers to a virtual character randomly obtaining virtual items after completing a task. For example, a random event is an attack effect random event. An attack effect random event refers to a virtual character randomly displaying different attack effects when attacking. For example, a random event is a character draw event. A character draw event refers to a user account paying virtual resources to randomly obtain a virtual character.
[0125] Optionally, the foreground display action is used to display the foreground display effect of random events, and the foreground display effect includes at least one of visual effects, sound effects, and vibration feedback.
[0126] Step 504: Determine the i-th second random number based on the random seed and the random number sequence number.
[0127] Optionally, a random number sequence is generated based on a random seed and a random algorithm; the i-th second random number is determined from the random number sequence based on the random number index and the random number sequence.
[0128] In some embodiments, the random algorithm is an iterative algorithm. Then, based on the random seed, the random algorithm, and the random number index, the i-th second random number is determined.
[0129] Step 506: If the i-th second random number matches the i-th first random number, send an acknowledgment message to the client. The acknowledgment message is used by the client to perform background calculations for the random event.
[0130] Optionally, background calculation actions are used to generate the calculation results of random events.
[0131] Optionally, if the i-th second random number does not match the i-th first random number, a synchronization instruction is sent to the client. The synchronization instruction includes the random number sequence number and the i-th second random number. The synchronization instruction is used to instruct the client to synchronize the i-th first random number to the i-th second random number.
[0132] Optionally, based on the synchronization completion message sent by the client, an unfreeze command is sent to the client, which instructs the client to unfreeze.
[0133] In summary, after generating a random number, the client directly executes the foreground display action of the random event based on the random number. Then, based on the confirmation message returned by the server, the client executes the background calculation action of the random event. Therefore, the embodiments of this application can execute the foreground display action in advance, improving the foreground feedback efficiency of random events.
[0134] In the following embodiments, the random event is a random critical hit event, which is used to determine whether the virtual character's attack will result in a critical hit. After the client generates a first random number, it sends the first random number to the server for verification.
[0135] Figure 6 A flowchart of a critical hit determination method provided in an embodiment of this application is shown. This method can be... Figure 1 The client 120 shown executes a method that includes:
[0136] Step 601: In response to the attack operation on the virtual character, generate the i-th first random number based on the random seed and the random number index i.
[0137] Offensive actions are used to control a virtual character to launch attacks against other virtual characters in the virtual environment.
[0138] An offensive action can be initiated by pressing one or more preset physical buttons, or by executing an offensive action through signals generated by long-pressing, clicking, double-clicking, and / or swiping on a designated area of the touchscreen, or by an object performing a specific action or by inputting a specific voice.
[0139] Step 602: Determine whether the i-th first random number is greater than the critical hit threshold.
[0140] If the i-th first random number is less than the critical hit threshold, then proceed to step 603;
[0141] If the i-th first random number is greater than the critical hit threshold, then proceed to step 604.
[0142] Optionally, the critical strike threshold is determined based on the attribute values of the virtual character. Optionally, the attribute values include, but are not limited to, at least one of critical strike rate, health, mana, movement speed, and coldness. For example, if the virtual character's critical strike rate is 20% and the value range of the first random number is [0, 1], then the critical strike threshold is set to 0.2. When the value of the first random number is less than 0.2, it is determined that the virtual character's attack will result in a critical strike.
[0143] Optionally, the critical hit threshold is determined based on the virtual character's state. For example, the virtual character's state includes an awakened state and a normal state. In the awakened state, every attack by the virtual character will inevitably result in a critical hit, while in the normal state, every attack by the virtual character has a 20% probability of resulting in a critical hit. Therefore, when the value range of the first random number is [0, 1], the critical hit threshold can be set to 0 in the awakened state and 0.2 in the normal state.
[0144] Step 603: Display the critical hit effect of the random event.
[0145] For example, critical hit effects include, but are not limited to, at least one of the following: large text effects, splash effects, blood splatter effects, sound feedback, and vibration feedback.
[0146] Step 604: Display non-critical hit effects for random events.
[0147] Critical hit effects and non-critical hit effects are two different types of effects. For example, when a critical hit occurs, the word "Critical Hit" will be displayed on the game interface. When a critical hit does not occur, the word "Critical Hit" will not be displayed on the game interface.
[0148] Step 605: Send the i-th first random number and the random number sequence number to the server.
[0149] Optionally, the client also sends a client identifier to the server, which is used to uniquely identify the client. In some embodiments, the client identifier is a sequence of user account IDs.
[0150] Step 606: Calculate the critical hit value of the random event based on the confirmation message returned by the server.
[0151] The confirmation message indicates that the i-th first random value calculated by the client is correct.
[0152] Optionally, the critical hit value is determined based on the virtual character's attribute values. In some embodiments, the critical hit value is determined based on the virtual character's critical hit damage increase; for example, the formula for calculating the critical hit value is attack power × (1 + critical hit damage increase).
[0153] It should be noted that in some cases, random critical hit events may repeat multiple times, such as when a virtual character launches multiple attacks on other virtual characters. Therefore, it is necessary to determine multiple times whether a random critical hit event will result in a critical hit. Optionally, update i to i+1 and repeat the above six steps. Correspondingly, in other cases, a random critical hit event will only occur once, such as when a virtual character launches only one attack on another virtual character. Therefore, it is not necessary to repeat steps 601 to 606.
[0154] In summary, this application provides a method for determining whether a virtual character has received a critical hit. This method can pre-display critical hit effects and provide real-time feedback to the player, ensuring a smooth gaming experience. Simultaneously, the server can verify the validity of the random number, ensuring the game is not subject to cheating.
[0155] In the following embodiments, the random event is a random item drop event, which is used to determine the rarity of virtual items. After the client generates a first random number, it sends the first random number to the server for verification.
[0156] Figure 7 A flowchart illustrating a method for determining item drop according to an embodiment of this application is shown. This method can be... Figure 1 The client 120 shown executes a method that includes:
[0157] Step 701: In response to the fulfillment of the virtual item drop condition, generate the i-th first random number based on the random seed and random number index i.
[0158] For example, the conditions for obtaining virtual items include, but are not limited to, defeating neutral virtual characters, defeating hostile virtual characters, opening virtual items, completing game tasks, reaching target areas, and consuming virtual resources.
[0159] Step 702: Determine the item rarity corresponding to the random event based on the i-th first random number.
[0160] Optionally, the rarity of the item corresponding to the random event is determined based on the i-th first random number and the first mapping relationship. The first mapping relationship is used to record the correspondence between the first random number and the item rarity. For example, please refer to Table 1:
[0161] Table 1 First Mapping Relationship
[0162] First random number Item rarity 0-60 ordinary 61-90 rare 90-98 epic 98-99 legend
[0163] Step 703: Display the rarity effect corresponding to the item's rarity.
[0164] Optionally, rarity effects are determined based on item rarity and a second mapping relationship, whereby the second mapping relationship records the correspondence between item rarity and rarity effects. For example, please refer to Table 2:
[0165] Table 2 Second Mapping Relationship
[0166]
[0167]
[0168] Step 704: Send the i-th first random number and the random number sequence number to the server.
[0169] Optionally, the client also sends a client identifier to the server, which is used to uniquely identify the client. In some embodiments, the client identifier is a sequence of user account IDs.
[0170] Step 705: Based on the confirmation message returned by the server, determine the virtual item corresponding to the random event.
[0171] Optionally, the confirmation message includes a virtual item belonging to the item rarity determined above. For example, virtual items of epic rarity include virtual item 1, virtual item 2, and virtual item 3, and the client determines that the virtual item obtained is virtual item 2 based on the confirmation message.
[0172] It should be noted that in some cases, random item drop events may repeat multiple times; for example, a random item drop event may drop multiple virtual items. Therefore, it is necessary to determine the rarity of the virtual items dropped by the random item drop event multiple times. Optionally, update i to i+1 and repeat the above five steps. Correspondingly, in other cases, a random item drop event may only occur once; for example, a random item drop event may drop only one virtual item. Therefore, it is not necessary to repeat steps 701 to 705 above.
[0173] In summary, this application provides a method for determining the rarity of virtual items. This method can pre-display rarity effects and provide real-time feedback to players, ensuring a consistent and responsive gaming experience. Simultaneously, the server can verify the validity of random numbers, guaranteeing the game's anti-cheating capabilities.
[0174] In the following embodiments, the random event is an attack effect random event, which is used for the attack effects of the virtual character. After the client generates the first random number, it sends the first random number to the server for verification.
[0175] Figure 8 A flowchart illustrating a method for determining attack effects according to an embodiment of this application is shown. This method can be... Figure 1 The client 120 shown executes a method that includes:
[0176] Step 801: In response to the attack operation on the virtual character, generate the i-th first random number based on the random seed and the random number index i.
[0177] Offensive actions are used to control a virtual character to launch attacks against other virtual characters in the virtual environment.
[0178] An offensive action can be initiated by pressing one or more preset physical buttons, or by executing an offensive action through signals generated by long-pressing, clicking, double-clicking, and / or swiping on a designated area of the touchscreen, or by an object performing a specific action or by inputting a specific voice.
[0179] Step 802: Determine the attack effect corresponding to the random event based on the i-th first random number.
[0180] In some embodiments, each time a virtual character attacks, it randomly selects one attack effect from multiple candidate attack effects to display.
[0181] Optionally, the rarity of the item corresponding to the random event is determined based on the i-th first random number and the third mapping relationship. The third mapping relationship is used to record the correspondence between the first random number and the attack effect. For example, please refer to Table 3:
[0182] Table 3 Third Mapping Relationship
[0183] First random number Attack effects 0-29 Water flow effects 30-59 Flame effects 60-89 Lightning effects 90-99 Flying sword effects
[0184] Step 803: Display attack effects.
[0185] Step 804: Send the i-th first random number and the random number sequence number to the server.
[0186] Optionally, the client also sends a client identifier to the server, which is used to uniquely identify the client. In some embodiments, the client identifier is a sequence of user account IDs.
[0187] Step 805: Determine the damage value of the random event based on the confirmation message returned by the server.
[0188] In some embodiments, attack effects can affect the damage dealt by an attack. For example, referring to Table 3, displaying a flying sword effect will cause the virtual character to take twice the damage of their attack. Displaying a fire effect will cause the virtual character to take 1.5 times the damage of their attack.
[0189] It should be noted that step 805 can be either an optional step or a mandatory step.
[0190] It should be noted that in some cases, random attack effect events may repeat multiple times, such as when a virtual character launches multiple attacks. Therefore, it is necessary to determine the attack effect corresponding to the random attack effect event multiple times. Optionally, update i to i+1 and repeat the above five steps. Correspondingly, in other cases, random attack effect events may only occur once, such as when a virtual character launches only one attack. Therefore, it is not necessary to repeat steps 801 to 805.
[0191] In summary, this application provides a method for determining the attack effects of a virtual character. This method can pre-display the attack effects and provide real-time feedback to the player, ensuring a smooth gaming experience. Simultaneously, the server can verify the validity of random numbers, ensuring the game is not subject to cheating.
[0192] The following are device embodiments of this application. For details not described in detail in the device embodiments, please refer to the corresponding descriptions in the above method embodiments. They will not be repeated here.
[0193] Figure 9 A schematic diagram of a random number generation apparatus provided in an exemplary embodiment of this application is shown. This apparatus can be implemented as all or part of a computer device through software, hardware, or a combination of both. The apparatus 900 includes:
[0194] The first calculation module 901 is used to generate the i-th first random number based on the random seed and the random number index i, wherein the random seed is synchronized from the server to the client and i is a positive integer;
[0195] Display module 902 is used to perform a front-end display action of a random event based on the i-th first random number;
[0196] The first interaction module 903 is used to send the i-th first random number and the random number sequence number to the server;
[0197] The first calculation module 901 is further configured to perform background calculation actions for the random event based on the confirmation message returned by the server;
[0198] The confirmation information is sent by the server when the i-th second random number matches the i-th first random number, and the i-th second random number is generated by the server based on the random seed and the random number sequence number.
[0199] In an optional design, the first interaction module 903 is further configured to receive a synchronization instruction returned by the server, the synchronization instruction being sent by the server when the i-th second random number does not match the i-th first random number, the synchronization instruction including the random number sequence number and the i-th second random number; the first calculation module 901 is further configured to synchronize the i-th first random number to the i-th second random number according to the synchronization instruction.
[0200] In an optional design, the first interaction module 903 is further configured to send a synchronization completion message to the server, the synchronization completion message being used to instruct the client to complete the synchronization of the i-th first random number.
[0201] In an optional design, the first calculation module 901 is further configured to generate a random number sequence based on the random seed and the random algorithm; and to determine the i-th first random number from the random number sequence based on the random number index and the random number sequence.
[0202] In an optional design, the random event is a random critical hit event; the display module 902 is further configured to display the critical hit effect of the random critical hit event when the i-th first random number is less than the critical hit threshold; or, when the i-th first random number is greater than the critical hit threshold, display the non-critical hit effect of the random critical hit event.
[0203] In an optional design, the random event is a random item drop event; the display module 902 is further configured to determine the item rarity corresponding to the random item drop event based on the i-th first random number; and display the rarity effect corresponding to the item rarity.
[0204] In an optional design, the random event is an attack effect random event; the display module 902 is further configured to determine the attack effect corresponding to the attack effect random event based on the i-th first random number; and display the attack effect.
[0205] In summary, after generating a random number, the front-end display action of the random event is executed directly based on the random number, and then the background calculation action of the random event is executed based on the confirmation message returned by the server. Therefore, the embodiments of this application can execute the front-end display action in advance, improving the front-end feedback efficiency of random events.
[0206] Figure 10A schematic diagram of a random number generation apparatus provided in an exemplary embodiment of this application is shown. This apparatus can be implemented as all or part of a computer device through software, hardware, or a combination of both. The apparatus 1000 includes:
[0207] The second interaction module 1001 is used to receive the i-th first random number and the random number sequence number i sent by the client. The i-th first random number is generated by the client based on the random seed and the random number sequence number. The random seed is synchronized to the client by the server. The i-th first random number is used by the client to perform a front-end display action of a random event. i is a positive integer.
[0208] The second calculation module 1002 is used to determine the i-th second random number based on the random seed and the random number sequence number;
[0209] The second interaction module 1001 is further configured to send a confirmation message to the client when the i-th second random number matches the i-th first random number, and the confirmation message is used by the client to perform background calculation of the random event.
[0210] In an optional design, the second interaction module 1001 is further configured to perform a freeze operation if the i-th second random number does not match the i-th first random number, wherein the freeze operation is used to interrupt the step of determining the i-th second random number based on the random seed and the random number index; and to send a synchronization instruction to the client, wherein the synchronization instruction includes the random number index and the i-th second random number, and the synchronization instruction is used to instruct the client to synchronize the i-th first random number to the i-th second random number.
[0211] In an optional design, the second interaction module 1001 is further configured to release the freeze operation based on the synchronization completion message sent by the client.
[0212] In summary, after generating a random number, the front-end display action of the random event is executed directly based on the random number, and then the background calculation action of the random event is executed based on the confirmation message returned by the server. Therefore, the embodiments of this application can execute the front-end display action in advance, improving the front-end feedback efficiency of random events.
[0213] Figure 11This is a schematic diagram illustrating the structure of a computer device according to an exemplary embodiment. The computer device 1100 includes a Central Processing Unit (CPU) 1101, a system memory 1104 including Random Access Memory (RAM) 1102 and Read-Only Memory (ROM) 1103, and a system bus 1105 connecting the system memory 1104 and the CPU 1101. The computer device 1100 also includes a basic input / output system (I / O system) 1106 to facilitate information transfer between various devices within the computer device, and a mass storage device 1107 for storing an operating system 1113, application programs 1114, and other program modules 1115.
[0214] The basic input / output system 1106 includes a display 1108 for displaying information and an input device 1109 for user input, such as a mouse or keyboard. Both the display 1108 and the input device 1109 are connected to the central processing unit 1101 via an input / output controller 1110 connected to the system bus 1105. The basic input / output system 1106 may also include the input / output controller 1110 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1110 also provides output to a display screen, printer, or other types of output devices.
[0215] The mass storage device 1107 is connected to the central processing unit 1101 via a mass storage controller (not shown) connected to the system bus 1105. The mass storage device 1107 and its associated computer device-readable media provide non-volatile storage for the computer device 1100. That is, the mass storage device 1107 may include computer device-readable media (not shown), such as a hard disk or a compact disc read-only memory (CD-ROM) drive.
[0216] Without loss of generality, the computer device readable medium may include computer device storage media and communication media. Computer device storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer device readable instructions, data structures, program modules, or other data. Computer device storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), CD-ROM, digital video disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer device storage media are not limited to the above-mentioned types. The system memory 1104 and mass storage device 1107 described above can be collectively referred to as memory.
[0217] According to various embodiments of this disclosure, the computer device 1100 can also be connected to a remote computer device on a network, such as the Internet. That is, the computer device 1100 can be connected to the network 1111 via a network interface unit 1112 connected to the system bus 1105, or the network interface unit 1112 can be used to connect to other types of networks or remote computer device systems (not shown).
[0218] The memory also includes one or more programs stored in the memory, and the central processing unit 1101 executes the one or more programs to implement all or part of the steps of the above-mentioned random number generation method.
[0219] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the random number generation method provided in the above-described method embodiments.
[0220] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the random number generation method provided in the above method embodiments.
[0221] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the random number generation method provided in the above embodiments.
[0222] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0223] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0224] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for generating random numbers, characterized in that, The method is executed by the client, and the method includes: The first random number is generated based on a random seed and a random number index i. The random seed is synchronized from the server to the client, and i is a positive integer. The front-end display action of the random event is executed based on the i-th first random number; Send the i-th first random number and the random number sequence number to the server; Based on the confirmation message returned by the server, the background calculation action of the random event is executed; wherein, the confirmation message is sent by the server when the i-th second random number matches the i-th first random number, and the i-th second random number is generated by the server based on the random seed and the random number sequence number; The system receives a synchronization instruction returned by the server. The synchronization instruction is sent by the server when the i-th second random number does not match the i-th first random number. The synchronization instruction includes the random number sequence number and the i-th second random number. According to the synchronization instruction, the i-th first random number is synchronized to the i-th second random number; A synchronization completion message is sent to the server, which instructs the client to complete the synchronization of the i-th first random number.
2. The method according to claim 1, characterized in that, The step of generating the i-th first random number based on the random seed and the random number index i includes: Generate a random number sequence based on the random seed and random algorithm; Based on the random number sequence and the random number sequence, the i-th first random number is determined from the random number sequence.
3. The method according to claim 1, characterized in that, The random event is a random critical hit event; The front-end display action of executing a random event based on the i-th first random number includes: If the i-th first random number is less than the critical hit threshold, display the critical hit effect of the random critical hit event; or, If the i-th first random number is greater than the critical hit threshold, the non-critical hit effect of the random critical hit event is displayed.
4. The method according to claim 1, characterized in that, The random event is a random item drop event; The front-end display action of executing a random event based on the i-th first random number includes: The item rarity corresponding to the random item drop event is determined based on the i-th first random number. Displays rarity effects corresponding to the rarity of the item.
5. A method for generating random numbers, characterized in that, The method is executed by the server, and the method includes: The client receives the i-th first random number and the random number index i. The i-th first random number is generated by the client based on the random seed and the random number index. The random seed is synchronized to the client by the server. The i-th first random number is used by the client to perform a front-end display action of a random event. i is a positive integer. The i-th second random number is determined based on the random seed and the random number index; If the i-th second random number matches the i-th first random number, a confirmation message is sent to the client. The confirmation message is used by the client to perform background calculations for the random event. If the i-th second random number does not match the i-th first random number, a freeze operation is performed. The freeze operation is used to interrupt the step of determining the i-th second random number based on the random seed and the random number index. A synchronization instruction is sent to the client. The synchronization instruction includes the random number sequence number and the i-th second random number. The synchronization instruction is used to instruct the client to synchronize the i-th first random number to the i-th second random number.
6. A random number generation device, characterized in that, The device includes: The first calculation module is used to generate the i-th first random number based on the random seed and the random number index i. The random seed is synchronized from the server to the client, and i is a positive integer. The display module is used to perform a front-end display action of a random event based on the i-th first random number; The first interaction module is used to send the i-th first random number and the random number sequence number to the server; The first calculation module is further configured to perform background calculation of the random event based on the confirmation message returned by the server; wherein the confirmation message is sent by the server when the i-th second random number matches the i-th first random number, and the i-th second random number is generated by the server based on the random seed and the random number sequence number; The first interaction module is further configured to receive a synchronization instruction returned by the server, wherein the synchronization instruction is sent by the server when the i-th second random number does not match the i-th first random number, and the synchronization instruction includes the random number sequence number and the i-th second random number; The first calculation module is further configured to synchronize the i-th first random number to the i-th second random number according to the synchronization instruction; The first interaction module is further configured to send a synchronization completion message to the server, the synchronization completion message being used to instruct the client to complete the synchronization of the i-th first random number.
7. A random number generation device, characterized in that, The device includes: The second interaction module is used to receive the i-th first random number and the random number index i sent by the client. The i-th first random number is generated by the client based on the random seed and the random number index. The random seed is synchronized to the client by the server. The i-th first random number is used by the client to perform a front-end display action of a random event. i is a positive integer. The second calculation module is used to determine the i-th second random number based on the random seed and the random number index; The second interaction module is further configured to send a confirmation message to the client when the i-th second random number matches the i-th first random number, and the confirmation message is used by the client to perform background calculation of the random event; The second interaction module is further configured to perform a freeze operation if the i-th second random number does not match the i-th first random number, wherein the freeze operation is used to interrupt the step of determining the i-th second random number based on the random seed and the random number sequence number; The second interaction module is further configured to send a synchronization instruction to the client. The synchronization instruction includes the random number sequence number and the i-th second random number. The synchronization instruction is used to instruct the client to synchronize the i-th first random number to the i-th second random number.
8. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one program, the at least one program being loaded and executed by the processor to implement the random number generation method as described in any one of claims 1 to 4, or the random number generation method as described in claim 5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the method for generating random numbers as described in any one of claims 1 to 4, or the method for generating random numbers as described in claim 5.
Citation Information
Patent Citations
User identity authentication processing method, application server and authentication system server
CN108259436A
Pseudo-random number acquisition method and device, client equipment and server
CN110069241A
