Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mmv
Created January 17, 2013 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmv/4552415 to your computer and use it in GitHub Desktop.
Save mmv/4552415 to your computer and use it in GitHub Desktop.
Graph ingress xmp burster damage according to attack position and level, and resonator placement
# graphs total damage of a XMP burster
# according to blast position
# i'm using pylab (from ipython)
# but python + numpy + matplotlib should do it
from pylab import *
from math import sin, cos, pi
# deployed resonator configuration
resonator_distance = [35] * 8
# XMP burster type
xmp_level = 1
# (source http://ingressfieldguide.com/content/xmp-bursters-attacking-enemy-portals )
# key : (range, power)
xmp_table = {
1: (50, 150),
2: (75, 300),
3: (100, 500),
4: (125, 900),
5: (150, 1200),
6: (200, 1500),
7: (300, 1800),
8: (400, 2700),
}
# graph config
g_granularity = 1.0
g_range = 55.0
# get info on burster according to level
xmp_range, xmp_power = xmp_table[xmp_level]
# convert the distance in coords
resonator_coords = [(d*sin(t),d*cos(t)) for d,t in zip(resonator_distance, [pi*a/4 for a in range(0,8)])]
def total_attack_power(x,y):
""" takes two axis and returns a grid (array of arrays)
with the total damage an attack on that point would cause on
all resonators """
ret = []
for y1 in y:
scores = []
for x1 in x:
r_scores = []
for x2,y2 in resonator_coords:
distance = (((x1-x2)**2)+((y1-y2)**2))**0.5
# this is the attack power formula
damage = (max(0, xmp_range - distance) / xmp_range)**2 * xmp_power
r_scores.append(damage)
scores.append(sum(r_scores))
ret.append(array(scores))
return array(ret)
def find_maxs(x,y,z):
cur_max = -1
maxs = None
xi = 0
for xv in x:
yi = 0
for yv in y:
val = z[yi][xi]
if cur_max < val:
maxs = ([xv],[yv])
cur_max = val
elif cur_max == val:
maxs[0].append(xv)
maxs[1].append(yv)
yi += 1
xi += 1
return maxs
# make these smaller to increase the resolution
dx, dy = g_granularity,g_granularity
x = arange(-g_range, g_range+dx/10, dx)
y = arange(-g_range, g_range+dy/10, dy)
X,Y = meshgrid(x, y)
Z = total_attack_power(x, y)
maxs = find_maxs(x,y,Z)
ax = subplot(111)
pcolor(X,Y,Z, cmap=cm.RdBu, vmax=(Z).max(), vmin=(Z).min())
colorbar()
axis([-g_range,g_range,-g_range,g_range])
ax.set_title("Distribution of total damage with L%d XMP" % (xmp_level,))
# mark resonators in graph
plot([c[0] for c in resonator_coords],[c[1] for c in resonator_coords], 'o')
# mark maximum points in graph (this is quite inaccurate)
plot(maxs[0],maxs[1], 'o')
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment