About the use of various algorithms in game production and development【0】

Many people didn’t know the actual effect of these algorithms on development when they first learned algorithms. Next, I will roughly talk about the application scenarios of algorithms in game development based on my own understanding.

Bubbling algorithm The
bubbling algorithm is a common algorithm for arrays. It allows the adjacent numbers in the array to be compared and combined with whether the conditions are converted, so as to achieve the effect of sorting the array.
For example, these nine numbers, 1, 2, 3, 4, 5, 6, 7, 8, and 9. If you want to change to descending order, you can first compare the two numbers 1, 2, 1 is smaller than 2, exchange positions , The array becomes 2,1,3,4,5,6,7,8,9, again compare 1 and 3, 1 is smaller than 3, exchange positions, at this time the array becomes 2,3,1 ,4,5,6,7,8,9, and so on, until it becomes 2,3,4,5,6,7,8,9,1, perform the above operation on 2 until it becomes 9,8 , 7, 6, 5, 4, 3, 2, 1.

So, since bubble sort can sort arrays, is there a scenario that is very suitable for this method? Of course there is.
Backpack is a common way to play role-playing, sandbox games, but once there are more items, the items will be messy, reducing the efficiency of the game. Then, we can use bubble sorting combined with array classification and sort these items according to their item id. Sorting, is that more pleasing to the eye?

Guess you like

Origin blog.51cto.com/15092366/2633851