Gun Accuracy Leaderboard Calculation - lua

I'm working on a leaderboard system for Garry's Mod and I have run into a slight problem to do with one of the statistics I'm tracking.
I am tracking a lot of statistics including the number of bullet's shot and the number of bullets that actually hit, and am using that information to work out the accuracy of the player like so:
(gunHits / gunShots) * 100
The problem with the way I'm doing it is that people can go to the top of the leaderboards by just logging on and shooting one bullet and hitting someone with it, therefore having an accuracy of 100%.
Is there any way I can get around this?

You could set a minimum amount of shots fired required to be ranked. I think 100 would be a good number.
On a side note you don't need to put any parenthesis on the operation since divide and multiply are operators with the same priority and they are already in the right order. It would've been necessary if you were doing it this way.
100 * (gunHits / gunShots)

Related

Distribution chart not showing bars in AnyLogic

So I've set up a simulation to measure the time it would take for a ship to get from houston to sydney. I put a time measure start and end between the move to block and made a distribution chart using a histogram. But when I run the simulation, the bars don't show up. The numbers are still there, and the rest of the histograms are working properly, but no bars on this particular one.Here is a screenshot of the simulation, histogram in question is the second one.
#Emile Zankoul
Can't be 100% sure why.
Try to copy and paste one of the two histograms that work then change the time measure name in the new histogram's properties.
I think most likely, you have "Show PDF" unchecked:
Make sure it is checked.
After reviewing the model I realized that the total measured duration is over 1,000,000 seconds. It seems there is a limitation to the maximum value for the histogram. So to resolve this, change your model time units from seconds to anything bigger (e.g. minutes, hours, etc.).

iPhone Accelerometer Values

My question is about the iPhone accelerometer. Does the accelerometer measure acceleration or movement of the iPhone? What I mean is if I hold the iPhone and go from 0mph to 60mph, I would expect the measure of acceleration to increase in value from 0 to 60, but once I reach 60, I expect the value to return to 0 since I am "no longer accelerating" but am moving at a constant speed. Now if the accelerometer measure motion, I would expect it to register 0 to 60 and continue to provide a change in value as I move forward at 60mph. Sorry, I looked at a few books, programmed some code (values seemed to small to give a recognizable result over short distances or speeds), and a lot of web searches, and I am trying to get an answer to this question.
Thanx!
A couple of points:
The accelerometer never reads zero because gravity is always with us and is an acceleration (and a good thing too). If it ever reads 0 you are in deep doo-doo - you have been cast adrift in space, or else you are in free-fall plunging towards the ground.
When you go from 0 to 60, acceleration does not "register 0 to 60". That isn't what acceleration is. It isn't speed; it's the rate of change in speed. Is this a Lamborghini or a VW Bug? They both go 0 to 60 but the acceleration might be very, very different.
You might need to read a little physics textbook here, but to make it simple, think of it as how hard you are being pressed back against the car seat! If you are not being pressed back, thrown from side to side, etc., then your horizontal acceleration is zero even you are going 100 miles per hour.
I think that the following links can clarify what the accelerometer of the iPhone does, and does not:
http://electronics.howstuffworks.com/iphone-accelerometer.htm
http://www.engadget.com/2012/05/22/the-engineer-guy-shows-how-a-smartphone-accelerometer-works/

Determining the height of iPhone from ground level

I am making an ios application in which it is to be determined that wether the person is sitting or standing.I wanted to know that if there is any method to find automatically that the person is sitting or standing like we can get the height from sea level with the help of CLLocation Manager.So like this can we get the height of iPhone from the ground level in any way?
This is not possible for the following reasons:
The phone can tell you its height above sea level, the accuracy of which has a larger margin of error than the difference between a sitting and a standing person
Even if 1. did not apply, and you knew the precise height of the ground at your current location and the additional height of the phone, this would still be meaningless, as it doesn't take into account buildings, the height of the person, their posture and so forth.
You may have more luck using the motion coprocessor on newer models, you could assume that a standing person moves about more than a sitting person, or something. Or accelerometer readings to detect changes of position. But altitude is definitely not the way to go.
You cannot find out by altitude if a person is standing or sitting.
Accuracy of GPS is much to low. Which is at best 6m for altitude.
But if you are really clever you could try other approaches:
-Use the acceleratoin sensor: A standing person might move a bit more than a sitting one, or moves different. [Sorry, I did not saw that user jrturton has written the same, bit this indicates that this might work]
Sitting persons often type on the keyboard. You can measure that with the accelerometer, by frequence analysis after doing a FFT.
Walking persons: A person that walks does not sit: Detect typical walking steps, with aclerometer or even with an ios API that is new in ios7. (I remeber there is a step counter)
These all are no accurate detections, but may raise the probability to detect a sitting person-.
If you get that to work, I will have major respect. Post an update if you succeed.
Expect 2,5 to 3,5 fulltime working month to get that to work (in some cases)

Filtering out surplus GPS track points

Im writing an app that functions much like RunKeeper. Im tracking CLLocations every x seconds to figure out the total distance.
However, if the user moves on a really straight freeway for 10 minutes (Think USA), there is no point in saving 60 tracking points.
What kind of filtering do you use in your apps to reduce the number of track points?
Im thinking about checking the course delta from the last good position and discarding the new posotion if course hasnt changed by more than x degrees. There would of course also be a longer time limit to get a point every now and then anyway.

Cocos2d 2.0 - 3 numbers on the bottom left?

I'm having a problem that I'm not sure how to solve.
In cocos2d 2.0 , the second number on the bottom left drops to a low number like 0.002 and causes lag in my game!!
The second number is the 'Frames Per Second's Milliseconds', or the amount of time it takes to go to the next frame. I got this info from a question similar to mine, here is a link to that question:
Cocos2d 2.0 - 3 numbers on the bottom left
The games FPS's Milliseconds usually runs at about 0.016 or 0.021 and there is no lag.
Shouldn't it run smoother at numbers as low as 0.002?
How can I stop this lag?
Is there anybody that knows enough about cocos2d to help me out?
When your app runs really, really slow (around 10 fps or less) the milliseconds display is no longer accurate and will display a very low number.
You need to find out what's causing the drop in framerate. If the number of draw calls is high (100+) then your problem is that you're rendering too much and/or inefficiently (use sprite batching).
If the number of draw calls is reasonably low (no more than 50) then your problem is not the rendering but your own code. Possibly some time consuming (inefficient?) algorithm or frequently loading/unloading objects and/or data (files), those are the most common cases.
How are you observing/measuring this 'lag' ?
If you are reporting this based on running on a simulator, please go check on a device. Simulator numbers are meaningless. Btw, the number does not CAUSE lag, the number is the result (measure) of resource consumption by the app , ie low FPS is caused by laggy software, not the reverse.

Resources