Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of 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, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. Based on the embodiments of the present application, every other embodiment obtained by a person skilled in the art without making any inventive effort falls within the scope of protection of the present application.
The terms "a," "an," "the," and "said" are used in this specification to denote the presence of one or more elements/components/etc., the terms "comprising" and "having" are used in an open-ended fashion and mean that there may be additional elements/components/etc. in addition to the listed elements/components/etc., and the terms "first" and "second" etc. are used merely as labels, and are not limiting in number of their objects.
It should be understood that in embodiments of the present application, "at least one" means one or more and "a plurality" means two or more. "and/or" is merely an association relationship describing the association object, and means that three relationships may exist, for example, a and/or B, and that a alone exists, a and B together, and B alone exists. The character "/" generally indicates that the context-dependent object is an "or" relationship. "comprising A, B and/or C" means comprising any 1 or any 2 or 3 of A, B, C.
It should be understood that in embodiments of the present application, "B corresponding to a", "a corresponding to B", or "B corresponding to a" means that B is associated with a from which B may be determined. Determining B from a does not mean determining B from a alone, but may also determine B from a and/or other information.
First, an application scenario to which the present application is applicable will be described. The method and the system can be applied to game scenes, the embodiment of the application does not limit specific application scenes, and any scheme using the random result determining method, the system, the client and the server provided by the embodiment of the application is within the protection scope of the application.
It should be noted that, before the present application proposes a multi-player online game, when the same random result needs to be displayed on different terminal devices for the same random event, the same random number needs to be obtained on different terminal devices, so as to obtain the same random result according to the same random number, for example, some natural phenomena in the game are random, offline rendering, randomly generating game content, etc., and the same random result needs to be displayed on different terminal devices. At present, the method for obtaining the same random result is that a server generates a random number and then sends the generated random number to different terminal devices, so that the different terminal devices can obtain the same random result when presenting a random event. However, with the above-described random result determination method, it is necessary to generate a random seed on the server and perform random number calculation based on the generated random seed, which may cause a problem of a large computational pressure of the server when a large number of random events occur.
Based on the above, the embodiment of the application provides a method for determining random results in games, so as to relieve the operation pressure of a server.
In order to facilitate a better understanding of the present application by those skilled in the art, the following describes in detail a method, a system, a terminal device, a server, an electronic device, and a storage medium for determining a random result in a game provided in the embodiments of the present application.
Referring to fig. 1, a flowchart of an application of a method for determining a random result in a game provided by an embodiment of the present application to a terminal device is shown, and specifically, the method for determining a random result in a game provided by the embodiment of the present application includes:
S101, receiving an initial random seed sent by a server and a timestamp of server time.
S102, determining a difference value between the timestamp of the server time and the timestamp of the first current time of the terminal equipment as a timestamp difference value.
S103, responding to the random number generation instruction, and calculating the random number according to the initial random seed, the time stamp difference value and the time stamp of the second current time of the terminal equipment.
S104, determining a random result corresponding to the random number.
The following first describes the names involved in the embodiments of the present application.
Terminal equipment:
the terminal device according to the embodiment of the application mainly refers to an intelligent device for providing a virtual scene of the virtual combat and capable of controlling and operating a controlled virtual object, and the terminal device can include any one of a smart phone, a tablet computer, a portable computer, a desktop computer, a game console, a Personal Digital Assistant (PDA), an electronic book reader, (Moving Picture Experts Group Audio Layer IV) a dynamic image expert compression standard audio layer 4) player. The terminal device installs and runs therein an application program supporting a virtual scene of a game, such as an application program supporting a three-dimensional game scene. The application may include, but is not limited to, any of a virtual reality application, a three-dimensional map application, a military simulation application, MOBA game, a multi-player survival game, a Third-Personal (TPS) game.
Graphical user interface:
Is an interface display format in which a person communicates with a computer, allowing a user to manipulate icons, marks, or menu options on a screen using an input device such as a mouse or a keyboard, and also allowing a user to manipulate icons or menu options on a screen by performing a touch operation on a touch screen of a touch terminal to select a command, start a program, or perform some other task, etc.
Virtual scene:
Is a virtual scene that an application program displays (or provides) when running on a terminal device or a server, i.e., a scene used in the course of normal play of a game. That is, the virtual scene refers to a virtual game control carrying a virtual object in the course of game play, and the virtual object may perform actions such as movement and skill release in the virtual scene under an operation instruction issued by a user (i.e., a player) to the terminal device. Alternatively, the virtual scene may be a simulation environment for the real world, a semi-simulation and semi-fictional virtual environment, or a pure 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, and the virtual environment can be sky, land, ocean and the like, wherein the land comprises environmental elements such as deserts, cities and the like. The virtual scene is a scene of a complete game logic of a user control virtual object. Alternatively, the virtual scene may also be used for virtual environment combat between at least two virtual objects, with virtual resources available for use by the at least two virtual objects in the virtual scene. By way of example, the virtual scene may include any one or more of a game background element, a game virtual character element, a game prop element, and the like.
Virtual object:
refers to controlled virtual objects in a virtual environment, which may be virtual characters manipulated by a player, including but not limited to at least one of virtual characters, virtual animals, cartoon characters, and uncontrolled virtual objects, which may be non-player-manipulated virtual characters (NPCs), and also virtual objects, which refer to static objects in a virtual scene, such as virtual props, virtual tasks, a location in a virtual environment, topography, house, bridge, vegetation, etc. in a virtual scene. Static objects are often not directly controlled by players, but can respond to the interaction behavior (e.g., attack, demolition, etc.) of virtual objects in a virtual scene to perform a corresponding performance, e.g., the virtual objects can demolish, pick up, drag, build, etc. a building. Alternatively, the virtual object may not be able to respond to the interaction of the virtual object, for example, the virtual object may be a building, a door, a window, a plant, etc. in the virtual scene, but the virtual object cannot interact with the virtual object, for example, the virtual object cannot destroy or remove the window, etc. Alternatively, when the virtual scene is a three-dimensional virtual environment, the virtual characters may be three-dimensional virtual models, each having its own shape and volume in the three-dimensional virtual environment, occupying 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, which implements different external figures by wearing different skins. In some implementations, the avatar may also be implemented using a 2.5-dimensional or 2-dimensional model, as embodiments of the application are not limited in this regard.
There may be a plurality of controlled virtual objects in the virtual scene, which are virtual characters manipulated by the player (i.e., characters controlled by the player through the input device), or artificial intelligence set in the virtual environment combat through training (ARTIFICIAL INTELLIGENCE, AI). Optionally, the controlled virtual object is a virtual character playing an athletic in the virtual scene. Optionally, the number of controlled virtual objects in the virtual scene fight is preset, or is dynamically determined according to the number of terminal devices joining the virtual fight, which is not limited by the embodiment of the present application. In one possible implementation, a user can control a controlled virtual object to move in the virtual scene, e.g., control the controlled virtual object to run, jump, crawl, etc., as well as control the controlled virtual object to fight with other controlled virtual objects using skills, virtual props, etc., provided by an application.
In an alternative embodiment, the terminal device may be a local terminal device. Taking a game as an example, the local terminal device stores a game program and is used to present a game screen. The local terminal device is used for interacting with the player through the graphical user interface, namely, conventionally downloading and installing the game program through the electronic device and running. The manner in which the local terminal device provides the graphical user interface to the player may include a variety of ways, for example, may be rendered for display on a display screen of the terminal device or provided to the player by holographic projection. For example, the local terminal device may include a display screen for presenting a graphical user interface including a game scene screen and a processor for running the game, generating the graphical user interface, and controlling the display of the graphical user interface on the display screen.
The application scene to which the application is applicable is introduced. The application can be applied to the technical field of games, and in the games, a plurality of players participating in the games join in the same virtual fight together.
Before entering the virtual match, the player can select different character attributes, such as identity attributes, for the controlled virtual objects in the virtual match, and determine different camps by distributing the different character attributes, so that the player wins the game match by executing the task of game distribution in different match-making stages of the virtual match-making, for example, a plurality of controlled virtual objects with A character attributes "reject" the controlled virtual objects with B character attributes in the match-making stage to obtain the winning of the game match. Here, when entering the present virtual fight, a character attribute may be randomly assigned to each controlled virtual object participating in the present virtual fight.
An implementation environment provided in one 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 are respectively communicated with the game server to realize data communication. In this embodiment, the first terminal device and the second terminal device are respectively installed with an application program for executing the method for determining a random result in a game provided by the present application, and the game server is a server for executing the method for determining a random result in a game provided by the present application. The first terminal device and the second terminal device can communicate with the game server respectively through the application program.
Taking the first terminal device as an example, the first terminal device establishes communication with the game server by running an application program. In an alternative embodiment, the game server establishes the virtual match according to the game request of the application program. The parameters of the virtual fight may be determined according to the parameters in the received game request, for example, the parameters of the virtual fight may include the number of people participating in the virtual fight, the role level participating in the virtual fight, and so on. And when the first terminal equipment receives the response of the game server, displaying a virtual scene corresponding to the virtual fight through a graphical user interface of the first terminal equipment. In an alternative embodiment, the game server determines, for the application program, a virtual match from among a plurality of virtual matches that have been established according to the game request of the application program, and when the first terminal device receives a response from the game server, displays a virtual scene corresponding to the virtual match through a graphical user interface of the first terminal device. The first terminal equipment is equipment controlled by a first user, the controlled virtual object displayed in the graphical user interface of the first terminal equipment is a player character controlled by the first user (namely, the first controlled virtual object), and the first user inputs an operation instruction through the graphical user interface so as to control the player character to execute corresponding operation in the virtual scene.
Taking a second terminal device as an example, the second terminal device establishes communication with the game server by running an application. In an alternative embodiment, the game server establishes the virtual match according to the game request of the application program. The parameters of the virtual fight may be determined according to the parameters in the received game request, for example, the parameters of the virtual fight may include the number of people participating in the virtual fight, the role level participating in the virtual fight, and so on. And when the second terminal equipment receives the response of the game server, displaying a virtual scene corresponding to the virtual fight through a graphical user interface of the second terminal equipment. In an alternative embodiment, the game server determines, according to the game request of the application program, the virtual match for the application program from the plurality of virtual matches that have been established, and when the second terminal device receives the response of the game server, the virtual scene corresponding to the virtual match is displayed 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 a player character controlled by the second user (namely, a second controlled virtual object), and the second user inputs an operation instruction through the graphical user interface so as to control the player character to execute corresponding operation in the virtual scene.
The game server calculates data according to game data reported by the first terminal equipment and the second terminal equipment, and synchronizes the calculated game data to the first terminal equipment and the second terminal equipment, so that the first terminal equipment and the second terminal equipment control the graphic user interface to render corresponding virtual scenes and/or virtual objects according to the synchronous data issued by the game server.
In this embodiment, 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 combat. 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 role attribute, or may have different role attributes, where 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.
It should be noted that, the controlled virtual object in the present virtual match may include two or more virtual objects, and different controlled virtual objects may correspond to different terminal devices respectively, that is, in the present virtual match, there are two or more terminal devices that respectively perform sending and synchronization of game data with the game server.
According to the method for determining the random result in the game, the server firstly transmits the random seed and the server time to the terminal equipment, the terminal equipment calculates the random number according to the random seed, the time stamp difference value and the current event of the terminal equipment when the random event occurs, and directly determines the random result of the random event according to the obtained random number, when a large number of random events occur, the random number calculated at the server is not needed, and the server does not need to wait for the server to transmit the random number to the terminal equipment.
The steps of the foregoing examples provided in the embodiments of the present application will be described below by taking an example in which the foregoing method is applied to a terminal device.
In step S101, the initial random seed may refer to a server-generated random seed, which is used to calculate a random number.
Server time may refer to a system time of a server.
In the embodiment of the application, when the current exchange starts, the server distributes the same initial random seed to all terminal devices corresponding to the controlled virtual objects participating in the current exchange, and in the current exchange process, the server distributes the time stamp of the server time to all the terminal devices corresponding to the controlled virtual objects participating in the current exchange every fixed time length.
After receiving the initial random seed sent by the server, the terminal equipment stores the initial random seed for calculating the random number. The random numbers generated in the current pair are all calculated based on the initial random seed.
In step S102, the first current time may refer to a time at which a timestamp of the server time is received, and the first current time is used to compare with the server time to determine a timestamp difference.
In the embodiment of the application, the terminal equipment continuously receives the time stamp of the server time sent by the server at fixed time intervals, acquires the time stamp of the first current time of the terminal equipment each time the time stamp of the server time is received, calculates the difference value between the time stamp of the server time and the time stamp of the first current time, namely the time stamp difference value, stores the calculated time stamp difference value, and calculates the random number by using the time stamp difference value when the random number generation instruction is to be generated.
If the terminal equipment stores the time stamp difference value and then receives the time stamp of the new server time sent by the server, the first current time of the terminal equipment at the moment is obtained, the latest time stamp difference value is calculated by utilizing the time stamp of the latest received server time and the first current time of the terminal equipment at the moment, and the latest time stamp difference value is used for replacing the time stamp difference value stored at the last time.
In step S103, the random number generation instruction may refer to an instruction to generate a random number, the random number generation instruction being used to determine the second current time of the terminal device, and start the random number calculation.
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.
The random number generation instruction triggered by the user corresponding to the terminal device can be a random number generation instruction triggered when the user controls the controlled virtual object to execute the expressive random behavior, so that the terminal device generates a random number according to the random number generation instruction and determines a random result of the expressive random behavior according to the random number, for example, the random number generation instruction triggered when the user controls the virtual object to eat a blood bag, so that the terminal device generates a random number according to the random number generation instruction and randomly generates a voice prompt to be played according to the random number.
The second current time may refer to a time at which the random number generation instruction is received, the second current time being used to characterize a calculation start time of the random number.
In an alternative embodiment, the random number is calculated according to the initial random seed, the time stamp difference value and the time stamp of the second current time of the terminal device, and the method comprises the steps of carrying out summation operation on the initial random seed, the time stamp difference value and the time stamp of the second current time of the terminal device, determining the result of the summation operation as a derivative random seed, and determining the random number according to the derivative random seed.
Here, the derived random seed may refer to a derived value of an initial random seed, the derived random seed is obtained by adding a time stamp difference value and a second current time on the basis of the initial random seed, and the derived random seed is a random seed capable of characterizing a terminal device time difference of different terminal devices.
Specifically, the sum of the initial random seed, the time stamp difference value and the time stamp of the second current time of the terminal device is calculated, the sum is the derived random seed, and then the derived random seed is used for calculating the random number.
It can be seen that the derived random seed can not only reflect the difference between the time of the terminal device and the time of the server, but also indirectly reflect the current time of the terminal device.
In an alternative embodiment, the random number is determined according to the derived random seed, and the method comprises the steps of taking the derived random seed as a dividend, taking a set delay tolerance value as a divisor, carrying out modulo operation on the dividend and the divisor to determine a model value, determining the difference between the derived random seed and the model value as a target random seed, and determining the random number according to the target random seed.
Here, the delay tolerance value may refer to a size of a delay time that can be tolerated, and the delay tolerance value is used to transform derivative random seeds having a difference value smaller than the delay tolerance value between a plurality of derivative random seeds into target random seeds having the same value.
The target random seed can refer to derived random seeds after modular operation, and the target random seed is used for reducing the occurrence of different situations of random results caused by different terminal equipment time of different terminal equipment and different terminal equipment time and server time.
Specifically, the target random seed may be substituted into a preset algorithm to calculate the random number, where the preset algorithm may refer to an algorithm that inputs the same target random seed to obtain the same random number, and the preset algorithm is used to obtain the random number distributed according to a specified distribution curve, for example, the obtained random number is uniformly distributed according to a linear or a positive-to-negative distribution.
Assuming that the derived random seed is 99 and the delay tolerance value is 3, the modulus value is 0, and the target random seed=99-0=99.
Assuming that the derived random seed is 100 and the delay tolerance value is 3, the modulus value is 1, and the target random seed=100-1=99.
Assuming that the derived random seed is 101 and the delay tolerance value is 3, the modulus value is 2, and the target random seed=101-2=99.
Assuming that the derived random seed is 102 and the delay tolerance value is 3, the modulus value is 0, and the target random seed=102-0=102.
It can be understood that the modulus obtained by performing the modulus calculation on the plurality of different derived random seeds 99, 100, 101 is different, but the target random seeds obtained by subtracting the derived random seeds from the modulus are the same, that is, the target random seeds with the same value are obtained by performing the modulus calculation on the derived random seeds with different values, and the same random seeds are substituted into the preset algorithm to obtain the same random number.
It can be seen that when the client delays of different terminal devices are different, as long as the derivative random seeds corresponding to different terminal devices fall in the delay tolerance interval, the same random number can be obtained, so that the random event obtains the same random result, the delay tolerance interval is a time window corresponding to the delay tolerance value, the size of the delay tolerance interval is determined by the delay tolerance value, for example, the delay tolerance value is 5, and the delay tolerance interval is a time window of 5 seconds.
In an alternative embodiment, determining the random number from the target random seed includes calculating a product of the target random seed and a set multiplier, calculating a sum of the product and the set increment, and performing a modulo operation on the sum to obtain the random number.
Here, the random number may be calculated by substituting the target random seed into a preset algorithm, wherein the preset algorithm is a linear congruence algorithm.
The multiplier and increment are set values, taking a linear congruence algorithm as an example, the multiplier is set as a, a= 214013, and the increment is set as C, c= 2531011.
Specifically, the target random seed is multiplied by a set multiplier 214013, then the multiplied result is added with a set increment, the added result is used as a dividend, and the set random tolerance value is used as a divisor to carry out modulo operation to obtain the random number. The set random tolerance value is denoted as M, m=65536, c=7x17x21269, and C and M are prime numbers, but M is smaller than a and C, so the period of the generated random number is smaller than M.
Assuming that the target random seed is a and the random number is R, the above calculation formula is r= (a×214013+2531011) mod 65536. The linear congruence algorithm belongs to the prior art and is not described in detail here.
Therefore, the calculation process is to perform linear calculation on the target random seed, and then perform modulo operation on the linear calculation result, so that random numbers distributed uniformly according to linearity can be obtained, and multiple different random results can occur according to the same random probability.
Referring to fig. 2, a flowchart of an application of the method for determining a random result in a game provided by the embodiment of the application to a server is shown, and specifically, the method for determining a random result in a game provided by the embodiment of the application includes:
s201, receiving a random synchronization instruction sent by the first terminal equipment, and determining role information of a first controlled virtual object in the first terminal equipment.
S202, determining second terminal equipment corresponding to a second controlled virtual object meeting preset conditions based on the role information of the first controlled virtual object.
S203, a random number generation instruction is sent to the second terminal equipment, so that the second terminal equipment generates a random number, and a random result corresponding to the random number is determined.
The steps of the foregoing examples provided in the embodiments of the present application will be described below by taking an example in which the foregoing method is applied to a server.
In step S201, the first terminal device may refer to a terminal device used by the first user, where the first terminal device is used to characterize the terminal device that actively presents the random event. Wherein, the random event here does not refer to all random events in the game, but refers to random events which need to be determined by adopting the method provided by the application.
The random synchronization instruction may refer to an instruction informing the server that the terminal device triggers a random event, and the random synchronization instruction is used to determine a time when the first terminal device triggers the random event.
As an example, the character information may be location information of the first controlled virtual object, camping information of the first controlled virtual object, or sex information of the first controlled virtual object.
In step S202, the preset condition may refer to a condition for determining the second controlled virtual object, where the preset condition is used for determining which second terminal devices need to obtain the same random result.
As an example, the preset condition may be a controlled virtual object within a preset range of the first controlled virtual object, the preset condition may also be a controlled virtual object in the same camp as the first controlled virtual object, and the preset condition may also be a controlled virtual object in the same sex as the first controlled virtual object.
In step S203, the second terminal device may refer to a terminal device used by the second user, where the second terminal device is used to characterize a terminal device that passively presents a random event, i.e. the second terminal device is a terminal device that presents a random event in synchronization with the first terminal device and presents the same random result.
In an alternative embodiment, the method further comprises the steps of generating an initial random seed, distributing the generated initial random seed to the second terminal device, distributing a time stamp of the server time to the second terminal device every fixed time length, and sending a random number generation instruction to the second terminal device to enable the second terminal device to generate the random number, wherein the step of sending the random number generation instruction to the second terminal device is conducted to enable the second terminal device to generate the random number according to the initial random seed and the time stamp of the server time.
Taking a single office as an example, the server distributes the same initial random seed to all terminal devices corresponding to the controlled virtual objects participating in the office, so that each terminal device corresponding to the office generates a random number by using the same initial random seed, and when the client delays of different terminal devices are different, the same random number can be obtained as long as the derivative random seeds corresponding to the different terminal devices fall in the delay tolerance interval, so as to present the same random result.
Meanwhile, the server can continuously distribute the time stamp of the server time to all the terminal devices participating in the current office so as to update the stored time stamp difference value, and the problem that the stored time stamp difference value is still the previous time stamp difference value because the difference value between the time stamp of the current server time and the time stamp of the current first current time is changed is avoided.
In an alternative embodiment, the method further comprises sending a random number generation instruction to the first terminal device, so that the first terminal device generates a random number, and determining a random result corresponding to the random number.
The server may send a random number generation instruction to the first terminal device, where the first terminal device starts to calculate the random number when receiving the random number generation instruction, so that the first terminal device performs random number calculation at the same time point with other terminal devices, and it is easier to make the random numbers calculated by different terminal devices consistent.
The following describes an interaction procedure between a plurality of terminal devices and a server in an embodiment of the present application with reference to fig. 3.
Fig. 3 is a schematic diagram illustrating an interaction process between a first terminal device, a second terminal device, and a server according to an embodiment of the present application.
As shown in fig. 3, when the current session starts, the server distributes the same initial random seed to all terminal devices corresponding to the controlled virtual objects participating in the current session, including distributing the initial random seed to the first terminal device and the second terminal device respectively, and distributing time stamps of server time to all terminal devices corresponding to the controlled virtual objects participating in the current session every fixed time length in the current session.
The first terminal device sequentially performs step S301, step S302, step S303, and step S304 to determine a random result corresponding to the random number.
In step S301, the initial random seed sent by the server and the timestamp of the server time are received.
In step S302, a difference between the timestamp of the server time and the timestamp of the first current time of the first terminal device is determined as a timestamp difference.
Step S303, a random synchronization instruction is sent to the server in response to the random number generation instruction.
Step S304, responding to the random number generation instruction, and calculating the random number according to the initial random seed, the time stamp difference value and the time stamp of the second current time of the first terminal equipment.
Step S305, determining a random result corresponding to the random number.
In the embodiment of the present application, the method for calculating the random number is the same as the method in the above embodiment, except that the terminal device is the first terminal device, which is not described herein again.
After receiving the random synchronization instruction, the server sequentially executes steps S311, S312, and S313.
Step S311, receiving a random synchronization instruction sent by the first terminal device, and determining role information of the first controlled virtual object in the first terminal device.
Step S312, determining a second terminal device corresponding to the second controlled virtual object satisfying the preset condition based on the role information of the first controlled virtual object.
Step S313, a random number generation instruction is transmitted to the second terminal device.
In step S311, after receiving the random synchronization instruction, the server indicates that the second terminal devices corresponding to the second controlled virtual objects meeting the preset condition need to be notified to perform corresponding random number calculation, so that it is first determined which controlled virtual objects are the second controlled virtual objects.
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 condition, and selects the second controlled virtual object from all the controlled virtual objects of the current game according to the target information.
Here, taking a preset condition as an example of a controlled virtual object within a preset range of the first controlled virtual object, at this time, the position information of the first controlled virtual object needs to be extracted from the character information as target information, and the second controlled virtual object is determined according to the position information of the first controlled virtual object.
And after the second controlled virtual object is selected, taking the terminal equipment corresponding to the second controlled virtual object as second terminal equipment.
In step S313, the server sends a random number generation instruction to the second terminal device, so that the second terminal device obtains a timestamp of the second current time, and calculates a random number according to the initial random seed, the timestamp difference value, and the timestamp of the second current time of the second terminal device.
After the random number generation instruction sent by the server, the second terminal device sequentially executes steps S323, S324, and S325.
Step S323, a random number generation instruction is received.
Step S324, calculating the random number according to the initial random seed, the time stamp difference value and the time stamp of the second current time of the second terminal device.
Step S325, determining a random result corresponding to the random number.
Here, the method for calculating the random number by the second terminal device is the same as the method for calculating the random number by the first terminal device, and will not be described here again.
Before executing step S323, the second terminal device also receives the initial random seed sent by the server and the timestamp of the server event, that is, steps S321 and S322 are sequentially executed.
In step S321, the initial random seed sent by the server and the timestamp of the server time are received.
In step S322, a difference between the timestamp of the server time and the timestamp of the first current time of the second terminal device is determined as a timestamp difference.
In the embodiment of the application, the second terminal device and the first terminal device execute the same calculation process to obtain the random number, wherein the difference value of the time stamp of the second terminal device is the difference value 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 according to the initial random seed, the time stamp difference value and the time stamp of the second current time of the second terminal device.
Compared with the random result determining method in the prior art, the random seed and the server time can be sent to the terminal equipment by the server, the terminal equipment calculates the random number according to the random seed, the time stamp difference value and the current event of the terminal equipment when the random event occurs, the random result of the random event is directly determined according to the obtained random number, and when a large number of random events occur, the random number calculated at the server is not needed, and the server does not need to wait for the server to send the random number to the terminal equipment.
Based on the same inventive concept, the embodiment of the application also provides a system for determining the random result in the game, which corresponds to the method for determining the random result in the game.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating a system for determining a random result in a game according to an embodiment of the application. As shown in fig. 4, the in-game random result determination system includes a server 401, a terminal device 402, a terminal device 403, and a terminal device 404.
Here, the terminal device 402 may be regarded as a first terminal device, and the terminal device 403 and the terminal device 404 may be regarded as second terminal devices.
The server 401 is connected to a terminal device 402, a terminal device 403, and a terminal device 404, respectively, via the internet.
The first terminal device is configured to respond to the random number generation instruction, send a random synchronization instruction to the server 401, calculate a random number according to the initial random seed, the timestamp difference value and the timestamp of the second current time of the first terminal device, and determine a random result corresponding to the random number;
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, based on the role information of the first controlled virtual object, a second terminal device corresponding to a second controlled virtual object that meets a preset condition, 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 the random number according to the initial random seed sent by the server 401, the timestamp difference value, and the timestamp of the second current time of the second terminal device, and determine a random result corresponding to the random number.
Based on the same inventive concept, the embodiment of the present application further provides a terminal device corresponding to the method for determining a random result in a game, and since the principle of solving the problem by the device in the embodiment of the present application is similar to that of the method for determining a random result in a game in the embodiment of the present application, the implementation of the device may refer to the implementation of the method, and the repetition is omitted.
Referring to fig. 5, fig. 5 shows a schematic structural diagram of a terminal device according to an embodiment of the present application. As shown in fig. 5, the terminal device 500 includes:
a receiving module 501, configured to receive an initial random seed sent by a server and a timestamp of a server system time;
a difference calculating module 502, configured to determine a difference between a timestamp of the server system time and a timestamp of a first current time of the terminal device as a timestamp difference;
a random number calculating module 503, configured to calculate a random number according to the initial random seed, the timestamp difference value, and the timestamp of the second current time of the terminal device in response to the random number generating instruction;
A determining module 504, configured to determine a random result corresponding to the random number.
Based on the same inventive concept, the embodiment of the present application further provides a server corresponding to the method for determining a random result in a game, and since the principle of solving the problem by the server in the embodiment of the present application is similar to that of the method for determining a random result in a game in the embodiment of the present application, implementation of the server can refer to implementation of the method, and repeated parts are not repeated.
Referring to fig. 6, fig. 6 shows a schematic structural diagram of a server according to an embodiment of the present application. As shown in fig. 6, the server 600 includes:
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;
A calculating module 602, configured to determine, based on the role information of the first controlled virtual object, a second terminal device corresponding to a second controlled virtual object that meets a preset condition;
And the sending module 603 is configured to send a random number generation instruction to the second terminal device, so that the second terminal device generates a random number, and determine a random result corresponding to the random number.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the application. As shown in fig. 7, the electronic device 700 includes a processor 710, a memory 720, and a bus 730.
The memory 720 stores machine-readable instructions executable by the processor 710, which when executed by the processor 710, cause the processor 710 to communicate with the memory 720 via the bus 730 when the electronic device 700 is running, to perform the steps of the method for determining a random outcome in a game as in the method embodiment of fig. 1 described above, for example:
the method comprises the steps of receiving an initial random seed and a time stamp of server time sent by a server, determining a difference value between the time stamp of the server time and a time stamp of a first current time of terminal equipment as a time stamp difference value, responding to a random number generation instruction, calculating a random number according to the initial random seed, the time stamp difference value and a time stamp of a second current time of the terminal equipment, and determining a random result corresponding to the random number.
In an alternative embodiment, the processor 710 is 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, determine a result of the summation operation as a derived random seed, and determine the random number based on the derived random seed when configured to perform a calculation of the random number based on the initial random seed, the timestamp difference, and the timestamp of the second current time of the terminal device.
In an alternative embodiment, the processor 710 is configured to determine a model value by taking a derivative random seed as a dividend and a set delay tolerance value as a divisor, performing a modulo operation on the dividend and the divisor, determining a difference between the derivative random seed and the model value as a target random seed, and determining the random number from the target random seed.
In an alternative embodiment, the processor 710 is configured to calculate a product of the target random seed and the set multiplier, calculate a sum of the product and the set increment, and modulo the sum to obtain the random number when configured to determine the random number based on the target random seed.
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.
The method comprises the steps of receiving a random synchronization instruction sent by first terminal equipment, determining role information of a first controlled virtual object in the first terminal equipment, determining second terminal equipment corresponding to a second controlled virtual object meeting preset conditions based on the role information of the first controlled virtual object, sending a random number generation instruction to the second terminal equipment, enabling the second terminal equipment to generate a random number, and determining a random result corresponding to the random number.
In an alternative embodiment, the processor 710 further performs generating an initial random seed, distributing the generated initial random seed to the second terminal device, distributing a timestamp of the server time to the second terminal device at intervals of a fixed duration, wherein sending a random number generation instruction to the second terminal device to cause the second terminal device to generate a random number includes sending a random number generation instruction to the second terminal device to cause the second terminal device to generate a random number according to the initial random seed and the timestamp of the server time.
In an alternative embodiment, the processor 710 further executes 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.
By the method, the random seed and the server time sent by the server are received, when a random event occurs, a random number is obtained through calculation according to the random seed, the timestamp difference value and the current event of the terminal equipment, 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 derivative random seeds corresponding to different terminal devices fall in a delay tolerance interval, the same random numbers can be obtained to present the same random results, when a large number of random events occur, the random numbers calculated at the server are not needed, and the server does not need to wait for sending the random numbers to the terminal devices, so that the problem of high operation pressure of the server when a large number of random events occur is solved.
Embodiments of the present application also provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor, is capable of performing the steps of a method for determining a random outcome in a game as in the method embodiment shown in fig. 1, for example:
the method comprises the steps of receiving an initial random seed and a time stamp of server time sent by a server, determining a difference value between the time stamp of the server time and a time stamp of a first current time of terminal equipment as a time stamp difference value, responding to a random number generation instruction, calculating a random number according to the initial random seed, the time stamp difference value and a time stamp of a second current time of the terminal equipment, and determining a random result corresponding to the random number.
In an alternative embodiment, the processor is used for calculating the random number according to the initial random seed, the time stamp difference value and the time stamp of the second current time of the terminal device, and is particularly used for carrying out summation operation on the initial random seed, the time stamp difference value and the time stamp of the second current time of the terminal device, determining the result of the summation operation as a derivative random seed, and determining the random number according to the derivative random seed.
In an alternative embodiment, the processor is specifically configured to determine a module value by taking the derived random seed as a dividend and a set delay tolerance value as a divisor, performing modulo operation on the dividend and the divisor, determining a difference between the derived random seed and the module value as a target random seed, and determining the random number according to the target random seed when the processor is configured to determine the random number according to the derived random seed.
In an alternative embodiment, the processor is specifically configured to calculate a product of the target random seed and the set multiplier, calculate a sum of the product and the set increment, and perform a modulo operation on the sum to obtain the random number when the processor is configured to determine the random number from the target random seed.
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.
The method comprises the steps of receiving a random synchronization instruction sent by first terminal equipment, determining role information of a first controlled virtual object in the first terminal equipment, determining second terminal equipment corresponding to a second controlled virtual object meeting preset conditions based on the role information of the first controlled virtual object, sending a random number generation instruction to the second terminal equipment, enabling the second terminal equipment to generate a random number, and determining a random result corresponding to the random number.
In an alternative embodiment, the processor further executes the steps of generating an initial random seed, distributing the generated initial random seed to the second terminal device, distributing a timestamp of the server time to the second terminal device every fixed time length, wherein the step of sending a random number generation instruction to the second terminal device to enable the second terminal device to generate the random number comprises the step of sending the random number generation instruction to the second terminal device to enable the second terminal device to generate the random number according to the initial random seed and the timestamp of the server time.
In an alternative embodiment, the processor further executes 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.
By the method, the random seed and the server time sent by the server are received, when a random event occurs, a random number is obtained through calculation according to the random seed, the timestamp difference value and the current event of the terminal equipment, 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 derivative random seeds corresponding to different terminal devices fall in a delay tolerance interval, the same random numbers can be obtained to present the same random results, when a large number of random events occur, the random numbers calculated at the server are not needed, and the server does not need to wait for sending the random numbers to the terminal devices, so that the problem of high operation pressure of the server when a large number of random events occur is solved.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
It should be noted that the foregoing embodiments are merely illustrative embodiments of the present application, and not restrictive, and the scope of the application is not limited to the embodiments, and although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any modification, variation or substitution of some of the technical features of the embodiments described in the foregoing embodiments may be easily contemplated within the scope of the present application, and the spirit and scope of the technical solutions of the embodiments do not depart from the spirit and scope of the embodiments of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.