Some tactics on "automatic generation" (1)

zhaozj2021-02-16  63

Unlike the stand-alone game, the general online games require a lot of resources, such as skills, items, tasks, what these things are impossible to complete "handmade", which is extremely stupid, we generally use a lot of small tricks To "automatically" to generate a lot of, no repetition.

Suppose you are doing such a online game now, it requires a lot of equipment to meet the players' collection desire, then this automatic generation system may be like this.

First of all, let's do some hypothesis, suppose your game is like this. The player role has many properties, the list is as follows:

Strength agility, physical attack, defense, HP MP

Hey, the actual game should be much more complicated than this, but we just give an example to explain that this thing above is enough.

The equipment in this game looks like this. For example, there is a stuff called the sword called the fire. When the player checks it, it will find that the above is written:

Power 10

Physical strength 5

Attack power 20

Oh, great, this is good, the other players will start to find this sword immediately, they find that they can get this sword of the fire, so they started to act.

Wait, do you have all the swords of all players? That's too hard, we have to think about it to change.

First we do something on the value. We may wish to stipulate that the sword of the fire fell out of the brothers, the value of the attack power is random, such as randomness between 16 to 25. So, the sword of the player will have 10 versions, and the attack power is from 16 to 25.

Wait, maybe you will say, the probability of these 10 versions is equal, all 1/10, maybe for some kind of game balance, I need more control, for example, I hope that the probability they appear Is such that:

16 17 18 19 20 21 22 23 24 25

0.055 0.065 0.075 0.085 0.095 0.105 0.115 0.125 0.135 0.145

The programmer feels too much trouble, so you decided to use a function to unify the relationship between probability and attack power, f (x) = (x-15) * 0.01 0.045, um, now look it work It is good.

We will immediately involve a very important issue, that is, what is the degree of what you need to do when designing this automatic generation mechanism.

Our goal is to let the machine to generate, so the benefit is to reduce the workload of "handmade", but it is at the expense of losing certain control. What extent to do, is a problem that needs to be better. In the above example, it can be considered that in most cases, the sword of 10 versions will appear with the same probability, and we have been able to meet our requirements, we do not need to get more control, and go manually The probability of each situation, or what formula is developed, so that we actually increase our "handmade" workload, to exchange the control of the system.

Please don't entangle the specific example I have lifted, you can say that it is necessary to use formulas. I just want to explain, "degree" is very important, please consider the specific situation you face, you will pay yourself.

Ok, then we continue to say.

Simple change in value is not enough to meet the needs of the player, they quickly discovered that in any case, the sword they got will always be in 10 versions, they have fooled feelings, this is not wonderful. We can further, do some articles on the data items, such as: Some versions of the sword of the fire only have an attribute:

Attack power 25

And another version of the fire sword has multiple properties:

Attack power 18

Power 5

Physical strength 10

MP 20

Well, let's consider how to draw a set of rules, allowing the system to automatically generate a sword with different data items.

We intuitively think of how many properties use a data will appear, but you see, we will always let the "attack power", so we may wish to divide the items into two Category: basic items and additional items, and we have to add this data to describe how many additional items will appear, and this time we give a table to illustrate their respective probability.

It seems that we have made a "template" of a sword of the fire, which can generate a large number of non-repetitive swords in accordance with certain rules.

Fire sword template

Basic item minimum maximum

Attack power 16 25

Additional item

Power 5 10

Physical force 8 16

HP 10 25

MP 15 30

Probability table

0 1 2 3 4

0.5 0.2 0.15 0.1 0.05

According to our rules, the sword with the probability of 0.5 will only have an attribute of the attack power, and only 0.05 probability will drop a sword with 5 attributes (1 base item, 4 additional items) ). There is a probability of 0.15 to fall out of 2 additional flavors.

Well, we also need to develop a rule. When you decide to have two additional items, should you take two items in 4 additional items? We can simply think that each of the probability of additional items is the same, then two additional items will be selected, and there will be 6 cases, that is, the probability of these 6 cases is all equal, all of which are 1/6 .

It seems that our mission has been completed, this automatic generation mechanism seems to work very well, we only need a small amount of work (fill in a template), you can generate a lot of swords of different fires (how many you can calculate it yourself Put).

But from intuition, I don't satisfy this thing, I always feel less, think about it, I think the thing used to describe how many additional items is a little feet, and then add a probability table, and They will make the probability that each data item appears is the same, I decided to do some small changes, the modified template after the change looks like this:

Fire sword template

Basic item minimum maximum

Attack power 16 25

Additional probability power 5 10 50%

Physical force 8 16 30%

HP 10 25 20%

MP 15 30 5%

We add a "probability" to each additional item, and the generation rules are also changed: each additional operation is performed, and a random number is taken between 0 ~ 1, if it is greater than the probability, it is generated. The sword of the fire uses this attribute.

Compared with the changes, this approach has little increase in the future, but has obtained more system control, I am very satisfied with this change.

Ok, this example is played, and our automatic generation system is also completed.

Compared with the examples in an actual game project, this example is too simple, and the actual situation will be much more complicated than this. Everything needs to be considered. However, I hope that readers receive 3 cognations by reading this article: First, designing some "automatic generation" system in your game is very necessary, you can't fully complete all things well; second, master " "" Is a very important thing, making a suitable choice is not very easy, this requires rich experience and good topping; again, this paper simply demonstrates a next iterative design method, how to make Improve the designs of the previous step, making it getting more and more elegant.

Also: I have wanted to attach a Python code to demonstrate this automatic generation system. Later, I think it may take up a lot of layout. In addition, I am not willing to show my bad programming level, but if you want more Intuitive understanding of this automatic generation mechanism, I am happy to provide you with some low quality code.

转载请注明原文地址:https://www.9cbs.com/read-17241.html

New Post(0)