[Pogamut-list] Ammo/Shot tracking

jacob.schrum pogamut-forum at diana.ms.mff.cuni.cz
Tue Jan 22 04:25:52 CET 2013


Re: Ammo/Shot tracking

Author: jacob.schrum

Ok, so Weaponry will allow me to check the current ammo for any weapon in the bot's inventory, but this still doesn't resolve the timing issue.

Let's say that on every call of the logic() method I check the ammo for any weapon or weapons. I can know for certain what the amount of ammo is in comparison with the last time I checked it, but I can't be certain what the cause of the differences are unless I do a lot of other special case checks and also get listeners involved. What I ultimately want to know at the end of the match (or at any time really) is how much ammo has actually been fired by the bot.

So, let's say that lastShockAmmo is a variable that stores the shock rifle ammo from the last time I checked, and shockAmmoUsed tracks how much ammo of that type has been used by the bot throughout the course of all of its lives in a single match. What all do I need to do?

The most obvious thing to do first is to set lastShockAmmo to 0 every time the bot spawns. Now, I'm using Weaponry to check the current amount of shock rifle ammo on every call to logic. If the current ammo is less than lastShockAmmo, then this means that the amount of the difference is the number of shots fired by the bot using the shock rifle (if we assume for simplicity's sake that secondary fire isn't being used). This difference can be added to shockAmmoUsed.

However, what if the current ammo is greater than the lastShockAmmo value? Well, then the bot must have picked up either shock core ammo, or (if weapon stay is off) another shock rifle. However, this is where things get really annoying, because the amount by which lastShockAmmo is greater than the current ammo could be many different things requiring special handling. 

If the amount of increase is exactly what you would expect to receive from either a shock core or a new shock rifle, then it means the bot picked up a new item and wasn't firing at the time, so you can just set lastShockAmmo to the new current value. However, what if the amount of the increase is not one of these values? If the amount of increase is less than the smaller of these two values, then I guess it means that the bot was shooting while picking up the new ammo, and so some accounting needs to be done to figure out how much to add to shockAmmoUsed. What if the bot fired a number of shots that exactly equals the difference between these two numbers? I don't know if this is possible, but if it is, then I wouldn't know how to detect it. Is it possible that in the time it takes between logic cycles the bot could have received and processed two Pickup messages, as a result of picking up two different ammo packs? What if the bot was shooting while almost at full ammo, and pi
 cking up new ammo? Is it possible in this case for the expended ammo to be masked by the newly acquired ammo?

The Weaponry class and various WeaponDescriptors are useful, but I don't think they directly address my problem. I was just wondering if I have to deal with all of the issues I mentioned above, and settle for some degree of uncertainty? Or is there a way to actually know exactly how much ammo the bot uses? Or perhaps a cleaner, easier way to track this info than what I am proposing?

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=1114&post_reply=1#form>




More information about the Pogamut-list mailing list