Last active
December 29, 2015 19:04
-
-
Save Lauler/85f1f6599cb1f9c3d136 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
tickrate = 100 | |
firerate = 0.1 # ak47 firerate (seconds) | |
seconds = 2 # nr of seconds to run spraying simulation | |
def inacc(): | |
with open('CSinaccuracypre2.csv', 'w') as file: | |
ticks = 0 | |
inaccuracy = 7.8 | |
time = 0 | |
recovery_time_stand = 0.46 | |
file.write("Inaccuracy" + "," + "Time" + "\n") | |
for x in range(0, 19): # 0.2s delay before simulating first shot | |
file.write(str(7.8) + "," + str(x/100) + "\n") | |
while ticks < seconds*tickrate: | |
new_inaccuracy = inaccuracy * math.exp(- time / (math.log10(math.e) * recovery_time_stand)) | |
# Updates inaccuracy every 0.1 sec when AK-47 fires | |
if ticks != 0 and ticks % int(tickrate*firerate) == 0: | |
# file.write(str(inaccuracy) + "," + str(ticks/100) + "\n") | |
inaccuracy = new_inaccuracy | |
inaccuracy += 7.8 | |
time = 0 | |
file.write(str(7.8 + new_inaccuracy) + "," + str(ticks/100 + 0.19) + "\n") | |
time += 1.0/tickrate # time since last fired shot | |
ticks += 1 | |
inacc() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment