Disclosure of Invention
In order to solve the above problems, the present invention provides a method and system for optimizing game operation, including a model making step, making at least two models with successively reduced fineness for the models in the game, and setting the transmission frame number per second corresponding to each fineness, i.e. the frame number grade; a game monitoring step, wherein a game program is executed, and each parameter in the game running is captured; the operation optimization step is that comparison is carried out according to the transmission frame number per second and each frame number grade, and a model corresponding to the grade of the transmission frame number per second which is more than or equal to the frame number is set as a model displayed by the current game program; and repeatedly executing the game monitoring step and the operation optimizing step until the game program stops operating.
The technical scheme adopted by the invention for solving the problems is as follows: a method of optimizing game play, the method comprising the steps of: a model formulation step, namely making at least two models with successively reduced fineness for the model in the game and setting the transmission frame number per second corresponding to each fineness, namely the frame number grade; a game monitoring step, wherein a game program is executed, and various parameters in the game running are captured, wherein the parameters include but are not limited to the number of frames transmitted per second; the operation optimization step is that comparison is carried out according to the transmission frame number per second and each frame number grade, and a model corresponding to the grade of the transmission frame number per second which is more than or equal to the frame number is set as a model displayed by the current game program; and repeatedly executing the game monitoring step and the running optimization step until the game program stops running.
Further, the modeling step includes: capturing game resources to obtain a model file; obtaining a plurality of models with different fineness by using a method for reducing the fineness of the models, wherein the method for reducing the fineness of the models comprises but is not limited to reducing the faces of the models and reducing the number of grids; and sequencing the models according to the fineness, and setting the corresponding transmission frame per second value of each model according to a grading strategy to obtain the frame number grade corresponding to each model.
Further, the classification strategy is that a corresponding frame number grade is set according to the model fineness, and the higher the model fineness is, the higher the value of the transmission frame number per second of the corresponding frame number grade is.
Further, the game monitoring step includes: and injecting a monitoring script or calling an engine interface into the game program to acquire parameters of the game running, including but not limited to the number of transmission frames per second, the occupancy rate of a central processing unit, the occupancy rate of a graphic processor and the occupancy rate of a memory.
Further, the operation optimization step includes: acquiring the transmission frame number per second in a period of time, and carrying out average processing to obtain the average value of the frame number, wherein the period of time can be customized; comparing the obtained average value of the frame number with the set frame number grade one by one, subtracting and taking an absolute value, judging whether the average value of the frame number is greater than the frame number grade, if so, taking the frame number grade with the maximum absolute value as a target optimization frame number grade, and otherwise, taking the frame number grade with the minimum absolute value as a target optimization frame number grade; and setting the model corresponding to the target optimization frame number grade as the model displayed by the current game program.
The other aspect of the technical scheme adopted by the invention for solving the problems is as follows: a system for optimizing game play, comprising: the model optimization module is used for making at least two models with successively reduced fineness for the models in the game and setting the transmission frame number per second, namely the frame number grade, corresponding to each fineness; the game monitoring module is used for executing a game program and capturing each parameter in the running process of the game; the game optimization module is used for comparing the transmission frame number per second with each frame number grade and setting a model corresponding to the grade of the transmission frame number per second greater than or equal to the frame number as a model displayed by the current game program; and the game process detection module is used for detecting whether the game program runs and sending a detection command to other modules according to the result.
Further, the model optimization module includes a model processing module for reducing the fineness of the model by reducing the faces of the model and reducing the number of meshes.
Further, the game optimization module comprises: the frame number processing module is used for acquiring the transmission frame number per second in a period of time and carrying out average processing to obtain the average value of the frame number, wherein the period of time can be customized; the judging module is used for comparing the obtained average value of the frame number with the set frame number grade one by one, performing subtraction to obtain an absolute value, judging whether the average value of the frame number is greater than the frame number grade, if so, taking the frame number grade with the maximum absolute value as a target optimization frame number grade, and otherwise, taking the frame number grade with the minimum absolute value as a target optimization frame number grade; and the model setting module is used for setting the model corresponding to the target optimization frame number grade as the model displayed by the current game program.
The invention has the beneficial effects that: according to the method and the system for optimizing the game operation, the fineness of the model in the game is set according to the number of frames transmitted per second according to the game operation condition, so that the fineness of the game picture is ensured and the game experience of the user is improved under the condition that the user experience is ensured without video game operation.
Detailed Description
The conception, the specific structure and the technical effects of the present invention will be clearly and completely described in conjunction with the embodiments and the accompanying drawings to fully understand the objects, the schemes and the effects of the present invention.
It should be noted that, unless otherwise specified, the descriptions of the upper, lower, left, right, etc. used in the present disclosure are only relative to the positional relationship of the components of the present disclosure with respect to each other in the drawings. As used in this disclosure, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. Furthermore, unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
The use of any and all examples, or exemplary language ("e.g.," such as "or the like") provided herein, is intended merely to better illuminate embodiments of the invention and does not pose a limitation on the scope of the invention unless otherwise claimed.
FPS-is a definition in the field of images, and refers to the number of frames transmitted per second of a picture, and refers to the number of pictures of animation or video in popular terms. The FPS measures the amount of information used to store and display the motion video. The greater the number of frames per second, the more fluid the displayed motion will be. Typically, a minimum of 30 to avoid motion blindness is used. Some computer video formats can only provide 15 frames per second.
LOD, short for Levels of Detail, means multiple Levels of Detail. The LOD technology is used for determining the resource allocation of object rendering according to the positions and the importance of the nodes of the object model in the display environment, reducing the number of faces and the detail of non-important objects and further obtaining high-efficiency rendering operation.
Referring to FIG. 1, a flow chart of a method according to a preferred embodiment of the invention is shown,
a model formulation step, namely making at least two models with successively reduced fineness for the models in the game and setting the transmission frame number per second corresponding to each fineness, namely the frame number grade;
in order to ensure that running equipment with various configurations can run a game program normally and smoothly, a model making step is firstly carried out, the existing model is simplified or details are enriched to obtain a plurality of models with different fineness, different FPSs are sequentially set from high to low according to the fineness of the model, the FPS is the frame number grade, and generally speaking, the higher the fineness of the model is, the higher the requirement of the corresponding FPS is.
A game monitoring step, wherein a game program is executed, and various parameters in the game running are captured, wherein the parameters include but are not limited to the number of frames transmitted per second;
in general, there are a number of schemes for acquiring FPS in a game,
1) The FPS of the current system is obtained through a dumpsys surface Flinger | grep strips command, if only a game process is in the foreground, correct FPS information can be obtained, and the method is the simplest and does not need a hook, an inject and the like.
2) FPS information can also be obtained by injecting so into a surfacinger process, a hook eglSwapBuffers function, and recording the calling frequency of the function.
3) And injecting so to the target process, loading a script in a unity gameobject of the target process, and recording the calling frequency of update to acquire the FPS.
The third is the most complex, the first is the simplest, but the third is the principle and implementation profile for acquiring FPS. The reason is as follows: by injecting so and cs scripts in the target game process, the FPS can be acquired, and other more functions can be realized.
After inject is used for injecting a so file into a target game process, the so calls a mono relevant interface, a dll file compiled by cs is loaded into the process, a gameobject. Step introduction an inject process is prepared (ATTACH applies for memory in a target process, a section of machine instruction is written into the target process, and so-called so file to be injected is loaded in the machine instruction section); after the So is loaded to the target process, calling dlsym to acquire a mono relevant interface; calling a mono related interface to acquire System.Reflect in mscollib, namely class information of Assembly, and acquiring Load and GetType methods in the class; calling a mono correlation interface to obtain class of GameObject in UnityEngine, and obtaining a vector and an AddComponent method in the class; reading all dll binary contents compiled by a script file to be injected into a memory code _ buffer; calling a Load method in the step 3 to Load the code _ buffer content into the process; it will be complex after loading; acquiring the type information of class of the loaded main class (calling GetType in 3); calling mono _ object _ new to create a GameObject (using the class information obtained in 4); calling AddComponent to load the created object into unity;
at this point, the script is loaded into the process, the update method and other methods are called when the frame is updated, and then an FPS calculator is realized, so that the FPS can be obtained. The above 10 steps need to be implemented in all mono running threads, and cannot be implemented in an initialization function for injecting SO calls (because most of the mono methods called by the steps are data locally cached by the mono threads), and the mode of switching to the mono thread is implemented by registering the profiler (by calling mono _ profiler _ install and mono _ profiler _ install _ method _ invoke).
And a script is injected into the game process, and the script can interact with the game UI to realize automatic testing.
The operation optimization step is that comparison is carried out according to the transmission frame number per second and each frame number grade, and a model corresponding to the grade of the transmission frame number per second which is more than or equal to the frame number is set as a model displayed by the current game program;
for example, the game running time within a segment of 10s is taken, the FPS of 10s is obtained, the average FPS of the 10s game is obtained through average processing, and then comparison is performed according to the previously set model fineness and the corresponding frame number grade, for example, three model fineness LOD1, LOD2 and LOD3 are set, wherein the fineness is sequentially reduced, and the consumption of new energy of equipment is also sequentially reduced in the same way; the three model accuracies correspond to three frame number levels FPS1, FPS2, and FPS3, where the values decrease sequentially.
Judging the average FPS and the grade of the three frame numbers, and if the average value is larger than the FPS1, setting the fineness of the model displayed in the current game as the fineness of the model corresponding to the FPS1, namely LOD1. Referring specifically to FIG. 2, a flow chart of the optimization procedure according to the preferred embodiment of the invention is shown.
And repeatedly executing the game monitoring step and the running optimization step until the game program stops running.
The whole optimization step is executed during game running, and real-time optimization of the game is realized.
The description is summarized to show that,
1. the FPS is calculated every frame by dividing 1 by the time elapsed since the previous frame to this frame.
2. For each object model, 3 LOD levels, LOD1, LOD2, LOD3, were made. The 3 LOD levels are defined according to the fineness of the model, and the LOD1, LOD2 and LOD3 models are increasingly less refined and consume less performance.
3. 3 FPS levels, FPS1, FPS2, FPS3, are defined. The lower the FPS1=45, FPSs 2=30, FPS3=20. The poorer the fluency of the game, the greater the performance pressure now will be. These 3 FPS levels correspond to the respective model LOD levels. The definition of the FPS value is based on the FPS value corresponding to the acceptable fluency of the game. For example, shooting games may have higher overall values, and RPG games may have lower overall values.
4. And acquiring the FPS calculated by the step 1 during the game running, and selecting the corresponding LOD level according to the grade of the FPS. For example, if the current FPS is 45> = FPS1, then LOD1 is selected, and if the current FPS is FPS1> =40> = FPS2, then LOD2 is selected, and so on.
Referring to FIG. 3, a block diagram of system modules, including
The model optimizing module is used for making at least two models with successively reduced fineness for the models in the game and setting the transmission frame number per second, namely the frame number grade, corresponding to each fineness, and the model optimizing module also comprises a model processing module which is used for reducing the fineness of the models by reducing the faces of the models and reducing the grid number;
the game monitoring module is used for executing a game program and capturing each parameter in the running process of the game;
the game optimization module is used for comparing the transmission frame per second with each frame number grade, setting a model corresponding to the grade that the transmission frame per second is greater than or equal to the frame number as a model displayed by the current game program, and the frame number processing module is used for acquiring the transmission frame per second in a period of time and carrying out average processing to obtain the average value of the frame numbers, wherein the period of time can be customized; the judgment module is used for comparing the obtained average value of the frame number with the set frame number grade one by one, subtracting and taking an absolute value, judging whether the average value of the frame number is greater than the frame number grade, if so, taking the frame number grade with the maximum absolute value as a target optimization frame number grade, and otherwise, taking the frame number grade with the minimum absolute value as a target optimization frame number grade; the model setting module is used for setting the model corresponding to the target optimization frame number grade as the model displayed by the current game program;
and the game process detection module is used for detecting whether the game program runs and sending a detection command to other modules according to the result.
It should be recognized that embodiments of the present invention can be realized and implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer readable memory. The methods may be implemented in a computer program using standard programming techniques, including a non-transitory computer-readable storage medium configured with the computer program, where the storage medium so configured causes a computer to operate in a specific and predefined manner, according to the methods and figures described in the detailed description. Each program may be implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language. Furthermore, the program can be run on a programmed application specific integrated circuit for this purpose.
Further, the operations of processes described herein can be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. The processes described herein (or variations and/or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) collectively executed on one or more processors, by hardware, or combinations thereof. The computer program includes a plurality of instructions executable by one or more processors.
Further, the method may be implemented in any type of computing platform operatively connected to a suitable interface, including but not limited to a personal computer, mini computer, mainframe, workstation, networked or distributed computing environment, separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, and the like. Aspects of the invention may be embodied in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optically read and/or write storage medium, RAM, ROM, or the like, such that it may be read by a programmable computer, which when read by the storage medium or device, is operative to configure and operate the computer to perform the procedures described herein. Further, the machine-readable code, or portions thereof, may be transmitted over a wired or wireless network. The invention described herein includes these and other different types of non-transitory computer-readable storage media when such media include instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. The invention also includes the computer itself when programmed according to the methods and techniques described herein.
A computer program can be applied to input data to perform the functions described herein to transform the input data to generate output data that is stored to non-volatile memory. The output information may also be applied to one or more output devices, such as a display. In a preferred embodiment of the invention, the transformed data represents physical and tangible objects, including particular visual depictions of physical and tangible objects produced on a display.
The above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiment, and the present invention shall fall within the protection scope of the present invention as long as the technical effects of the present invention are achieved by the same means. The invention is capable of other modifications and variations in its technical solution and/or its implementation, within the scope of protection of the invention.