Rating Systems

Something I've found immensely useful for prototyping recently are simple rating systems. After using them for everything from targeting to AI I realised I hadn't written about them here.

Two simple examples - say you're writing something that targets an NPC in front of the player, and you want to find the most central target - not too far forward or back, left or right. You simply assign a rating to each NPC based on say, screenspace (or a point projected in front of the camera or player) - 1 being dead centre and 0 being the edge of the boundary that you deem acceptable. Do this for X and Y and then multiply them together and pick the highest one. (Or add them if your ratings aren't in the range 0 - 1)

This starts getting really useful when you want to add in other variable, giving npc's a higher score if they are.. facing away, stumbling, running at you, a bigger enemy etc etc. 

Another example would be prototyping AI - To prototype behaviours for new, distinct npc classes, It's quite a nice trick to scatter points around the map and have them rate their own eligibility for an NPC to move to based on... LOS to the player, height, nearby enemies etc. Then again the NPC simply moves to the highest rated point. 

An incredibly simple but, massively useful pattern.