Skip to content

Instantly share code, notes, and snippets.

@Lauler
Last active December 29, 2015 19:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lauler/85f1f6599cb1f9c3d136 to your computer and use it in GitHub Desktop.
Save Lauler/85f1f6599cb1f9c3d136 to your computer and use it in GitHub Desktop.
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