Wu haopin game core algorithm round 18 -- Wu haopin teaches you how to play Fruit Ninja)

Source: Internet
Author: User

I used to read the biography of Steve Jobs when I was in my sophomore year. "living is about changing the world." It adds a new world view to my college world view. It is a meaning of existence! (Note: This biography is not an official biography of Steve Jobs after his death.) Here we will talk a little bit about Steve Jobs. In my impression, Steve Jobs is a character similar to Qin Shihuang. He is attractive and has his own exclusive power. In the early days, I became more authoritative and gradually corrected my ideas in my later years. There was nothing wrong, as l said in the Death Note-no one could change the world! Because of this, the world will become so beautiful!

In his fifties, Steve Jobs has ruled the three major industries in the world. After years of hard work and early drug abuse, his health is also declining. However, what we can imagine is that the existence of Steve Jobs, an outstanding artist, is really just an example for the world today? I think, at least, the most valuable thing for me is that, after being expelled from his board of directors, he regained his position in the past day, this is really not something that ordinary people can do. My life has been getting short. For decades, how many people have been repeating like Steve Jobs? Steve Jobs is a great man and has no mistakes at all.

Now, Steve Jobs is out of sight, but it is undeniable that even a few years old Tom is still using a tablet iPad to cut fruit!

Here, we will display brilliant pictures, diverse items, and do not discuss various scoring rules and the final score output algorithms. Here we mainly aim at players and design two secondary AI:

(A) collision detection AI

Let's set a time. Assume that the time (fixed) is used to cut the fruit to the maximum value (assuming that the points of each fruit are equal, it does not matter if they are not equal, it is only after the geometric analysis, that the integral weights of each fruit are not equal ). In this way, there is a problem called collision detection, which is common in game algorithms. What is collision? For example, if a point in the area where the image is located is hit, it indicates a collision. Of course, this is acceptable, but in some games, it seems too "sharp", such as some drama games, but in some games, these are what must be followed-for example, this fruit ninja game and another game also require collision detection to make a keen response. I don't know what the name is, that is, two people control the two consoles to collide with the ball in the middle. Then, if you have a name, please reply and let me know!

In some games, the collision detection "sensitivity" does not need to be so strong. We can assume that there are two villains who can be used as two rectangles for approximation. Here is only a simple example, collision detection is a very complex technique. Here I will mention it in detail in the future ):

, Two rectangles, which are recorded as a and B, and intersect in one region. The ratio between this region and the area after rectangle A and B can be seen as the standard of collision detection, we can adjust according to the specific sensitivity. Of course, the more sensitive it is, the smaller the ratio!

Before we finish, we just defined the concept of sensitivity. But when we conduct collision detection, what should we do to make the shape of those fruits look like? Rectangle? Or a circle? Straight or square? According to different shapes, we will take different methods for processing.

For specific problems, we should make a specific analysis. For fruit ninja, these two approximation are pretty good. However, although the approximate form is different, the method is indeed the same, and it uses the calculation ry + scanning line algorithm. Here, I will implement the collision detection AI for this game in two different ways.

(B) AI produced by fruits

Logs
  • Wu Hao
  • Wu Hao's log
  • Current Log

Back to log homepage» newer/older edit | Delete | copy LinkWu haopin game core algorithm round 18 -- Wu haopin teaches you how to play Fruit Ninja)(Category: Wu Hao miscellaneous)

I used to read the biography of Steve Jobs when I was in my sophomore year. "living is about changing the world." It adds a new world view to my college world view. It is a meaning of existence! (Note: This biography is not an official biography of Steve Jobs after his death.) Here we will talk a little bit about Steve Jobs. In my impression, Steve Jobs is a character similar to Qin Shihuang. He is attractive and has his own exclusive power. In the early days, I became more authoritative and gradually corrected my ideas in my later years. There was nothing wrong, as l said in the Death Note-no one could change the world! Because of this, the world will become so beautiful!

In his fifties, Steve Jobs has ruled the three major industries in the world. After years of hard work and early drug abuse, his health is also declining. However, what we can imagine is that the existence of Steve Jobs, an outstanding artist, is really just an example for the world today? I think, at least, the most valuable thing for me is that, after being expelled from his board of directors, he regained his position in the past day, this is really not something that ordinary people can do. My life has been getting short. For decades, how many people have been repeating like Steve Jobs? Steve Jobs is a great man and has no mistakes at all.

Now, Steve Jobs is out of sight, but it is undeniable that even a few years old Tom is still using a tablet iPad to cut fruit!

Here, we will display brilliant pictures, diverse items, and do not discuss various scoring rules and the final score output algorithms. Here we mainly aim at players and design two secondary AI:

(A) collision detection AI

Let's set a time. Assume that the time (fixed) is used to cut the fruit to the maximum value (assuming that the points of each fruit are equal, it does not matter if they are not equal, it is only after the geometric analysis, that the integral weights of each fruit are not equal ). In this way, there is a problem called collision detection, which is common in game algorithms. What is collision? For example, if a point in the area where the image is located is hit, it indicates a collision. Of course, this is acceptable, but in some games, it seems too "sharp", such as some drama games, but in some games, these are what must be followed-for example, this fruit ninja game and another game also require collision detection to make a keen response. I don't know what the name is, that is, two people control the two consoles to collide with the ball in the middle. Then, if you have a name, please reply and let me know!

In some games, the collision detection "sensitivity" does not need to be so strong. We can assume that there are two villains who can be used as two rectangles for approximation. Here is only a simple example, collision detection is a very complex technique. Here I will mention it in detail in the future ):


, Two rectangles, which are recorded as a and B, and intersect in one region. The ratio between this region and the area after rectangle A and B can be seen as the standard of collision detection, we can adjust according to the specific sensitivity. Of course, the more sensitive it is, the smaller the ratio!

Before we finish, we just defined the concept of sensitivity. But when we conduct collision detection, what should we do to make the shape of those fruits look like? Rectangle? Or a circle? Straight or square? According to different shapes, we will take different methods for processing.


For specific problems, we should make a specific analysis. For fruit ninja, these two approximation are pretty good. However, although the approximate form is different, the method is indeed the same, and it uses the calculation ry + scanning line algorithm. Here, I will implement the collision detection AI for this game in two different ways.

(B) AI produced by fruits

Why do we need to study the AI produced by fruits? Because time changes, and that is the key. In (a), we have discussed how to cut the most fruit from a group of fruits at a certain time. However, the problem is that the whole process is moving. How do you know if you can cut the most at a certain time point?

This is a bit like a local optimal solution and a global optimal solution. This is a completely different concept. In our overall consideration, we must add the time t factor. Therefore, in this consciousness, we need to study the AI algorithms produced by fruits.

In fact, apart from random number generation, this can be converted into a pure physical problem (here, the collision detection is ignored and each fruit is divided into particles, because, the problem we are considering is not collision detection, so the focus of the problem can be shifted as appropriate.) This is a pure oblique throwing problem. We need to find a time point and draw a straight line to find the maximum value of the cut fruit and the corresponding time point.

Okay, as a trailer, that's it! I sincerely hope that you will be able to make a similar picture when you are playing Fruit Ninja in the future-an incredible attack !!!

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.