Loading...
 

PogamutUT2004


Ammo/Shot tracking

So, something that I have always found a bit annoying about GameBots is the way that there are actions to start and stop shooting, but not really to take a single shot. I know that in general this makes sense, because it corresponds to whether or not a human is holding down the mouse button or not, but it creates some difficulties.

Specifically, I would like to track when the bot actually takes a shot with weapons like the shock rifle, sniper rifle, etc (single shot weapons with a pause between shots), or at the very least track how much ammo the bot spends with any given weapon. The ultimate goal is to track some notion of bot accuracy.

Now, it seems like the most straight-forward way to do this is to remember how much ammo the bot previously had, and update this amount whenever a new Self message comes in. If the new ammo amount is less than the previous amount, then the difference between the two amounts can be counted as ammo spent.

However, this approach runs into problems given that the bot may also be acquiring new ammo for a gun it is using while shooting it, which brings up a question of exactly when certain updates occur. For example, if I track every ItemPickUp message to keep an eye out for both ammo and weapon pickups, I will be able to tell when new ammo is added for a gun. However, at what point does Pogamut actually update its internal data structures regarding new item pickups? If I access the Weaponry class from within a Listener for ItemPickUp messages, and check the amount of ammo that a given weapon has, will the amount be for before or after the currently picked up item is processed? If I try to track weapon ammo counts based on asynchronous messages like ItemPickUp, and I doomed to become out of sync with the ammo counts from Self messages?

Basically, it would be really nice if there were some kind of asynchronous message that indicated whenever ammo was depleted, but I can understand why this doesn't exist, since continued fire with certain weapons means that ammo is depleted continuously.

Basically, any recommendations you have for the easiest/cleanest way to track either ammo use or firing accuracy would be welcome.
Yeah, tracking AMMO is hard as you only get pri/sec ammo for CURRENT weapon through SLF (Self) message.

Have you checked Weaponry class that contains ammo tracking routines?

Have you checked WeaponDescriptor(s) for weapons? Class ItemDescriptors?

Cheers!
Jimmy
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 picking 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?
Hmm, I will have to disappoint you, such precise tracking is probably not possible ... may be I'm mistaken, but there is no such option within UnrealScript code to track "how much ammo was spent" and the problem with shooting&picking ammo is present there as well.

I will have to ask Michal whether he sees any option to support more precise tracking of ammo during shooting, but for now the troubles with shooting&picking ammos cannot be solved on the Java side.

Why do you need to track it so precisely? If it is about "single shot" action, we might try to provide the action for you in GameBots2004?

Best,
Jakub
It seems to be that the problem is more in GameBots than in Pogamut. There just aren't any messages that tell you when ammo is used.

I don't know if I *need* to track the ammo this precisely, but I know I need to be able to calculate the ratio hits over shots with certain weapons (i.e. the accuracy), and why wouldn't I try to do it correctly?

Basically, I'm evolving bots, and I want to have an accuracy objective. I know that stuff like this has been done before by others, and I've done it too, but I'm sort of refactoring some code and it just looked really nasty to be tracking ammo use the way I was ... I was hoping there would be a better way.

Things get even crazier when you have to track the notion of accuracy with a weapon like the flak cannon, since one shot by the bot can register multiple PlayerDamaged messages. I don't really know what the best way to track this is, but since we're talking about it I figured I'd point it out as another weird issue that is hard to deal with.
Hi!

First thing how to solve this was already mentioned by you - keep track of SELF message + take into account picking up new items.

Second thing how to solve this could be to store how long you were using the weapon - how much time has passed between startShooting and stopShooting commands. Each weapon has fixed refire rate. I guess it is even exported for most (all?) weapons in WeaponDescriptors. By comparing the time you were shooting with refire rate you would get rather precise estimate of how many shots were actually fired.

Apart from this GameBots right now do not track ammo spent.

best,
michal
 

News

News RSS RSS feed for News link



Pogamut

Quarterly RSS RSS feed for quarterly reports

Acknowledgement

This work is supported by GA UK 1053/2007/A-INF/MFF (2007-8), GA UK 351/2006/A-INF/MFF (2006-8), the Ministry of Education of the Czech Republic (grant MSM0021620838) (2008-9), by the Program "Information Society" under project 1ET100300517 (2006-9), and the project Integration of IT Tools into Education of Humanities (2006-8) and by the project CZ.2.17/3.1.00/31162, which are financed by the European Social Fund, the state budget of the Czech Republic, and by the budget of Municipal House Prague.