Game world scenario (Hu Yi)

Source: Internet
Author: User

KOBE: "Do you know what Los Angeles looks like at a.m ?"

IT male: "Oh, I am still working overtime"

KOBE: "... Oh, that's okay."

This section reflects the hard work that programmers in China cannot say. I also saw the 4 o'clock scene at the company yesterday, so today, we can only free up time at home to sort out things that we don't have to sort out at ordinary times. It's just that we're not awake.

When I got up like a dog in the morning, I browsed the hard disk aimlessly. After resisting the temptation of mysterious folders, I turned out the wow video I had collected a few years ago, once I opened it, I watched it for more than an hour. After reading it, I would not help but lament the time passing by. The previously decadent wow scenes are vivid. It was really a special experience, however, in retrospect, there was no sin or regret, but more warmth and nostalgia. It may have been a long time, but instead, it had a crush on the virtual world. I have also thought about why wow had such a plot and put aside the advantages and disadvantages of the game products. Maybe it was because there were not many conflicts of interests in the domestic game environment, shi Yuzhu's free online game model has not swept across the Chinese Mainland. On the basis of relatively fair time consumption, everyone is helping each other and playing games together. This is really a highlight of the game's life, it's a bit unrealistic, but happy, and will never be experienced in the future.

======================================================= ========================

The title reminds me not to talk about it any more, or the audience will complain that it has not entered the subject. I have been thinking about the game world scenario. Different companies and projects are all thinking about how to start a wow world, this is also the reason why I spoke about wow. Technically speaking, wow has brought too many new technologies to the Chinese market-the true sense of the world, and the phase technology that Yunfeng once mentioned, and the popularity of lua

In my personal experience, there are several difficulties to overcome in a world scenario:

1) Search for nearby entities

2) AI map pathfinding

3) loads of computing entities on different maps

Difficulty 1:

For a general 2D flat game, you can divide a map by a certain size of blocks (partition), and find nearby entities to find nearby units, the data structure that can be used here can be quad-tree. If it is a 3D scenario, it will be an octree ), after finding a nearby unit, find the required entity in each unit (for example, according to a certain radius distance)

Difficulty 2:

In some early 2D flat games, A map is divided into square squares. Similar to this type of map, A * algorithm is used directly to obtain the path.

In some scenarios where map units are fine-grained and coordinate ranges are relatively wide (for example, many MMO RPGs), the preceding method cannot be used, because if you are a game server, A large number of search requests occupy the entire CPU resource, resulting in the external capability of the entire service being 0. Our solution is to use waypoint to set up key points on the map. Before each operation of A *, we need to find anchor as the starting point of the * algorithm.

For 3D scenes, waypoint will also become a bottleneck, because the terrain of 3D scenes is much more complex than that of 2D terrain, and the coordinate system is also one-dimensional, which means a larger range, another drawback of waypoint is that it must be manually set and the path directly obtained by pathfinding is tortuous. It must be processed smoothly. In 3D scenarios, NavigationMesh technology is generally used to solve this problem, I will not describe the details of NavigationMesh, But I can simply say:

It can use an automatically generated algorithm to automatically divide a map into convex polygon.

On the basis of a convex polygon, pathfinding becomes simple. First, any two points in a convex polygon can be accessible, we can quickly calculate the path from a convex polygon in units, get the link of a convex polygon node, and then calculate the path inside the convex polygon.

PS. if this is the first time you have heard of NavigationMesh technology and may not be able to understand what I have said above, please google on your own. It is worth mentioning that, if there is A dynamic obstacle (such as A rolling stone), real-time dynamic polygon cutting is required, it has been widely regarded as the most suitable game map pathfinding algorithm. There are also many optimization schemes, and there are also many methods that allow the server to respond to the client as soon as possible (such as the three steps of classical generation: shortcut path-complete path-correction path), which can be viewed online.

Difficulty 3:

Generally, the main logic services of game servers are divided by game functions. For example, when the data volume reaches a certain scale based on different maps, these servers become bottlenecks and difficult to expand.

A theoretically feasible solution is to divide a part of a map into an abstract unit (for example, the polygon mentioned above ), all logical servers dynamically load these units on the map at runtime.

For example:

Host A-Map

Host B-Map B

Host A runs Map A at first.

At first, Map B was running on Host B.

However, there may be too many server load instances (players) on Map A, causing the load of Host A to reach the bottleneck, while the load on Map B is not large, so dynamic adjustment can be made at this time.

The adjustment process is as follows: merge some Convex Polygon on Map A. After the merge, it is still A convex polygon (Map Aa) all information and the above strength information are synchronized to Host B, and then Host B merges it locally Map B + Map Aa = Map (B + Aa ), then, the hosts on both sides need to re-cut the Map to ensure the NavigationMesh structure.

This process requires a certain performance cost, but only on the Network (Data Synchronization) or on CPU computing (re-cutting and merging), so when dynamic adjustment is required, you need to carefully consider it, it should be particularly noted that the process of determining dynamic adjustment is an independent observer, and it requires a relatively fair guideline to supervise every game/map server

Another problem is the processing of map boundaries. Interactions between players on map boundaries (transactions, battles, etc ), the data of one player needs to be synchronized to the host where the other player is located for processing, and then synchronized back. This synchronization process may cause latency improvement, of course, the client should try its best to handle the simulation results, instead of waiting for service response synchronously.

For games in big world scenarios, maybe they are no longer mainstream games, but they have always been technical challenges. Maybe in the future, I may start to develop such a demo, to fulfill your dreams over the years.

Well, let's get down to it first. Although there may be a sequel according to the title rhythm, I do not rule out the possibility of such an article, after all, it's just hu Ke, who is on the rise today...

 

In addition, you are welcome to discuss this in my personal blog: www.cppthinker.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.