A CLIP-based strategy for playing a game object layout method and application thereof
By using the CLIP model to customize the appearance and attributes of game objects in strategy battles, the problem of uncontrollable appearance and attributes of chess pieces is solved, thus improving the playability and fun of the game.
Patent Information
- Application Number
- CN202311078627.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-08-25
AI Technical Summary
In existing strategy games such as auto chess, the appearance and attributes of pieces are difficult to personalize, and the randomness is uncontrollable, resulting in monotonous game strategies and reduced playability.
The CLIP model is used to customize the appearance and attributes of game objects. By using images and text descriptions uploaded by users, CLIP is used to calculate similarity and generate credibility, thus realizing personalized layout of the game pieces.
It improves the game's playability and fun, enhances the controllability of piece generation and the diversity of strategies, and reduces the probability of strategy repetition.
Smart Images

Figure CN117258301B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of digital data processing, in particular to a CLIP-based strategy battle game object layout method combining game design, deep learning, natural language understanding and computer vision and application thereof. BACKGROUND
[0002] Strategy game is a game with various forms of victory as the theme, which provides players with an environment to deal with complex things by thinking, allowing players to freely control, manage and use people or things (objects) in the game to achieve the goal required by the game. In fact, most puzzle games belong to the category of strategy games, such as chess, and tactics, psychological warfare, opportunity utilization, etc. are also emphasized in strategy games. Therefore, strategy games are generally in the form of "battle".
[0003] Autonomous chess is also one of the strategy battle games. Its core gameplay of automatic battle of chess pieces brings players a novel and interesting game experience. Players can choose, upgrade and match different chess pieces to form a powerful battle formation, observe their automatic combat on the battlefield, and take certain strategies to influence the outcome of the battle. This gameplay is deeply loved by the majority of players, attracting a large number of players to participate and explore. Because of the strategy and competitiveness of autonomous chess, it has become an important type of electronic sports, attracting the attention of many professional players and audiences.
[0004] However, there are still deficiencies and problems in the design scheme of these strategy battle games including autonomous chess. Taking autonomous chess as an example, firstly, the personalization problem in autonomous chess game, the existing technology often only provides some fixed and preset chess characters, and the image and attribute value of the chess piece are difficult to be adjusted by the player, resulting in single chess selection and relatively simple strategy design, which inhibits the strategy diversity of the player and the personalized generation of the chess piece; secondly, the randomness of the current autonomous chess mainly reflects that the chess pieces obtained by the player are randomly refreshed by the system, which belongs to "uncontrollable randomness", that is, it cannot be guaranteed that the system can refresh the chess piece you want, and this means that the player cannot determine the probability of obtaining a specific chess piece, cannot predict or plan his game strategy, and this instability may lead to confusion or frustration of the player in the game, reducing the playability and participation of the game. SUMMARY
[0005] The present application solves the problems in the prior art and provides a CLIP-based strategy battle game object layout method and application thereof.
[0006] The technical concept of the present application is CLIP (Contrastive Language-Image Pre-Training), a pre-training model proposed by OpenAI company, which is a model for jointly processing computer vision and natural language. It is a pre-training neural network model originally used for matching images and text. It is a pre-training neural network that has been trained on a large image database. It uses vector projection strategy for text and images. The model is trained in the vector space of text and images by calculating the cosine similarity to make similar images and text closer in the vector space. In the method of the present application, the CLIP model plays the role of "evaluator" as a source of reliable randomness in the game. The image of the game object (piece) can be designed by the user and basically matches the picture uploaded by the user. The attribute of the game object (piece) is calculated by the CLIP similarity output using the picture uploaded by the user and the description of the picture as input, and then the image and attribute are customized to a certain extent.
[0007] The technical solution adopted by the present application is a strategy battle game object layout method based on CLIP, which comprises the following steps:
[0008] Step 1: Configure objects and set the image and attribute value of different objects;
[0009] Step 2: User uploads strategy battle game object layout target data;
[0010] Step 3: The trained CLIP model calculates the reliability of the target data and returns the attribute value of the object; the attack power of each battle game object is different, and the returned reliability value is used as the attribute such as attack power, and the attribute value corresponds to the battle game object one by one;
[0011] Step 4: User manages objects based on the attribute value of the object output by the CLIP model to complete object layout.
[0012] Preferably, in step 2, the target data includes a picture and a corresponding text description.
[0013] Preferably, in step 3, the picture and the text description are pre-processed respectively and then input into the trained CLIP model. The CLIP model encodes the processed picture and text description respectively and outputs the corresponding feature vectors. The similarity of the two feature vectors is calculated as the reliability.
[0014] Preferably, the preprocessing of the picture includes image scaling, cropping and standardization processing. The standardization processing here includes but is not limited to rotation, normalization, filtering, etc.
[0015] Preferably, the preprocessing of the text description includes splitting words, word vectorization, and special symbol addition.
[0016] A method for arranging game objects in a strategy battle game based on CLIP is applied to a Gomoku game.
[0017] Preferably, the Gomoku game includes a client, a backend server, and a front-end interface cooperating with the client, the client and the backend server are configured with a CLIP server, and the CLIP server is configured with a CLIP model.
[0018] Preferably, the user uploads target data including pictures and corresponding text descriptions on the front-end interface, the client sends the target data to the backend server through an HTTP or HTTPS interface, the backend server saves the pictures to a temporary folder, and the backend server sends the file path of the pictures and the text description to the CLIP server through a gRPC interface after establishing a connection with the started CLIP server.
[0019] Preferably, the backend server encapsulates the similarity of the pictures and the corresponding text description returned by the CLIP server and the picture path into JSON or other formats, returns them to the client through an HTTP or HTTPS interface, and displays the returned pictures and their attribute values through the front-end interface, wherein the returned pictures are used as the basis for generating the images of the game objects in the battle, and the attribute values are generally the calculated similarity, which is used as the attack attribute in Gomoku.
[0020] Preferably, objects are dynamically generated based on the returned pictures and their attribute values, each object is provided with a listener, an event is triggered by the user, the selected object is added to a list and the front-end interface is updated in real time, the user saves the latest object order data after adjusting the objects on the client, and the backend server processes the data and saves them to the corresponding database.
[0021] The application relates to a method for arranging game objects in a strategy battle game based on CLIP and an application thereof, and the method comprises the following steps: configuring objects, setting the images and attribute values of different objects, uploading object layout target data of the strategy battle game by a user, calculating the reliability of the target data by using a trained CLIP model, returning the attribute values of the objects, managing the objects based on the attribute values of the objects output by the CLIP model, and completing the object layout.
[0022] The application has the following advantages:
[0023] (1) can generate unique objects by using the CLIP model algorithm, relies on the CLIP model, gives the strategy war game reliable randomness through reasonable layout of the object, increases the game interest while reducing the probability of strategy repetition between players, improves the game experience of players;
[0024] (2) easy to deploy and functionally expand. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 is the flowchart of the present application;
[0026] Figure 2 is the application structure diagram of the present application;
[0027] Figure 3 is the front-end interface schematic diagram of the present application in the embodiment after loading the picture and the corresponding text description;
[0028] Figure 4 is the attribute value schematic diagram of the object returned by the CLIP model calculation in the embodiment of the present application;
[0029] Figure 5 is the schematic diagram of object adjustment completed in the client in the embodiment of the present application. DETAILED DESCRIPTION
[0030] The present application will be further described in detail below in combination with embodiments, but the protection scope of the present application is not limited thereto.
[0031] As shown in the figure, the present application relates to a strategy war game object layout method based on CLIP, which comprises the following steps: Figure 1 Step 1: configure objects, set the image and attribute value of different objects;
[0032] Step 2: the user uploads the object layout target data of the strategy war game;
[0033] In step 2, the target data includes pictures and corresponding text descriptions.
[0034] For example, to generate a chess piece with high attack force, the user can input the description word "strong warrior" and upload a picture similar to the description, the higher the similarity of the picture and the text description, the higher the value returned by the CLIP model calculation to a certain extent, thereby realizing a certain degree of control over the generation of the chess piece.
[0035] Step 3: the trained CLIP model calculates the credibility of the target data and returns the attribute value of the object;
[0036]
[0037] In step 3, after preprocessing the image and text description respectively, they are input into the trained CLIP model. The CLIP model encodes the processed image and text description respectively, outputs the corresponding feature vectors, calculates the similarity between the two feature vectors, and uses the similarity as the confidence level.
[0038] Image preprocessing includes image scaling, cropping, and normalization.
[0039] Preprocessing of the text description includes keyword extraction.
[0040] Based on the aforementioned embodiments, the CLIP model is used to process the data of "powerful warriors" and their corresponding images. When the description and image are highly similar, the generated pieces may have high attack power. The generation process of this attribute value is based on the data input and uploaded by the player, rather than being completely random, making the random results controllable within a certain range.
[0041] Step 4: The user manages the object based on the attribute values of the object output by the CLIP model and completes the object layout.
[0042] In this invention, the application of the CLIP model cannot completely guarantee the consistency between the generated chess piece attribute values and the input content, because the attribute values of the generated objects are also affected by other factors, such as the distribution of the training dataset and the limitations of the model. This achieves the requirement of randomness in the game, and makes the game more challenging and interesting through randomness without affecting the actual development of the strategy game.
[0043] The present invention also relates to an application of the CLIP-based strategy game object layout method, applied to an auto chess game.
[0044] like Figure 2 As shown, the auto chess game includes a client and a backend server. The client has a frontend interface, and the client, backend server and CLIP server are configured together. The CLIP server is configured with a CLIP model.
[0045] Users upload target data, including images and corresponding text descriptions, through the front-end interface. The client sends the target data to the back-end server via HTTP or HTTPS, and the back-end server saves the images to a temporary folder. After establishing a connection with the started CLIP server via the gRPC protocol, the back-end server sends the image file path and text description to the CLIP server via the gRPC interface.
[0046] The backend server encapsulates the similarity of the picture and the corresponding text description returned by the CLIP server and the picture path into JSON or other formats, and returns them to the client through an HTTP or HTTPS interface, and displays the returned picture and its attribute values through the front-end interface.
[0047] Based on the returned picture and its attribute values, objects are dynamically generated, and listeners are provided for each object. When a user triggers an event, the selected object is added to the list and the front-end interface is updated in real time. After the user completes the object adjustment on the client, the latest object sequence data is saved and transmitted to the backend server, which processes the data and saves it to the corresponding database.
[0048] The application based on the small program to realize the self-walking chess is taken as an example for description, wherein the client and the front-end interface are the user's mobile phone and its WeChat mini-program interface, and the backend server is a game server; the front-end interface of the self-walking chess game is developed by using Cocos and WeChat small game platform, the backend server of the game is built by using Golang and Gin framework, and Python is used as the CLIP server; the servers communicate with each other through gRPC, realizing cross-language interface calling.
[0049] In the application process, first, the automatic registration, login and authentication of the user are completed, and the user completes the login, and if it is the first login, the user is automatically registered.
[0050] (1) First login, automatic registration
[0051] (1-1) The client obtains the code, EncryptedData and iv of this login, and sends them to the backend server together, wherein the code is a temporary credential in the WeChat mini-program during login, and the EncryptedData and iv are parameters required for encrypting the player data in the WeChat mini-program, wherein the EncryptedData is the player data, such as the gender and avatar of the player, which is encrypted by using AES and then encoded into a Base64 string, and the iv is an initial vector of the encryption algorithm;
[0052] (1-2) After receiving the parameter data, the backend server obtains the user login state information through a special interface, including the session information session_key, and decrypts the EncryptedData by using the session_key and iv; the algorithm used for decryption is AES-128-CBC, and the PKCS#7 padding is adopted; after obtaining the decrypted data, the PKCS7 padding character at the end of the data source is removed, and finally the user data, including the gender, avatar, residence, nickname, OpenId and other sensitive data, is obtained by deserialization; the user avatar is downloaded and stored in the local server;
[0053] (1-3) Store the user's OpenId, name, head address and other data into the database to complete user registration.
[0054] (II) Login and authentication of registered users
[0055] (2-1) After the user logs in, the client sends login information to the backend server, generates a unique session ID, and stores the player's OpenId as value in the server-maintained map (session) with the session ID as key. The server returns the generated session ID to the front-end interface as the value of the Cookie. When requesting other function services after login, the client sends the session ID as Cookie to the server;
[0056] (2-2) The authentication middleware (Auth) obtains the session ID from the Cookie sent by the client, queries the server-maintained map (session) according to the obtained session ID, and returns a 401 status code if the session ID does not exist or is not legal, indicating that it is not authorized. If the session ID exists and is legal, the authentication middleware obtains the corresponding player OpenId from the map (session), and sets the OpenId to the request context;
[0057] (2-3) The business logic layer can obtain the player's OpenId from the request context, read the player's information, and perform corresponding operations.
[0058] (III) User-defined chess piece generation and attribute value calculation
[0059] (3-1) As shown in Figure 3 , the user uploads the target chess piece picture and fills in the text description on the front-end interface. The client collects the user's picture and text description, and sends them to the backend server through HTTP or HTTPS interface. The backend server receives the request, saves the picture to a temporary folder, and returns the file path of the picture. It establishes a connection with the CLIP server started by Python through gRPC protocol, and sends the picture file path and text description as parameters to the Python CLIP server through the gRPC interface.
[0060] (3-2) CLIP model calculates the similarity between picture and text:
[0061] (3-2-1) After receiving the request, the CLIP server reads the picture from the temporary folder according to the picture file path and performs preprocessing operations such as image scaling, cropping and standardization.
[0062] (3-2-2) Process the text description and input the picture and text together into the pre-trained CLIP model for feature extraction;
[0063] (3-2-3) The CLIP model encodes the image and text description and outputs the corresponding feature vector;
[0064] (3-2-4) Calculate the similarity score between the feature vectors of the image and the text description using cosine similarity or other similarity measurement methods;
[0065] (3-2-5) The CLIP server returns this similarity score to the backend server through the gRPC interface;
[0066] (3-3) As shown in Figure 4 , the backend server encapsulates the similarity score and picture path into JSON or other formats and returns them to the client through the HTTP or HTTPS interface. The client displays the returned picture and its attribute values in the front-end interface as the generated chess piece for this personalized customization. Thus, the user chess piece personalization and predicted CLIP attribute value calculation functions are completed.
[0067] (Four) User chess piece management and team deployment
[0068] (4-1) As shown in Figure 5 , in the chess piece management page of the front-end interface, the ScrollView component provided by the Cocos game engine is used to display and support sliding functions. ScrollView contains two nodes, ScrollBar and Content. After receiving the object data returned by the backend server, the client dynamically generates and adds chess piece prefabs to the Content node. Each prefab node represents a chess piece (object). A listener is set to trigger the TOUCH_END event when the user's finger presses and leaves the node. When the TOUCH_END event occurs, the selected chess piece node will be added to the selected chess piece list, and the UI will be updated in real time;
[0069] (4-2) The client determines whether it is in the chess piece adjustment mode by judging the value of a preset variable. The preset variable refers to a variable that corresponds to different values when the user clicks a certain function, thereby determining the execution mode. If it is in the chess piece adjustment mode, the chess piece adjustment mode operation is executed. The user adjusts the battle order of the chess pieces by dragging and exchanging their positions. If it is not in the chess piece adjustment mode, the chess piece adjustment mode operation is not executed, and only the current selected chess piece list is displayed. When the user completes the chess piece order adjustment, the save button can be clicked to upload the new chess piece order to the backend server. After receiving the new chess piece order, the backend server processes and saves it to the corresponding database.
[0070] (4-3) When the user fights in the team deployment page, the corresponding strategy can be executed according to the saved piece order.
[0071] It should be noted that in the implementation process, the logic of dragging and exchanging the positions of the chess pieces needs to be handled, including the calculation of the coordinates of the nodes, the position judgment and the position update, etc. The experience of UI interaction also needs to be considered, such as the following animation when dragging, boundary detection and legality judgment, etc.
[0072] (Five) User chess game
[0073] (5-1) After the user selects the match game, send a request to join the matching queue to the server, and the server receives the request and adds it to the matching queue, and waits for a certain number of users to join the queue;
[0074] (5-2) When the number of users in the queue reaches a certain threshold, the server randomly selects a pair of users from the queue for pairing, and after pairing is successful, the server sends a pairing success message to the two users, and the client receives the opponent information and the game information, and the game starts; If the number of users in the queue is not enough to pair, wait for new users to join; If there is no available opponent, wait for a certain period of time and send a waiting message to the client, and continue to wait for new users to join;
[0075] (5-3) After the game starts, initialize the user team and the enemy team, and pass the team information to the battle manager. Here, the initialized game program can be regarded as a battle manager, which controls the progress of the game;
[0076] After the turn-based battle starts, initialize the round counter and the current operation user, and loop the following operations until the game ends or a draw:
[0077] (5-3-1) The current operation user selects the chess piece to be moved and performs the moving operation;
[0078] (5-3-2) The current operation user performs an attack action, performs target judgment, and if there is an attackable target, initiates an attack animation and sound effect;
[0079] (5-3-3) According to the attack result, update the user state and the game state, and if necessary, display a prompt or warning message;
[0080] (5-3-4) Determine whether the current operation user loses the game, if so, trigger the game settlement process, in the game settlement process, determine whether there is a user who loses all chess pieces, if so, proceed with the game settlement, create a game settlement page, which includes the match and user score information and displays it;
[0081] (5-3-5) A button for returning to the hall is provided, a UI interaction event is bound, a prompt box is popped up by clicking the button to ask whether to exit the game, and corresponding operations are performed according to the operation selected by the user, such as returning to the hall or continuing the game.
[0082] Based on this method, the development of a computer medium and program and device based on the CLIP model for the layout of game objects in a battle game can be further implemented; taking the WeChat applet as an example, after starting the game and logging in and entering the hall page, there are three function buttons of “generate chess pieces”, “my chess pieces” and “online matching” on the hall page for the user to select, clicking “generate chess pieces” jumps to the chess piece generation page, uploads an image and inputs text, calculates the similarity data of the uploaded image and text through the CLIP model and returns as the attribute value of the generated chess pieces; clicking “my chess pieces” enters the chess piece management page to view and adjust the chess piece team, arrange the chess pieces for the battle, and complete the strategy; clicking “online matching” performs random matching for the battle, the game ends when the user loses all chess pieces or exceeds 50 rounds, and if the user wins, “victory” is displayed, and if the enemy wins, “failure” is displayed; the user clicks “OK” or a similar button to jump to the hall page, at this time, the position of the chess pieces and other battle data are restored to the pre-match initialization value.
[0083] Those skilled in the art will appreciate that embodiments of the present application can be provided as methods, systems, or computer program products. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage media, etc.) having computer usable program code embodied therein.
[0084] The present application is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The means for implementing each flow or multiple flows and / or blocks Figure 1 The means for implementing each flow or multiple flows and / or blocks
[0085] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0086] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0087] Although preferred embodiments of the application have been described herein, substitutions and alterations can be made to these embodiments by those skilled in the art without departing from the spirit and scope of the application. Accordingly, it is intended that the appended claims be interpreted as including all such alternatives and modifications as fall within the spirit and scope of the present application.
[0088] It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application cover modifications and variations of this application provided they come within the scope of the appended claims and their equivalents.
Claims
1. An application of a CLIP-based strategy for a battle game object layout method, characterized in that: The method comprises the following steps: Step 1: configure objects, set the image and attribute value of different objects; Step 2: the user uploads the object layout target data of the strategy confrontation game; Step 3: the trained CLIP model calculates the credibility of the target data and returns the attribute value of the object; Step 4: the user manages the object based on the attribute value of the object output by the CLIP model and completes the object layout; The method is applied to a self-moving chess game, which comprises a client, a backend server, a front-end interface matched with the client, a CLIP server matched with the client and the backend server, and the CLIP server is configured with a CLIP model; The user uploads target data on the front-end interface, the target data comprises a picture and a corresponding text description; the client sends the target data to the backend server through an HTTP or HTTPS interface, and the backend server saves the picture to a temporary folder; the backend server establishes a connection with the started CLIP server through a gRPC protocol, and then sends the file path of the picture and the text description to the CLIP server through a gRPC interface; the backend server encapsulates the similarity of the picture and the corresponding text description returned by the CLIP server and the picture path into JSON or other formats, and returns them to the client through an HTTP or HTTPS interface, and displays the returned picture and its attribute value on the front-end interface.
2. The application of a CLIP-based strategy battle game object layout method according to claim 1, characterized in that: In step 2, the target data comprises a picture and a corresponding text description.
3. The application of a CLIP-based strategy battle game object layout method according to claim 1, characterized in that: In step 3, after the picture and the text description are respectively preprocessed, they are respectively input into the trained CLIP model, the CLIP model encodes the processed picture and text description respectively, outputs corresponding feature vectors, and calculates the similarity of the two feature vectors as the credibility.
4. The application of a CLIP-based strategy battle game object layout method according to claim 1, characterized in that: The preprocessing of the picture comprises image scaling, cropping and standardization processing.
5. The application of a CLIP-based strategy battle game object layout method according to claim 1, characterized in that: The preprocessing of the text description comprises splitting words, word vectorization and adding special symbols.
6. The application of a CLIP-based strategy battle game object layout method according to claim 1, characterized in that: Based on the returned picture and its attribute value, objects are dynamically generated, a listener is matched with each object, an event is triggered by the user, the selected object is added to a list and the front-end interface is updated in real time; after the user completes the object adjustment on the client, the latest object sequence data is saved and transmitted to the backend server, and the backend server processes the data and saves them to a corresponding database.
Citation Information
Patent Citations
Game battle power evaluation method and device and computer readable storage medium
CN115228092A