| Nowadays,most of the games are involved with artificial intelligence.Some of the Non-Playable Characters(NPC)require the use of their own memory to store and achieve some tasks in their virtual environment.How to organize these data in a queue and read them from a queue is a problem that we will encounter in every project.This experiment will setup a virtual environment with Unity3 D.NPC will be assigned with only one job,which is to complete different tasks as much as possible.The focus on this experiment is to observe the performance when NPC’s queue algorithm is set to four different types: FIFO,LIFO,Random and Closet.In order to get an accurate evaluation,the experiment especially defines the Throughput,Latency and Fairness as the performance rating metrics.Each queue will be tested with ten rounds of three different task release frequencies.All the test results will be exported to software for analysis.After analysis on significant difference and calibrating the F value,results show that the P value is less than 0.01,which proves that the experiment has statistical significance.According to these analyses,we know the Closest queue can get the maximum number of complete tasks,but Random queue has better fairness and LIFO queue has less average waiting time.Based on these conclusions,in order to balance the three performance rating metrics,we design and implement a new queue type: MFQS(Multilevel Feedback Queue Scheduling).The new queue algorithm can be better integrated with the advantages of the above four basic queue algorithms,and it divides tasks into different priority-based groups and adjusts the task priority according to the dynamic feedback.With this mechanism,the new algorithm has the ability to handle more complicated situation.After the same condition test,the result proves that it has better comprehensive performance.Besides the performance research on each individual NPC,we also provide a solution to solve the collaboration problem when system has multiple NPCs.We believe that our experiment results and conclusions can help the developers to better use the memory queue to handle multitasking situation,to reduce the developments’ effort,and to improve the efficiency and playability of the game.The new queue algorithm can not only be applied to the field of the game,but also have certain application prospects of the traditional industries. |