From b1cf03f130e2b2c87b3adb36e0a8ece51fc1ef4e Mon Sep 17 00:00:00 2001 From: kulisak12 Date: Wed, 14 Sep 2022 10:31:19 +0200 Subject: [PATCH] =?UTF-8?q?Strategick=C3=A1:=20Opravit=20centrov=C3=A1n?= =?UTF-8?q?=C3=AD=20kopc=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/gen_hills | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/server/bin/gen_hills b/server/bin/gen_hills index 1d11b06..accd690 100755 --- a/server/bin/gen_hills +++ b/server/bin/gen_hills @@ -22,15 +22,9 @@ def main(): ) # make it less likely for hills to be close to home bases - home_distance_tile = 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) + distance_decay_tiling = np.fromfunction(distance_decay, args.size, dtype=np.float32) - 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] config = { "width_per_team": args.size[0], @@ -41,7 +35,12 @@ def main(): 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: