Browse Source

Strategická: Opravit centrování kopců

master
David Klement 2 years ago
parent
commit
b1cf03f130
  1. 17
      server/bin/gen_hills

17
server/bin/gen_hills

@ -22,15 +22,9 @@ def main():
) )
# make it less likely for hills to be close to home bases # make it less likely for hills to be close to home bases
home_distance_tile = np.fromfunction(distance_decay, args.size, dtype=np.float32) distance_decay_tiling = np.fromfunction(distance_decay, args.size, dtype=np.float32)
home_distance = np.sum([
home_distance_tile,
np.flip(home_distance_tile, axis=0),
np.flip(home_distance_tile, axis=1),
np.flip(home_distance_tile, axis=(0,1)),
], axis=0)
hills = np.where(noise - home_distance > args.threshold, "x", ".") hills = np.where(noise - distance_decay_tiling > args.threshold, "x", ".")
rows = ["".join(row) for row in hills] rows = ["".join(row) for row in hills]
config = { config = {
"width_per_team": args.size[0], "width_per_team": args.size[0],
@ -41,7 +35,12 @@ def main():
def distance_decay(x, y): def distance_decay(x, y):
return np.exp(-np.sqrt(x*x + y*y) / args.safezone) # calculate distance from home base
dx = x - args.size[0] // 2
dy = y - args.size[1] // 2
distance = np.sqrt(dx*dx + dy*dy)
# use exponential decay
return np.exp(-distance / args.safezone)
# Source: # Source:

Loading…
Cancel
Save