A method for implementing efficient random player names based on ets table in Erlang game server
By using the ets table in the erlang game server, looping to obtain and process random names, the inefficient random names problem in traditional methods is solved, and efficient name generation is achieved.
Patent Information
- Application Number
- CN202410793392.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-06-19
Smart Images

Figure CN118593998B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of game development, and in particular to a method for an Erlang game server to realize efficient random player names based on an ETS table. Background Art
[0002] The present invention provides an erlang game server based on the ets table, a method for efficiently randomizing player names. The process of randomizing player names in traditional online games is
[0003] (1) Randomly select a player name from the player name database, and then check whether the randomized name has been randomly selected before
[0004] (2) If yes, repeat step (1)
[0005] (3) If no, the random player name is successful
[0006] When most of the names in the random library have been used by players in the game, this method is very inefficient, resulting in frequent timeouts when randomizing player names and a poor gaming experience. This paper proposes a method that can achieve efficient randomization of player names. Summary of the invention
[0007] The technical problem to be solved by the present invention is to provide a method for realizing efficient random player names based on the ETS table of an Erlang game server to solve the existing problems.
[0008] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0009] A method for implementing efficient random player names in an Erlang game server based on an ETS table comprises the following steps:
[0010] S1. Generate an ets table T of the ordered_set type in Erlang;
[0011] S2, loop to obtain all random names and perform the following operations;
[0012] S21. Perform a CRC32 operation on the random name + server ID to obtain an integer A (where the + sign is only a link symbol and does not participate in the CRC32 operation. The server ID is added mainly to make the names of different servers random and unordered);
[0013] S22, insert the data consisting of integer A and random name {{A, random name}} into ets table T;
[0014] S23, use the first method provided by ets to get the first data {A1, random name 1} and store it;
[0015] S3. When you need to get a random name for the player, directly use the random name stored in S23 as the player's name, and use ets:next(T,{A1,random name 1}) to get the next data {A2,random name 2} to replace the stored data. And so on. When a random name is needed, use the stored data, use the ets:next method to get the data of the next name, and replace the currently stored data.
[0016] In some examples, step one further includes calling the method ets:new(T,[ordered_set,public,named_table,{keypos,1}] provided by erlang.
[0017] Compared with the prior art, the present invention has at least the following beneficial effects:
[0018] In the above scheme, when a random name is needed, the stored data is used, and the ets:next method is used to obtain the data of the next name and replace the currently stored data. Since the next method of the ordered_set type ets table is efficient and can ensure that the data obtained each time is unused, the efficiency of random names is greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated herein and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, further serve to explain the principles of the present disclosure and to enable those skilled in the relevant art to make and use the present disclosure.
[0020] Figure 1 Flowchart of a method for implementing efficient random player names based on ets tables for Erlang game servers; DETAILED DESCRIPTION
[0021] The following is a detailed description of a method for implementing efficient random player names based on the ETS table in an Erlang game server provided by the present invention in conjunction with the accompanying drawings and specific embodiments. At the same time, it is explained here that in order to make the embodiments more detailed, the following embodiments are the best and preferred embodiments, and those skilled in the art may also adopt other alternatives to implement some known technologies; and the accompanying drawings are only for a more specific description of the embodiments, and are not intended to specifically limit the present invention.
[0022] It should be noted that the references to "one embodiment", "an embodiment", "an exemplary embodiment", "some embodiments" and the like in the specification indicate that the embodiments described may include specific features, structures or characteristics, but not every embodiment may include the specific features, structures or characteristics. In addition, when a specific feature, structure or characteristic is described in conjunction with an embodiment, it should be within the knowledge of a person skilled in the art to implement such feature, structure or characteristic in conjunction with other embodiments (whether or not explicitly described).
[0023] In general, a term can be understood, at least in part, from its use in context. For example, depending, at least in part, on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in the singular sense, or can be used to describe a combination of features, structures, or characteristics in the plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey an exclusive set of factors, but can instead, depending, at least in part, on the context, allow for the presence of other factors that are not necessarily explicitly described.
[0024] It will be understood that the meaning of “on,” “over,” and “above” in this disclosure should be interpreted in the broadest manner, so that “on” means not only “directly on” something, but also includes the meaning of being “on” something with intervening features or layers therebetween, and “on” or “over” means not only “on” or “above” something, but also includes the meaning of being “on” or “above” something with no intervening features or layers therebetween.
[0025] Additionally, spatially relative terms such as "under," "beneath," "lower," "above," "upper," and the like may be used herein for descriptive convenience to describe the relationship of one element or feature to another element or features, as shown in the accompanying drawings. Spatially relative terms are intended to encompass different orientations of the device in use or operation in addition to the orientation depicted in the accompanying drawings. The device may be oriented in other ways, and the spatially relative descriptors used herein may be similarly interpreted accordingly.
[0026] like Figure 1 As shown, an embodiment of the present invention provides a method for an Erlang game server to implement efficient random player names based on an ETS table, comprising the following steps:
[0027] S1. Generate an ets table T of the ordered_set type in Erlang;
[0028] S2, loop to obtain all random names and perform the following operations;
[0029] S21. Perform a CRC32 operation on the random name + server ID to obtain an integer A (where the + sign is only a link symbol and does not participate in the CRC32 operation. The server ID is added mainly to make the names of different servers random and unordered);
[0030] S22, insert the data consisting of integer A and random name {{A, random name}} into ets table T;
[0031] S23, use the first method provided by ets to get the first data {A1, random name 1} and store it;
[0032] S3. When you need to get a random name for the player, directly use the random name stored in S23 as the player's name, and use ets:next(T,{A1,random name 1}) to get the next data {A2,random name 2} to replace the stored data. And so on. When a random name is needed, use the stored data, use the ets:next method to get the data of the next name, and replace the currently stored data.
[0033] It should be further explained in this embodiment that step 1 also includes calling the method ets:new(T,[ordered_set,public,named_table,{keypos,1}] provided by erlang.
[0034] The technical solution provided by the present invention uses the stored data when a random name is needed, uses the ets:next method to obtain the data of the next name, and replaces the currently stored data. Since the next method of the ordered_set type ets table is highly efficient and can ensure that the data obtained each time is unused, the efficiency of the random name is greatly improved.
[0035] The present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention. In order to make the public have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, but those skilled in the art can fully understand the present invention without the description of these details. In addition, in order to avoid unnecessary confusion about the essence of the present invention, well-known methods, processes, procedures, components and circuits are not described in detail.
[0036] A person skilled in the art will appreciate that all or part of the steps in the above-mentioned embodiment method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc.
[0037] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for implementing efficient random player names based on the ets table in an Erlang game server, characterized in that: The following steps are involved: S1. Generate an ets table T of the ordered_set type in Erlang; S2, loop to obtain all random names and perform the following operations; S21. Perform CRC32 operation on the random name + server ID to obtain integer A, where the + sign is only a link symbol and does not participate in the CRC32 operation. The server ID is added mainly to make the names of different servers random and unordered. S22, insert the data consisting of integer A and random name {A, random name} into ets table T; S23, use the first method provided by ets to get the first data {A1, random name 1} and store it; S3. When you need to get a random name for the player, directly use the random name stored in S23 as the player's name, and use ets:next(T,{A1,random name 1}) to get the next data {A2,random name 2} to replace the stored data. And so on. When a random name is needed, use the stored data, use the ets:next method to get the data of the next name, and replace the currently stored data.
2. The method for realizing efficient random player names based on the ets table in the Erlang game server according to claim 1 is characterized in that: The step 1 also includes calling the method ets:new(T,[ordered_set,public,named_table,{keypos,1}] provided by erlang.
Citation Information
Patent Citations
Subway data processing method and device
CN110493205A
Data reading and writing method and system based on multi-level cache, equipment and medium
CN111897847A