A method, system, terminal device and server for determining random results in a game
By calculating random numbers on the terminal device, using the received initial random seed and timestamp difference value, the server computing pressure caused by a large number of random events in multiplayer online games is solved, and efficient random result determination is achieved.
Patent Information
- Application Number
- CN202210653927.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-06-09
AI Technical Summary
In multiplayer online games, when a large number of random events occur, the prior art requires generating random seeds on the server and calculating random numbers, resulting in high pressure on the server to operate.
By receiving the time stamp of the initial random seed sent by the server and the server time on the terminal device, the timestamp difference value is calculated, and the random number is calculated based on the initial random seed, the timestamp difference value and the current timestamp of the terminal device, the random result is directly determined.
When a large number of random events occur, the computing pressure of the server is reduced and the delay in waiting for the server to send random numbers is avoided.
Smart Images

Figure CN114917591B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of human-computer interaction technology. Specifically, it relates to a method, system, terminal device, server, electronic device, and storage medium for determining random results in a game. Background Art
[0002] In a multiplayer online game, when the same random event needs to display the same random result on different terminal devices, the same random number needs to be obtained on different terminal devices to obtain the same random result based on the same random number. For example, some natural phenomena randomness, offline rendering, random generation of game content, etc. in the game need to display the same random result on different terminal devices.
[0003] Currently, the way to obtain the same random result is to generate a random number on the server and then send the generated random number to different terminal devices so that different terminal devices can obtain the same random result when presenting random events.
[0004] However, when using the above method for determining random results, it is necessary to generate a random seed on the server and calculate the random number based on the generated random seed, which will increase the computing pressure on the server when a large number of random events occur. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a method, system, terminal device, server, electronic device, and storage medium for determining random results in a game, so as to at least solve the problem of high computing pressure on the server when a large number of random events occur.
[0006] In a first aspect, an embodiment of this application provides a method for determining random results in a game, which is applied to a terminal device and includes: receiving an initial random seed sent by the server and a time stamp of the server time; determining the difference between the time stamp of the server time and the time stamp of the first current time of the terminal device as the time stamp difference; in response to a random number generation instruction, calculating a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device; and determining the random result corresponding to the random number.
[0007] Optionally, calculating the random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device includes: performing a summation operation on the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device, and determining the result of the summation operation as the derived random seed; and determining the random number according to the derived random seed.
[0008] Optionally, determining a random number according to a derived random seed includes: using the derived random seed as the dividend, the set delay tolerance value as the divisor, and performing a modulo operation on the dividend and the divisor to determine a modulo value; determining the difference between the derived random seed and the modulo value as the target random seed; and determining a random number according to the target random seed.
[0009] Optionally, determining a random number according to the target random seed includes: calculating the product of the target random seed and a set multiplier; calculating the sum of the product and a set increment; and performing a modulo operation on the sum to obtain a random number.
[0010] Optionally, the random number generation instruction is a random number generation instruction triggered by a user corresponding to the terminal device, or a random number generation instruction sent by the server.
[0011] In a second aspect, an embodiment of the present application further provides a method for determining a random result in a game, which is applied to a server and includes: receiving a random synchronization instruction sent by a first terminal device, and determining the role information of a first controlled virtual object in the first terminal device; determining a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object; and sending a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines a random result corresponding to the random number.
[0012] Optionally, the method further includes: generating an initial random seed and distributing the generated initial random seed to the second terminal device; distributing a time stamp of the server time to the second terminal device at fixed time intervals; and sending a random number generation instruction to the second terminal device, so that the second terminal device generates a random number, including: sending a random number generation instruction to the second terminal device, so that the second terminal device generates a random number according to the initial random seed and the time stamp of the server time.
[0013] Optionally, the method further includes: sending a random number generation instruction to the first terminal device, so that the first terminal device generates a random number and determines a random result corresponding to the random number.
[0014] In a third aspect, an embodiment of the present application further provides a random result determination system in a game. The system includes: a first terminal device, a second terminal device, and a server; the first terminal device is configured to, in response to a random number generation instruction, send a random synchronization instruction to the server, calculate a random number according to an initial random seed, a timestamp difference, and a timestamp of a second current time of the first terminal device, and determine a random result corresponding to the random number; the server is configured to receive the random synchronization instruction sent by the first terminal device, determine role information of a first controlled virtual object in the first terminal device, determine a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object, and send a random number generation instruction to the second terminal device; the second terminal device is configured to receive the random number generation instruction sent by the server, calculate a random number according to the initial random seed, the timestamp difference, and a timestamp of a second current time of the second terminal device, and determine a random result corresponding to the random number.
[0015] In a fourth aspect, an embodiment of the present application further provides a terminal device, including: a receiving module, configured to receive an initial random seed sent by the server and a timestamp of the server system time; a difference calculation module, configured to determine a timestamp difference by taking a difference between the timestamp of the server system time and a timestamp of a first current time of the terminal device; a random number calculation module, configured to, in response to a random number generation instruction, calculate a random number according to the initial random seed, the timestamp difference, and a timestamp of a second current time of the terminal device; a determination module, configured to determine a random result corresponding to the random number.
[0016] In a fifth aspect, an embodiment of the present application further provides a server, including: a receiving module, configured to receive the random synchronization instruction sent by the first terminal device and determine role information of a first controlled virtual object in the first terminal device; a calculation module, configured to determine a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object; a sending module, configured to send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines a random result corresponding to the random number.
[0017] In a sixth aspect, an embodiment of the present application further provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the memory through the bus. When the machine-readable instructions are executed by the processor, the steps of the above-mentioned random result determination method in the game are executed.
[0018] In a seventh aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of the above-mentioned random result determination method in the game are executed.
[0019] The embodiments of the present application bring the following beneficial effects:
[0020] A method, system, terminal device and server for determining random results in a game provided by the embodiments of the present application. In the prior art, a terminal device sends a random instruction to a server, and the server generates a random seed according to the random instruction. After calculating a random number based on the random seed, the server distributes the random number to different terminal devices so that the terminal devices present the random results corresponding to the random numbers. However, in the present application, the server first sends the random seed and the server time to the terminal device. When a random event occurs, the terminal device calculates a random number according to the random seed, the time stamp difference, and the current event of the terminal device, and directly determines the random result of the random event according to the obtained random number. When a large number of random events occur, there is no need to calculate random numbers on the server side, nor to wait for the server to send the random numbers to the terminal device. Compared with the method for determining random results in a game in the prior art, the problem of heavy computing pressure on the server when a large number of random events occur is solved.
[0021] In order to make the above objects, features and advantages of the present application more obvious and understandable, the following specific embodiments are given, and in conjunction with the accompanying drawings, the detailed description is as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0023] Figure 1 Shows the flowchart of the method for determining random results in a game provided by the embodiments of the present application applied to a terminal device;
[0024] Figure 2 Shows the flowchart of the method for determining random results in a game provided by the embodiments of the present application applied to a server;
[0025] Figure 3 Shows the schematic diagram of the interaction process between the first terminal device, the second terminal device and the server provided by the embodiments of the present application;
[0026] Figure 4 Shows the schematic diagram of the structure of the system for determining random results in a game provided by the embodiments of the present application;
[0027] Figure 5 Shows the schematic diagram of the structure of the terminal device provided by the embodiments of the present application;
[0028] Figure 6 Shows a schematic structural diagram of the server provided by the embodiments of the present application;
[0029] Figure 7 Shows a schematic structural diagram of the electronic device provided by the embodiments of the present application. Detailed implementation manners
[0030] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Usually, the components of the embodiments of the present application described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, every other embodiment obtained by those skilled in the art without creative efforts belongs to the scope of protection of the present application.
[0031] In this specification, the terms "a", "an", "the", and "said" are used to indicate the existence of one or more elements / components / etc.; the terms "comprising" and "having" are used to mean an open inclusion and mean that there may be additional elements / components / etc. in addition to the listed elements / components / etc.; the terms "first" and "second", etc. are only used as labels and are not a limitation on the quantity of their objects.
[0032] It should be understood that in the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "And / or" is merely a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. These three situations. The character " / " generally means that the associated objects before and after are in an "or" relationship. "Including A, B, and / or C" means including any one or any two or all three of A, B, and C.
[0033] It should be understood that in the embodiments of the present application, "B corresponding to A", "B corresponding to A relatively", "A corresponding to B relatively", or "B corresponding to A relatively" means that B is associated with A, and B can be determined according to A. Determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.
[0034] First, the applicable application scenarios of this application are introduced. This application can be applied to game scenarios. The embodiments of this application do not limit specific application scenarios. Any solution using the random result determination method, system, client, and server provided by the embodiments of this application is within the protection scope of this application.
[0035] It should be noted that before this application was proposed, in a multiplayer online game, when the same random result needed to be displayed on different terminal devices for the same random event, the same random number needed to be obtained on different terminal devices to obtain the same random result based on the same random number. For example, for some natural phenomena randomness, offline rendering, randomly generating game content, etc. in the game, the same random result needed to be displayed on different terminal devices. Currently, the way to obtain the same random result is to generate a random number on the server and then send the generated random number to different terminal devices so that different terminal devices can obtain the same random result when presenting random events. However, when using the above random result determination method, it is necessary to generate a random seed on the server and calculate the random number based on the generated random seed. When a large number of random events occur, it will cause a problem of high computing pressure on the server.
[0036] Based on this, the embodiments of this application provide a method for determining random results in a game to reduce the computing pressure on the server.
[0037] To facilitate those skilled in the art to better understand this application, the following provides a detailed introduction to a method for determining random results in a game, a system, a terminal device, a server, an electronic device, and a storage medium provided by the embodiments of this application.
[0038] Please refer to Figure 1 , which is a flowchart of the method for determining random results in a game provided by the embodiments of this application applied to a terminal device. Specifically, the method for determining random results in a game provided by the embodiments of this application includes:
[0039] S101, receive the initial random seed sent by the server and the timestamp of the server time.
[0040] S102, determine the time difference between the timestamp of the server time and the timestamp of the first current time of the terminal device as the timestamp difference.
[0041] S103, in response to the random number generation instruction, calculate the random number according to the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device.
[0042] S104, determine the random result corresponding to the random number.
[0043] First, the names involved in the embodiments of this application are briefly introduced below.
[0044] Terminal device:
[0045] In the embodiments of the present application, the terminal device mainly refers to an intelligent device that provides a virtual scene for the virtual battle and can perform control operations on the controlled virtual object. The terminal device may include, but is not limited to, any one of the following devices: smart phone, tablet computer, portable computer, desktop computer, game console, personal digital assistant (PDA), e-book reader, (Moving Picture Experts Group Audio Layer IV) player. An application program that supports the virtual scene of the game is installed and run in the terminal device, such as an application program that supports a three-dimensional game scene. The application program may include, but is not limited to, any one of a virtual reality application program, a three-dimensional map program, a military simulation program, a MOBA game, a multiplayer shooting survival game, a third-person shooting game (TPS). Optionally, the application program may be a stand-alone application program, such as a stand-alone 3D game program, or a network online version of the application program.
[0046] Graphical user interface:
[0047] It is an interface display format for human-computer communication that allows users to manipulate icons, identifiers, or menu options on the screen using input devices such as a mouse or keyboard, and also allows users to manipulate icons or menu options on the screen by performing touch operations on the touch screen of a touch terminal to select commands, start programs, or perform other tasks, etc.
[0048] Virtual scene:
[0049] It is a virtual scene displayed (or provided) when an application runs on a terminal device or a server, that is, a scene used during the normal gameplay of a game. That is to say, a virtual scene refers to the virtual game controls that carry virtual objects during the game process. The virtual objects can perform actions such as moving and skill releasing according to the operation instructions issued by the user (i.e., the player) to the terminal device in the virtual scene. Optionally, the virtual scene can be a simulation environment of the real world, a semi-simulated and semi-fictional virtual environment, or a purely fictional virtual environment. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5-dimensional virtual scene, and a three-dimensional virtual scene. The virtual environment can be the sky, land, ocean, etc., where the land includes environmental elements such as deserts and cities. Among them, the virtual scene is a scene for the user to control the complete game logic of the virtual object. Optionally, the virtual scene can also be used for virtual environment battles between at least two virtual objects, and there are virtual resources available for at least two virtual objects in this virtual scene. Exemplarily, the virtual scene can include any one or more of the following elements: game background elements, game virtual character elements, game prop elements, etc.
[0050] Virtual object:
[0051] It refers to the controlled virtual objects and uncontrolled virtual objects in the virtual environment. The controlled virtual objects can be virtual characters manipulated by players, including but not limited to at least one of virtual humans, virtual animals, and anime characters. The uncontrolled virtual objects can be non-player-controlled virtual characters (NPCs), or can also be virtual objects, referring to static objects in the virtual scene. For example, virtual props, virtual tasks, a location in the virtual environment, terrain, houses, bridges, vegetation, etc. in the virtual scene. Static objects are often not directly controlled by players, but can respond to the interaction behaviors (such as attacks, demolitions, etc.) of virtual objects in the virtual scene and make corresponding manifestations. For example: virtual objects can demolish, pick up, drag, build, etc. buildings. Optionally, virtual objects can also not respond to the interaction behaviors of virtual objects. For example, virtual objects can also be buildings, doors, windows, plants, etc. in the virtual scene, but virtual objects cannot interact with them. For example, virtual objects cannot damage or demolish windows, etc. Optionally, when the virtual scene is a three-dimensional virtual environment, the virtual character can be a three-dimensional virtual model. Each virtual character has its own shape and volume in the three-dimensional virtual environment and occupies a part of the space in the three-dimensional virtual environment. Optionally, the virtual character is a three-dimensional character constructed based on three-dimensional human skeleton technology, and the virtual character realizes different external images by wearing different skins. In some implementation manners, the virtual character can also be implemented using a 2.5-dimensional or 2-dimensional model, and the embodiments of the present application do not limit this.
[0052] In a virtual scene, there can be multiple controlled virtual objects. The controlled virtual object can be a virtual character controlled by a player (i.e., a character controlled by the player through an input device), or an artificial intelligence (AI) set in a virtual environment battle through training. Optionally, the controlled virtual object is a virtual character competing in the virtual scene. Optionally, the number of controlled virtual objects in the virtual scene battle is preset, or dynamically determined according to the number of terminal devices joining the virtual battle. This application embodiment does not limit this. In a possible implementation, the user can control the controlled virtual object to move in the virtual scene. For example, control the controlled virtual object to run, jump, crawl, etc., and can also control the controlled virtual object to use skills, virtual props, etc. provided by the application to fight with other controlled virtual objects.
[0053] In an optional embodiment, the terminal device can be a local terminal device. Taking a game as an example, the local terminal device stores a game program and is used to present game pictures. The local terminal device is used to interact with the player through a graphical user interface, that is, conventionally, the game program is downloaded and installed on an electronic device and run. The way the local terminal device provides the graphical user interface to the player can include various methods. For example, it can be rendered and displayed on the display screen of the terminal device, or provided to the player through holographic projection. For example, the local terminal device can include a display screen and a processor. The display screen is used to present the graphical user interface, and the graphical user interface includes a game scene picture. The processor is used to run the game, generate the graphical user interface, and control the display of the graphical user interface on the display screen.
[0054] An introduction to the applicable application scenarios of this application is given. This application can be applied to the game technology field. In a game, multiple players participating in the game jointly join the same virtual battle.
[0055] Before entering this virtual battle, the player can select different character attributes for the controlled virtual object in this virtual battle. For example, identity attributes. By assigning different character attributes to determine different camps, so that the player can win the game competition by performing tasks assigned by the game in different stages of this virtual battle. For example, multiple controlled virtual objects with A character attributes "eliminate" the controlled virtual objects with B character attributes in the game stage to obtain the victory of the game competition. Here, it can also be that when entering this virtual battle, random character attributes are assigned to each controlled virtual object participating in this virtual battle.
[0056] The implementation environment provided by an embodiment of the present application may include: a first terminal device, a game server, and a second terminal device. The first terminal device and the second terminal device communicate with the game server respectively to achieve data communication. In this implementation manner, the first terminal device and the second terminal device are respectively installed with application programs for executing the random result determination method in the game provided by the present application, and the game server is the server side for executing the random result determination method in the game provided by the present application. Through the application program, the first terminal device and the second terminal device can communicate with the game server respectively.
[0057] Taking the first terminal device as an example, the first terminal device establishes communication with the game server by running the application program. In an optional implementation manner, the game server establishes the current virtual battle according to the game request of the application program. Among them, the parameters of the current virtual battle can be determined according to the parameters in the received game request. For example, the parameters of the current virtual battle may include the number of people participating in the virtual battle, the character levels of the participants in the virtual battle, etc. When the first terminal device receives the response from the game server, the virtual scene corresponding to the current virtual battle is displayed through the graphical user interface of the first terminal device. In an optional implementation manner, the game server determines the current virtual battle for the application program from multiple established virtual battles according to the game request of the application program. When the first terminal device receives the response from the game server, the virtual scene corresponding to the current virtual battle is displayed through the graphical user interface of the first terminal device. The first terminal device is the device controlled by the first user, and the controlled virtual object displayed in the graphical user interface of the first terminal device is the player character controlled by the first user (i.e., the first controlled virtual object). The first user inputs operation instructions through the graphical user interface to control the player character to perform corresponding operations in the virtual scene.
[0058] Taking the second terminal device as an example, the second terminal device establishes communication with the game server by running an application program. In an optional implementation manner, the game server establishes the current virtual battle according to the game request of the application program. Among them, the parameters of the current virtual battle can be determined according to the parameters in the received game request. For example, the parameters of the current virtual battle may include the number of people participating in the virtual battle, the character levels of the people participating in the virtual battle, etc. When the second terminal device receives the response from the game server, it displays the virtual scene corresponding to the current virtual battle through the graphical user interface of the second terminal device. In an optional implementation manner, the game server determines the current virtual battle for the application program from the multiple established virtual battles according to the game request of the application program. When the second terminal device receives the response from the game server, it displays the virtual scene corresponding to the current virtual battle through the graphical user interface of the second terminal device. The second terminal device is a device controlled by a second user. The controlled virtual object displayed in the graphical user interface of the second terminal device is the player character controlled by the second user (i.e., the second controlled virtual object). The second user inputs an operation instruction through the graphical user interface to control the player character to perform corresponding operations in the virtual scene.
[0059] The game server performs data calculation based on the game data reported by receiving the first terminal device and the second terminal device, and synchronizes the calculated game data to the first terminal device and the second terminal device, so that the first terminal device and the second terminal device control the graphical user interface to render the corresponding virtual scene and / or virtual object according to the synchronized data sent by the game server.
[0060] In this implementation manner, the first controlled virtual object controlled by the first terminal device and the second controlled virtual object controlled by the second terminal device are virtual objects in the same virtual battle. Among them, the first controlled virtual object controlled by the first terminal device and the second controlled virtual object controlled by the second terminal device may have the same character attributes, or may have different character attributes. The first controlled virtual object controlled by the first terminal device and the second controlled virtual object controlled by the second terminal device belong to different camps.
[0061] It should be noted that the controlled virtual objects in the current virtual battle may include two or more virtual objects. Different controlled virtual objects may respectively correspond to different terminal devices. That is to say, in the current virtual battle, there are more than two terminal devices respectively sending and synchronizing game data with the game server.
[0062] A method for determining random results in a game provided by an embodiment of the present application. First, the server sends a random seed and the server time to the terminal device. When a random event occurs, the terminal device calculates a random number based on the random seed, the time stamp difference, and the current event of the terminal device, and directly determines the random result of the random event according to the obtained random number. When a large number of random events occur, there is no need to calculate random numbers on the server side, nor to wait for the server to send the random numbers to the terminal device. Compared with the method for determining random results in a game in the prior art, it solves the problem of heavy computing pressure on the server when a large number of random events occur.
[0063] Taking the above method applied to the terminal device as an example, the above exemplary steps provided by the embodiment of the present application will be described separately.
[0064] In step S101, the initial random seed may refer to the random seed generated by the server, and the initial random seed is used to calculate the random number.
[0065] The server time may refer to the system time of the server.
[0066] In the embodiment of the present application, at the beginning of the current game session, the server distributes the same initial random seed to the terminal devices corresponding to all controlled virtual objects participating in the current game session, and during the current game session, the time stamps of the server time are distributed to the terminal devices corresponding to all controlled virtual objects participating in the current game session at fixed intervals.
[0067] After receiving the initial random seed sent by the server, the terminal device stores the initial random seed for calculating the random number. The random numbers generated within the current game session are all calculated based on the initial random seed.
[0068] In step S102, the first current time may refer to the time when the time stamp of the server time is received, and the first current time is used to compare with the server time to determine the time stamp difference.
[0069] In the embodiment of the present application, the terminal device continuously receives the time stamps of the server time sent by the server at fixed intervals. Each time the time stamp of the server time is received, the time stamp of the first current time of the terminal device is obtained. Then, the difference between the time stamp of the server time and the time stamp of the first current time is calculated. This difference is the time stamp difference, and the calculated time stamp difference is stored for calculating the random number when the random number generation instruction is generated.
[0070] If the terminal device stores the timestamp difference and then receives a new timestamp of the server time sent by the server, obtain the first current time of the terminal device at this moment. Use the latest received timestamp of the server time and the first current time of the terminal device at this moment to calculate the latest timestamp difference, and replace the previously stored timestamp difference with the latest timestamp difference.
[0071] In step S103, the random number generation instruction may refer to an instruction for generating a random number. The random number generation instruction is used to determine the second current time of the terminal device and start random number calculation.
[0072] In an optional embodiment, the random number generation instruction is a random number generation instruction triggered by the user corresponding to the terminal device, or a random number generation instruction sent by the server.
[0073] Here, the random number generation instruction triggered by the user corresponding to the terminal device may be a random number generation instruction triggered when the user controls the controlled virtual object to perform a performance random behavior, so that the terminal device generates a random number according to the random number generation instruction and determines the random result of the performance random behavior according to the random number. For example: the random number generation instruction triggered when the user-controlled virtual object eats a health pack, so that the terminal device generates a random number according to the random number generation instruction and randomly selects the voice prompt to be played according to the random number.
[0074] The second current time may refer to the time when the random number generation instruction is received. The second current time is used to represent the start time of random number calculation.
[0075] In an optional embodiment, calculating a random number according to an initial random seed, a timestamp difference, and a timestamp of the second current time of the terminal device includes: performing a summation operation on the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device, and determining the result of the summation operation as a derived random seed; determining a random number according to the derived random seed.
[0076] Here, the derived random seed may refer to a derived value of the initial random seed. The derived random seed is obtained by adding the timestamp difference and the second current time to the initial random seed. The derived random seed is a random seed that can represent the time difference of the terminal device time of different terminal devices.
[0077] Specifically, first calculate the sum value of the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device. This sum value is the derived random seed. Then, use the derived random seed to calculate the random number.
[0078] It can be seen that the derived random seed can not only reflect the magnitude of the difference between the terminal device time and the server time, but also indirectly reflect the current time of the terminal device.
[0079] In an optional embodiment, determining a random number according to a derived random seed includes: using the derived random seed as the dividend and a set delay tolerance value as the divisor, and performing a modulo operation on the dividend and the divisor to determine a modulo value; determining the difference between the derived random seed and the modulo value as the target random seed; and determining a random number according to the target random seed.
[0080] Here, the delay tolerance value may refer to the magnitude of the delay time that can be tolerated. The delay tolerance value is used to convert derived random seeds with a difference between multiple derived random seeds less than the delay tolerance value into target random seeds with the same value.
[0081] The target random seed may refer to the derived random seed after the modulo operation. The target random seed is used to reduce the occurrence of different random results caused by different terminal device times of different terminal devices and the difference between the terminal device time and the server time.
[0082] Specifically, the target random seed can be substituted into a preset algorithm to calculate a random number. Here, the preset algorithm may refer to an algorithm that obtains the same random number when the same target random seed is input. The preset algorithm is used to obtain random numbers distributed according to a specified distribution curve. For example, the obtained random numbers are distributed linearly uniformly or normally.
[0083] Suppose the derived random seed is 99 and the delay tolerance value is 3, then the modulo value is 0, and the target random seed = 99 - 0 = 99.
[0084] Suppose the derived random seed is 100 and the delay tolerance value is 3, then the modulo value is 1, and the target random seed = 100 - 1 = 99.
[0085] Suppose the derived random seed is 101 and the delay tolerance value is 3, then the modulo value is 2, and the target random seed = 101 - 2 = 99.
[0086] Suppose the derived random seed is 102 and the delay tolerance value is 3, then the modulo value is 0, and the target random seed = 102 - 0 = 102.
[0087] It can be understood that after modulo calculations on multiple different derived random seeds 99, 100, and 101, the obtained modulo values are different, but the target random seeds obtained by subtracting the derived random seed from the modulo value are the same, all being 99. That is to say, after modulo operations on different numerical derived random seeds, target random seeds with the same value are obtained, and substituting the same random seed into the preset algorithm will obtain the same random number.
[0088] It can be seen that when the client delays of different terminal devices are different, as long as the derived random seeds corresponding to different terminal devices fall within the delay tolerance interval, the same random number can be obtained, so that the random event can obtain the same random result. The delay tolerance interval is the time window corresponding to the delay tolerance value, and the size of the delay tolerance interval is determined by the delay tolerance value. For example, if the delay tolerance value is 5, the delay tolerance interval is a 5-second time window.
[0089] In an alternative embodiment, determining a random number according to a target random seed includes: calculating the product of the target random seed and a set multiplier; calculating the sum of the product and a set increment; performing a modulo operation on the sum to obtain the random number.
[0090] Here, the target random seed can be substituted into a preset algorithm to calculate the random number, where the preset algorithm is a linear congruence algorithm.
[0091] Both the set multiplier and the set increment are set values. Taking the linear congruence algorithm as an example, the set multiplier is denoted as A, A = 214013, and the set increment is denoted as C, C = 2531011.
[0092] Specifically, first multiply the target random seed by the set multiplier 214013, then add the result of the multiplication to the set increment, use the added result as the dividend, and use the set random tolerance value as the divisor to perform a modulo operation to obtain the random number. Among them, the set random tolerance value is denoted as M, M = 65536, C = 7×17×21269, C and M are relatively prime to each other. However, M is smaller than both A and C, so the period of the generated random number is less than M.
[0093] Assume that the target random seed is a and the random number is R. Then the above calculation formula is R = (a×214013 + 2531011) mod 65536. The linear congruence algorithm belongs to the prior art and will not be elaborated here.
[0094] It can be seen that the above calculation process is actually a linear calculation of the target random seed, and then a modulo operation is performed on the linear calculation result, so that a random number uniformly distributed linearly can be obtained, making various different random results occur with the same random probability.
[0095] Please refer to Figure 2 , which is a flowchart of the method for determining random results in a game provided by an embodiment of the present application applied to a server. Specifically, the method for determining random results in a game provided by an embodiment of the present application includes:
[0096] S201, receiving a random synchronization instruction sent by a first terminal device, and determining the role information of a first controlled virtual object in the first terminal device.
[0097] S202. Determine the second terminal device corresponding to the second controlled virtual object that meets the preset conditions based on the role information of the first controlled virtual object.
[0098] S203. Send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines the random result corresponding to the random number.
[0099] Taking the above method applied to a server as an example, the above exemplary steps provided by the embodiments of the present application will be described separately.
[0100] In step S201, the first terminal device may refer to the terminal device used by the first user, and the first terminal device is used to represent the terminal device that actively presents random events. Among them, the random events here do not refer to all random events in the game, but refer to the random events that need to use the method provided by the present application to determine the random results.
[0101] The random synchronization instruction may refer to an instruction to inform the server that the terminal device triggers a random event, and the random synchronization instruction is used to determine the time when the first terminal device triggers the random event.
[0102] As an example, the role information may be the location information of the first controlled virtual object, the camp information of the first controlled virtual object, or the gender information of the first controlled virtual object.
[0103] In step S202, the preset condition may refer to the condition for determining the second controlled virtual object, and the preset condition is used to determine which second terminal devices need to obtain the same random result.
[0104] As an example, the preset condition may be the controlled virtual objects within the preset range of the first controlled virtual object, the controlled virtual objects in the same camp as the first controlled virtual object, or the controlled virtual objects of the same gender as the first controlled virtual object.
[0105] In step S203, the second terminal device may refer to the terminal device used by the second user, and the second terminal device is used to represent the terminal device that passively presents random events, that is, the second terminal device is the terminal device that synchronously presents random events with the first terminal device and presents the same random result.
[0106] In an optional embodiment, the method further includes: generating an initial random seed and distributing the generated initial random seed to the second terminal device; distributing the time stamp of the server time to the second terminal device every fixed duration; wherein, sending a random number generation instruction to the second terminal device so that the second terminal device generates a random number includes: sending a random number generation instruction to the second terminal device so that the second terminal device generates a random number according to the initial random seed and the time stamp of the server time.
[0107] Here, taking a single game as an example, the server distributes the same initial random seed to the terminal devices corresponding to all the controlled virtual objects participating in this game, so that each terminal device corresponding to this game generates random numbers using the same initial random seed. In this way, when the client delays of different terminal devices are different, as long as the derived random seeds corresponding to different terminal devices fall within the delay tolerance interval, the same random numbers can be obtained to present the same random results.
[0108] At the same time, the server continuously distributes the time stamps of the server time to all the terminal devices participating in this game to update the stored time stamp differences, avoiding the problem that the difference between the time stamp of the current server time and the time stamp of the current first current time has changed, but the stored time stamp difference is still the previous one.
[0109] In an optional embodiment, the method further includes: sending a random number generation instruction to the first terminal device, so that the first terminal device generates a random number and determines the random result corresponding to the random number.
[0110] Here, the server can also send a random number generation instruction to the first terminal device. When the first terminal device receives the random number generation instruction, it starts to calculate the random number. In this way, the first terminal device and other terminal devices calculate the random numbers at the same time point, making it easier for the random numbers calculated by different terminal devices to be consistent.
[0111] Next, with reference to Figure 3 the interaction process between multiple terminal devices and the server in the embodiments of the present application will be introduced.
[0112] Figure 3 The schematic diagram of the interaction process between the first terminal device, the second terminal device and the server provided by the embodiments of the present application is shown.
[0113] As Figure 3 shown, at the beginning of this game, the server distributes the same initial random seed to the terminal devices corresponding to all the controlled virtual objects participating in this game, including distributing the initial random seed to the first terminal device and the second terminal device respectively, and during this game, at fixed intervals, the server distributes the time stamps of the server time to the terminal devices corresponding to all the controlled virtual objects participating in this game.
[0114] The first terminal device sequentially executes step S301, step S302, step S303 and step S304 to determine the random result corresponding to the random number.
[0115] Step S301, receiving the initial random seed and the time stamp of the server time sent by the server.
[0116] Step S302: Determine the time stamp difference between the time stamp of the server time and the time stamp of the first current time of the first terminal device as the time stamp difference.
[0117] Step S303: Send a random synchronization instruction to the server in response to the random number generation instruction.
[0118] Step S304: In response to the random number generation instruction, calculate a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the first terminal device.
[0119] Step S305: Determine the random result corresponding to the random number.
[0120] In the embodiment of the present application, the method for calculating the random number is the same as that in the above embodiment, except that the terminal device is the first terminal device, which will not be elaborated here.
[0121] After receiving the random synchronization instruction, the server sequentially executes steps S311, S312, and S313.
[0122] Step S311: Receive the random synchronization instruction sent by the first terminal device and determine the role information of the first controlled virtual object in the first terminal device.
[0123] Step S312: Based on the role information of the first controlled virtual object, determine the second terminal device corresponding to the second controlled virtual object that meets the preset conditions.
[0124] Step S313: Send a random number generation instruction to the second terminal device.
[0125] In step S311, after the server receives the random synchronization instruction, it indicates that it is necessary to notify other second terminal devices corresponding to the second controlled virtual objects that meet the preset conditions to also perform corresponding random number calculations. Therefore, it is first necessary to determine which controlled virtual objects are the second controlled virtual objects.
[0126] In step S312, the server first extracts the required target information from the role information of the first controlled virtual object according to the preset conditions, and selects the second controlled virtual object from all the controlled virtual objects in the current game according to the target information.
[0127] Here, taking the controlled virtual object within the preset range of the first controlled virtual object as an example of the preset condition, at this time, it is necessary to extract the position information of the first controlled virtual object from the role information as the target information, and determine the second controlled virtual object according to the position information of the first controlled virtual object; taking the controlled virtual object of the same gender as the first controlled virtual object as an example of the preset condition, at this time, it is necessary to extract the gender information of the first controlled virtual object from the role information as the target information, and determine the second controlled virtual object according to the gender information of the first controlled virtual object.
[0128] After selecting the second controlled virtual object, the terminal device corresponding to the second controlled virtual object is used as the second terminal device.
[0129] In step S313, the server sends a random number generation instruction to the second terminal device, so that the second terminal device obtains the time stamp of the second current time, and calculates a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the second terminal device.
[0130] After receiving the random number generation instruction sent by the server, the second terminal device sequentially executes steps S323, S324, and S325.
[0131] Step S323, receive the random number generation instruction.
[0132] Step S324, calculate a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the second terminal device.
[0133] Step S325, determine the random result corresponding to the random number.
[0134] Here, the method for the second terminal device to calculate the random number is the same as that of the first terminal device, which will not be elaborated here.
[0135] Before executing step S323, the second terminal device will also receive the initial random seed sent by the server and the time stamp of the server event, that is, sequentially execute steps S321 and S322.
[0136] Step S321, receive the initial random seed sent by the server and the time stamp of the server time.
[0137] Step S322, determine the difference between the time stamp of the server time and the time stamp of the first current time of the second terminal device as the time stamp difference.
[0138] In the embodiment of the present application, the second terminal device performs the same calculation process as the first terminal device to obtain a random number. The difference is that the time stamp difference of the second terminal device is the difference between the time stamp of the server time and the time stamp of the first current time of the second terminal device, and the random number of the second terminal device is calculated based on the initial random seed, the time stamp difference, and the time stamp of the second current time of the second terminal device.
[0139] Compared with the random result determination method in the prior art, in the present application, the server can first send the random seed and the server time to the terminal device. When a random event occurs, the terminal device calculates a random number based on the random seed, the time stamp difference, and the current event of the terminal device, and directly determines the random result of the random event according to the obtained random number. When a large number of random events occur, there is no need to calculate the random number on the server side, nor to wait for the server to send the random number to the terminal device. Compared with the random result determination method in the prior art in games, the problem of heavy computing pressure on the server when a large number of random events occur is solved.
[0140] Based on the same inventive concept, in the embodiment of the present application, a random result determination system in a game corresponding to the random result determination method in the game is also provided. Since the principle of solving problems by the system in the embodiment of the present application is similar to the random result determination method in the above-mentioned game in the embodiment of the present application, the implementation of the system can refer to the implementation of the method, and the repeated parts will not be described again.
[0141] Please refer to Figure 4 , Figure 4 which shows a schematic structural diagram of the random result determination system in the game provided by the embodiment of the present application. As Figure 4 shown in, the random result determination system in the game includes a server 401, a terminal device 402, a terminal device 403, and a terminal device 404.
[0142] Here, the terminal device 402 can be used as the first terminal device, and the terminal devices 403 and 404 can be used as the second terminal devices.
[0143] The server 401 is connected to the terminal device 402, the terminal device 403, and the terminal device 404 respectively through the Internet.
[0144] The first terminal device is configured to, in response to a random number generation instruction, send a random synchronization instruction to the server 401, calculate a random number based on the initial random seed, the time stamp difference, and the time stamp of the second current time of the first terminal device, and determine the random result corresponding to the random number;
[0145] A server 401, configured to receive a random synchronization instruction sent by a first terminal device, determine role information of a first controlled virtual object in the first terminal device, determine a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object, and send a random number generation instruction to the second terminal device;
[0146] A second terminal device, configured to receive the random number generation instruction sent by the server, calculate a random number according to an initial random seed, a time stamp difference, and a time stamp of a second current time of the second terminal device sent by the server 401, and determine a random result corresponding to the random number.
[0147] Based on the same inventive concept, an embodiment of the present application further provides a terminal device corresponding to a method for determining a random result in a game. Since the principle of solving problems by the device in the embodiment of the present application is similar to the method for determining a random result in the above game in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and repeated parts will not be described again.
[0148] Please refer to Figure 5 , Figure 5 which shows a schematic structural diagram of the terminal device provided by the embodiment of the present application. As Figure 5 shown in
[0149] a receiving module 501, configured to receive an initial random seed sent by the server and a time stamp of the server system time;
[0150] a difference calculation module 502, configured to determine a time stamp difference by subtracting the time stamp of the first current time of the terminal device from the time stamp of the server system time;
[0151] a random number calculation module 503, configured to calculate a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device in response to the random number generation instruction;
[0152] a determination module 504, configured to determine a random result corresponding to the random number.
[0153] Based on the same inventive concept, an embodiment of the present application further provides a server corresponding to a method for determining a random result in a game. Since the principle of solving problems by the server in the embodiment of the present application is similar to the method for determining a random result in the above game in the embodiment of the present application, the implementation of the server can refer to the implementation of the method, and repeated parts will not be described again.
[0154] Please refer to Figure 6 , Figure 6 which shows a schematic structural diagram of the server provided by the embodiment of the present application. As Figure 6 shown in
[0155] A receiving module 601, configured to receive a random synchronization instruction sent by a first terminal device, and determine role information of a first controlled virtual object in the first terminal device;
[0156] A calculation module 602, configured to determine a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object;
[0157] A sending module 603, configured to send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines a random result corresponding to the random number.
[0158] Please refer to Figure 7 , Figure 7 , which shows a schematic structural diagram of an electronic device provided in an embodiment of the present application. As Figure 7 shown in, the electronic device 700 includes a processor 710, a memory 720, and a bus 730.
[0159] The memory 720 stores machine-readable instructions executable by the processor 710. When the electronic device 700 runs, the processor 710 communicates with the memory 720 through the bus 730. When the machine-readable instructions are executed by the processor 710, the steps of the method for determining a random result in a game in the method embodiment as described above can be executed, for example: Figure 1 shown in, receiving an initial random seed sent by a server and a time stamp of the server time; determining a time stamp difference between the time stamp of the server time and the time stamp of the first current time of the terminal device; in response to the random number generation instruction, calculating a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device; determining a random result corresponding to the random number.
[0160]
[0161] In an optional embodiment, when the processor 710 is used to execute calculating a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device, it is specifically configured to: perform a summation operation on the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device, and determine the result of the summation operation as a derived random seed; determine a random number according to the derived random seed.
[0162] In an optional embodiment, when the processor 710 is used to execute determining a random number according to the derived random seed, it is specifically configured to: use the derived random seed as a dividend, a set delay tolerance value as a divisor, perform a modulo operation on the dividend and the divisor to determine a modulo value; determine a difference between the derived random seed and the modulo value as a target random seed; determine a random number according to the target random seed.
[0163] In an alternative embodiment, when the processor 710 is used to execute the determination of a random number based on a target random seed, it is specifically configured to: calculate the product of the target random seed and a set multiplier; calculate the sum value of the product and a set increment; perform a modulo operation on the sum value to obtain a random number.
[0164] In an alternative embodiment, the random number generation instruction is a random number generation instruction triggered by a user corresponding to a terminal device, or a random number generation instruction sent by a server.
[0165] Receive a random synchronization instruction sent by a first terminal device, and determine the role information of a first controlled virtual object in the first terminal device; based on the role information of the first controlled virtual object, determine a second terminal device corresponding to a second controlled virtual object that meets a preset condition; send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines a random result corresponding to the random number.
[0166] In an alternative embodiment, the processor 710 further executes: generate an initial random seed, and distribute the generated initial random seed to the second terminal device; distribute a time stamp of the server time to the second terminal device at fixed intervals; wherein, sending a random number generation instruction to the second terminal device so that the second terminal device generates a random number includes: sending a random number generation instruction to the second terminal device so that the second terminal device generates a random number according to the initial random seed and the time stamp of the server time.
[0167] In an alternative embodiment, the processor 710 further executes: send a random number generation instruction to the first terminal device, so that the first terminal device generates a random number and determines a random result corresponding to the random number.
[0168] In the above manner, receive a random seed and server time sent by a server, calculate a random number according to the random seed, time stamp difference, and current event of the terminal device when a random event occurs, and directly determine the random result of the random event according to the obtained random number; further, when the client delays of different terminal devices are different, as long as the derived random seeds corresponding to different terminal devices fall within the delay tolerance interval, the same random number can be obtained to present the same random result. When a large number of random events occur, there is no need to calculate random numbers on the server side, nor wait for the server to send the random numbers to the terminal devices, solving the problem of heavy computing pressure on the server when a large number of random events occur.
[0169] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it can execute the steps of the method for determining a random result in a game in the method embodiment as described above Figure 1 shown, for example:
[0170] Receive the initial random seed sent by the server and the timestamp of the server time; determine the time difference between the timestamp of the server time and the timestamp of the first current time of the terminal device as the timestamp difference; in response to the random number generation instruction, calculate a random number according to the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device; determine the random result corresponding to the random number.
[0171] In an alternative embodiment, when the processor is used to execute calculating a random number according to the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device, it is specifically used for: performing a summation operation on the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device, and determining the result of the summation operation as the derived random seed; determining a random number according to the derived random seed.
[0172] In an alternative embodiment, when the processor is used to execute determining a random number according to the derived random seed, it is specifically used for: using the derived random seed as the dividend and the set delay tolerance value as the divisor, performing a modulo operation on the dividend and the divisor to determine the modulus value; determining the difference between the derived random seed and the modulus value as the target random seed; determining a random number according to the target random seed.
[0173] In an alternative embodiment, when the processor is used to execute determining a random number according to the target random seed, it is specifically used for: calculating the product of the target random seed and the set multiplier; calculating the sum value of the product and the set increment; performing a modulo operation on the sum value to obtain a random number.
[0174] In an alternative embodiment, the random number generation instruction is a random number generation instruction triggered by a user corresponding to the terminal device, or a random number generation instruction sent by the server.
[0175] Receive the random synchronization instruction sent by the first terminal device, and determine the role information of the first controlled virtual object in the first terminal device; based on the role information of the first controlled virtual object, determine the second terminal device corresponding to the second controlled virtual object that meets the preset conditions; send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines the random result corresponding to the random number.
[0176] In an alternative embodiment, the processor further executes: generating an initial random seed, and distributing the generated initial random seed to the second terminal device; distributing the timestamp of the server time to the second terminal device every fixed duration; where sending a random number generation instruction to the second terminal device so that the second terminal device generates a random number includes: sending a random number generation instruction to the second terminal device so that the second terminal device generates a random number according to the initial random seed and the timestamp of the server time.
[0177] In an optional embodiment, the processor further executes: sending a random number generation instruction to a first terminal device, so that the first terminal device generates a random number and determines a random result corresponding to the random number.
[0178] In the above manner, a random seed and a server time sent by the server are received, a random number is calculated according to the random seed, a time stamp difference, and a current event of the terminal device when a random event occurs, and a random result of the random event is directly determined according to the obtained random number; further, when the client delays of different terminal devices are different, as long as the derived random seeds corresponding to different terminal devices fall within a delay tolerance interval, the same random number can be obtained to present the same random result. When a large number of random events occur, there is no need to calculate random numbers on the server side, nor to wait for the server to send the random numbers to the terminal devices, thus solving the problem of heavy computing pressure on the server when a large number of random events occur.
[0179] Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0180] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings, direct couplings, or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0181] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0182] In addition, the functional units in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.
[0183] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs.
[0184] Finally, it should be noted that: the above-mentioned embodiments are only specific implementation manners of this application, used to illustrate the technical solutions of this application, rather than limiting it. The protection scope of this application is not limited to this. Although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed in this application can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. A method for determining a random result in a game, characterized in that, applied to a terminal device, the method includes: receiving an initial random seed sent by a server and a time stamp of the server time; determining a time stamp difference as the difference between the time stamp of the server time and the time stamp of the first current time of the terminal device; in response to a random number generation instruction, calculating a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device; determining a random result corresponding to the random number; The calculating the random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device includes: performing a summation operation on the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device, and determining the result of the summation operation as a derived random seed; determining the random number according to the derived random seed; The determining the random number according to the derived random seed includes: using the derived random seed as a dividend and a set delay tolerance value as a divisor, and performing a modulo operation on the dividend and the divisor to determine a modulo value; determining a difference between the derived random seed and the modulo value as a target random seed; determining a random number according to the target random seed.
2. The method according to claim 1, characterized in that, the determining the random number according to the target random seed includes: calculating a product of the target random seed and a set multiplier; calculating a sum value of the product and a set increment; performing a modulo operation on the sum value to obtain a random number.
3. The method according to claim 1, characterized in that, the random number generation instruction is a random number generation instruction triggered by a user corresponding to the terminal device, or a random number generation instruction sent by the server.
4. A method for determining a random result in a game, characterized in that, applied to a server, the method includes: receiving a random synchronization instruction sent by a first terminal device, and determining role information of a first controlled virtual object in the first terminal device; determining a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object; sending a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines a random result corresponding to the random number; The second terminal device calculates a random number in the following manner: performing a summation operation on an initial random seed, a time stamp difference, and a time stamp of a second current time, and determining the result of the summation operation as a derived random seed; determining the random number according to the derived random seed; The determining the random number according to the derived random seed includes: using the derived random seed as a dividend and a set delay tolerance value as a divisor, and performing a modulo operation on the dividend and the divisor to determine a modulo value; determining a difference between the derived random seed and the modulo value as a target random seed; determining a random number according to the target random seed.
5. The method according to claim 4, characterized in that, the method further includes: Generate an initial random seed and distribute the generated initial random seed to the second terminal device; Distribute the time stamp of the server time to the second terminal device at fixed intervals; Among them, the sending the random number generation instruction to the second terminal device to enable the second terminal device to generate a random number includes: Sending a random number generation instruction to the second terminal device to enable the second terminal device to generate a random number according to the initial random seed and the time stamp of the server time.
6. The method according to claim 4, wherein, the method further includes: Sending a random number generation instruction to the first terminal device to enable the first terminal device to generate a random number and determine the random result corresponding to the random number.
7. A system for determining random results in a game, wherein, the system includes: a first terminal device, a second terminal device, and a server; The first terminal device is configured to, in response to a random number generation instruction, send a random synchronization instruction to the server, calculate a random number according to an initial random seed, a time stamp difference, and the time stamp of the second current time of the first terminal device, and determine the random result corresponding to the random number; The server is configured to receive the random synchronization instruction sent by the first terminal device, determine the role information of the first controlled virtual object in the first terminal device, determine the second terminal device corresponding to the second controlled virtual object that meets the preset conditions based on the role information of the first controlled virtual object, and send a random number generation instruction to the second terminal device; The second terminal device is configured to receive the random number generation instruction sent by the server, calculate a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the second terminal device sent by the server, and determine the random result corresponding to the random number; The first terminal device and the second terminal device calculate random numbers in the following manner: Performing a summation operation on the initial random seed, the time stamp difference, and the time stamp of the second current time, and determining the result of the summation operation as a derived random seed; Determining the random number according to the derived random seed; The determining the random number according to the derived random seed includes: Using the derived random seed as the dividend and the set delay tolerance value as the divisor, performing a modulo operation on the dividend and the divisor to determine a modulo value; Determining the difference between the derived random seed and the modulo value as the target random seed; Determining the random number according to the target random seed.
8. A terminal device, wherein, the terminal device includes: A receiving module, configured to receive the initial random seed sent by the server and the time stamp of the server system time; A difference calculation module, configured to determine the difference between the time stamp of the server system time and the time stamp of the first current time of the terminal device as the time stamp difference; A random number calculation module, configured to, in response to a random number generation instruction, calculate a random number according to the initial random seed, the time stamp difference, and the time stamp of the second current time of the terminal device; A determination module, configured to determine the random result corresponding to the random number; The random number calculation module is specifically configured to: Perform a summation operation on the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device, and determine the result of the summation operation as the derived random seed; Determine the random number according to the derived random seed; The determining the random number according to the derived random seed includes: Use the derived random seed as the dividend and the set delay tolerance value as the divisor, and perform a modulo operation on the dividend and the divisor to determine the modulus value; Determine the difference between the derived random seed and the modulus value as the target random seed; Determine the random number according to the target random seed.
9. A server, characterized in that, the server includes: a receiving module, configured to receive a random synchronization instruction sent by a first terminal device, and determine the role information of a first controlled virtual object in the first terminal device; a calculation module, configured to determine a second terminal device corresponding to a second controlled virtual object that meets a preset condition based on the role information of the first controlled virtual object; a sending module, configured to send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number and determines a random result corresponding to the random number; The second terminal device calculates the random number in the following manner: Perform a summation operation on the initial random seed, the timestamp difference, and the timestamp of the second current time, and determine the result of the summation operation as the derived random seed; Determine the random number according to the derived random seed; The determining the random number according to the derived random seed includes: Use the derived random seed as the dividend and the set delay tolerance value as the divisor, and perform a modulo operation on the dividend and the divisor to determine the modulus value; Determine the difference between the derived random seed and the modulus value as the target random seed; Determine the random number according to the target random seed.
10. An electronic device, characterized in that, it includes: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the method for determining a random result in the game according to any one of claims 1 to 6.
11. A computer-readable storage medium, characterized in that, a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes the steps of the method for determining a random result in the game according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data selection method and related device
CN107046564A
Game data processing method and device
CN109481935A