changeset 1:5492efd60e2c

first prototype + updated art sheet
author ark
date 2026-10-18 14:50 +0200
parents 7af9dd4e2595
children 3dd5b745fa08
files art/0418_261018145916_001.jpg config/game.toml config/routes.toml doc/roadmap.md game/assets/b0.png game/assets/b1.png game/assets/b2.png game/assets/b3.png game/assets/c0.png game/assets/c1.png game/assets/c2.png game/assets/c3.png game/assets/hpb.png game/assets/hpb_empty.png game/assets/hpm.png game/assets/hpm_empty.png game/assets/m0.png game/assets/m1.png game/assets/m2.png game/assets/m3.png game/assets/m4.png game/assets/map0.jpg game/assets/map1.jpg game/assets/map2.jpg game/assets/map3.jpg game/assets/p0.png game/assets/p1.png game/assets/p2.png game/assets/p3.png game/assets/t0.png game/assets/t0_2.png game/assets/t0_3.png game/assets/t0_4.png game/assets/t0_5.png game/assets/t1.png game/assets/t1_2.png game/assets/t1_3.png game/assets/t1_4.png game/assets/t1_5.png game/assets/t2.png game/assets/t2_2.png game/assets/t2_3.png game/assets/t2_4.png game/assets/t2_5.png game/assets/t3.png game/assets/t3_2.png game/assets/t3_3.png game/assets/t3_4.png game/assets/t3_5.png game/data/config.js game/data/maps.js game/index.html game/js/assets.js game/js/game.js game/js/input.js game/js/main.js game/js/map.js game/js/monster.js game/js/projectile.js game/js/render.js game/js/tower.js game/js/ui.js game/js/util.js game/js/wave.js game/style.css tools/build.py tools/images.py tools/masks.py tools/preview.py
diffstat 69 files changed, 4660 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file art/0418_261018145916_001.jpg has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/game.toml	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,549 @@
+# game settings. tools/build.py checks this file and writes game/data/config.js.
+#
+# units: distances in map pixels (pixels of the map image as scanned), times
+# in seconds, speeds in map pixels per second.
+#
+# source markers, as in doc/balance.md:
+#   notes    from the original design notes or drawing sheet, decided
+#   decided  decided after the notes were written
+#   guess    a starting value for playtesting, expected to change
+#   derived  calculated from other values
+#   proto    chosen while building the prototype, not in the docs
+#            (see "prototype notes" in doc/roadmap.md)
+
+
+[scale]
+map = 1.0           # notes
+sprite = 0.25       # notes ("maps scaled approx 400%"), towers, monsters, projectiles
+coin = 0.4          # guess, 0.25 makes them about 10 pixels
+hp_bar = 0.25       # guess
+
+
+# monsters. coins: regular monsters drop 0.2 coins per hp, bosses 1 coin per
+# hp (derived). hit_radius is a share of the scaled sprite's smaller side.
+
+[monster.m0]
+hp = 5              # notes
+coins = 1           # notes
+speed = 35          # guess
+
+[monster.m1]
+hp = 10             # notes
+coins = 2           # notes
+speed = 40          # guess
+
+[monster.m2]
+hp = 15             # notes
+coins = 3           # notes
+speed = 45          # guess
+
+[monster.m3]
+hp = 20             # notes
+coins = 4           # notes
+speed = 40          # guess
+
+[monster.m4]
+hp = 30             # notes
+coins = 6           # notes
+speed = 35          # guess
+
+[monster.b0]
+hp = 30             # notes
+coins = 30          # notes
+speed = 25          # guess
+boss = true
+
+[monster.b1]
+hp = 50             # notes
+coins = 50          # notes
+speed = 25          # guess
+boss = true
+
+[monster.b2]
+hp = 70             # notes
+coins = 70          # notes
+speed = 25          # guess
+boss = true
+
+[monster.b3]
+hp = 100            # notes
+coins = 100         # notes
+speed = 25          # guess
+boss = true
+
+
+[animation]
+hop_time = 0.35     # guess
+hop_height = 5      # guess
+squash = 0.06       # guess, on landing, wider and flatter
+stretch = 0.04      # guess, in the air
+idle_bob = 0.02     # guess
+hit_radius = 0.4    # proto, share of the monster sprite's smaller side
+
+
+[route_preference]
+reference_speed = 40    # guess
+bias = 3                # guess
+min_weight = 0.1        # guess
+
+
+# towers. damage and range lists are by level 1-5. attack_time is the time
+# between attacks, the same at every level (decided). projectile_speed 0
+# means a melee tower: each attack damages every monster in range.
+# level n costs cost x n (decided).
+
+[tower.t0]
+damage = [5, 10, 15, 20, 25]        # notes
+cost = 5                            # notes
+range = [45, 48, 51, 54, 57]        # guess
+attack_time = 1.5                   # guess, slower than the others (decided)
+projectile = "p0"
+projectile_speed = 0                # notes (melee)
+
+[tower.t1]
+damage = [3, 7, 13, 17, 23]         # notes
+cost = 10                           # notes
+range = [100, 104, 108, 112, 116]   # guess
+attack_time = 0.7                   # guess
+projectile = "p1"
+projectile_speed = 300              # guess
+
+[tower.t2]
+damage = [1, 3, 5, 7, 9]            # 1-4: notes, 5: guess
+cost = 20                           # notes
+range = [90, 94, 98, 102, 106]      # guess
+attack_time = 1.2                   # guess
+projectile = "p2"
+projectile_speed = 220              # guess
+slow = [0.60, 0.55, 0.50, 0.45, 0.40]   # guess, share of speed left, by level
+slow_time = 2.0                     # guess
+
+[tower.t3]
+damage = [1, 5, 7, 10, 13]          # 1-4: notes, 5: guess
+cost = 25                           # decided (was 40), may go lower
+range = [220, 230, 240, 250, 260]   # guess
+attack_time = 1.3                   # decided, amount guessed
+projectile = "p3"
+projectile_speed = 800              # guess
+
+[tower_rules]
+sell_refund = 0.5       # decided, half of the last purchase, rounded down
+
+
+[placement]
+footprint_radius = 16   # guess
+max_gap = 14            # guess, largest gap between footprint and path edge
+min_tower_distance = 32 # derived (two footprints)
+edge_distance = 16      # guess
+snap_radius = 48        # guess
+grid_cell = 4           # guess
+
+
+[economy]
+coin_total_factor = 10  # notes, coins dropped per map = 10 x starting coins
+coin_tolerance = 0.05   # notes for the build check: warn when more than 5 % off
+
+
+[waves]
+first_break = 40        # guess
+break = 25              # guess ("longer", decided)
+spawn_interval = 1.0    # guess, default for groups without an interval
+
+
+[hearts]
+per_map = 10            # decided
+monster = 1             # decided
+boss = 5                # decided
+
+
+[coins]
+flight_time = 0.7       # guess
+max_sprites = 8         # guess
+
+
+[controls]
+speeds = [1, 2]         # guess
+
+
+# sprite drawing direction (art.md): angle the drawing points to as drawn,
+# 0 right, -90 up. sprites not listed do not turn.
+[art.angle]
+t1 = 0
+t1_2 = 0
+t1_3 = 0
+t1_4 = 0
+t1_5 = 0
+t2 = -90
+t2_2 = -90
+t2_3 = -90
+t2_4 = -90
+t2_5 = -90
+t3 = -45
+t3_2 = -45
+t3_3 = -45
+t3_4 = -45
+t3_5 = -90
+p0 = -90
+p3 = -45
+
+# rotation point as a share of the trimmed image's width and height, for
+# sprites that do not turn around their centre (art.md). proto, by eye from
+# temp/preview/towers.png.
+[art.pivot]
+t1 = [0.36, 0.5]
+t1_2 = [0.27, 0.55]
+t1_3 = [0.31, 0.5]
+t1_4 = [0.34, 0.5]
+t1_5 = [0.26, 0.5]
+
+
+# debug switches, all off by default
+[debug]
+start_coins = -1        # coins at the start of a map, -1 uses the map's value
+unlimited_coins = false
+start_map = 0
+start_wave = 1          # the first wave to play, from 1
+no_heart_loss = false
+show_routes = false
+show_grid = false
+show_ranges = false
+show_hit_areas = false
+extra_speeds = []       # added to the game speeds, for example [4, 8]
+show_stats = false      # frame time and entity counts
+seed = 0                # random seed, 0 picks a new one each run
+
+
+# maps. waves: a group starts after the previous group has finished spawning,
+# plus its delay. the boss is a group in the last wave.
+
+[map.0]
+starting_coins = 10                     # notes
+early_bonus = 0.05                      # guess (starting coins / 200), coins per second left
+wave_count = 6                          # guess
+monster_share = [40, 25, 15, 10, 10]    # guess, % of regular monster coins, m0-m4
+
+[map.1]
+starting_coins = 20                     # notes
+early_bonus = 0.1                       # guess
+wave_count = 8                          # guess
+monster_share = [30, 25, 20, 15, 10]    # guess
+
+[map.2]
+starting_coins = 40                     # notes
+early_bonus = 0.2                       # guess
+wave_count = 10                         # guess
+monster_share = [20, 20, 20, 20, 20]    # guess
+
+[map.3]
+starting_coins = 60                     # notes (the sheet says 50)
+early_bonus = 0.3                       # guess
+wave_count = 12                         # guess
+monster_share = [15, 15, 20, 25, 25]    # guess
+
+# map0: draft, made from the monster shares; coin value grows with the wave number
+
+[[map.0.wave]]   # wave 1, 4 coins
+groups = [
+    { monster = "m0", count = 2, interval = 1.0 },
+    { monster = "m1", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.0.wave]]   # wave 2, 7 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.0.wave]]   # wave 3, 10 coins
+groups = [
+    { monster = "m0", count = 3, interval = 1.0 },
+    { monster = "m1", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.0.wave]]   # wave 4, 14 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 1.0, delay = 2.0 },
+]
+
+[[map.0.wave]]   # wave 5, 17 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.0.wave]]   # wave 6, 20 coins + boss 30
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m4", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "b0", count = 1, interval = 1.0, delay = 4.0 },
+]
+
+# map1: draft, made from the monster shares; coin value grows with the wave number
+
+[[map.1.wave]]   # wave 1, 4 coins
+groups = [
+    { monster = "m0", count = 4, interval = 1.0 },
+]
+
+[[map.1.wave]]   # wave 2, 8 coins
+groups = [
+    { monster = "m0", count = 4, interval = 1.0 },
+    { monster = "m1", count = 2, interval = 1.0, delay = 2.0 },
+]
+
+[[map.1.wave]]   # wave 3, 12 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.1.wave]]   # wave 4, 17 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.1.wave]]   # wave 5, 21 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 3, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 1, interval = 1.0, delay = 2.0 },
+]
+
+[[map.1.wave]]   # wave 6, 25 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 4, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 1.0, delay = 2.0 },
+]
+
+[[map.1.wave]]   # wave 7, 29 coins
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 3, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m4", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 1.0, delay = 2.0 },
+]
+
+[[map.1.wave]]   # wave 8, 33 coins + boss 50
+groups = [
+    { monster = "m0", count = 5, interval = 1.0 },
+    { monster = "m1", count = 3, interval = 1.0, delay = 2.0 },
+    { monster = "m2", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m3", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "m4", count = 1, interval = 1.0, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 1.0, delay = 2.0 },
+    { monster = "b1", count = 1, interval = 1.0, delay = 4.0 },
+]
+
+# map2: draft, made from the monster shares; coin value grows with the wave number
+
+[[map.2.wave]]   # wave 1, 6 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m0", count = 1, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 2, 12 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 3, 18 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 5, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 3, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 4, 24 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 4, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 5, 30 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m3", count = 3, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 6, 36 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m3", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m4", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 7, 42 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m3", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m4", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 8, 48 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 4, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m3", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m4", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 9, 53 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 5, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 4, interval = 0.8, delay = 2.0 },
+    { monster = "m3", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m4", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.8, delay = 2.0 },
+]
+
+[[map.2.wave]]   # wave 10, 59 coins + boss 70
+groups = [
+    { monster = "m0", count = 5, interval = 0.8 },
+    { monster = "m1", count = 5, interval = 0.8, delay = 2.0 },
+    { monster = "m2", count = 4, interval = 0.8, delay = 2.0 },
+    { monster = "m3", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m4", count = 3, interval = 0.8, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.8, delay = 2.0 },
+    { monster = "b2", count = 1, interval = 0.8, delay = 4.0 },
+]
+
+# map3: draft, made from the monster shares; coin value grows with the wave number
+
+[[map.3.wave]]   # wave 1, 6 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m0", count = 1, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 2, 13 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 3, 19 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 4, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 4, 26 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 5, 32 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 6, 38 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 4, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 7, 45 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 8, 51 coins
+groups = [
+    { monster = "m0", count = 4, interval = 0.7 },
+    { monster = "m1", count = 2, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m4", count = 3, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 9, 58 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 2, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m4", count = 4, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 10, 64 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m4", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 11, 71 coins
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 3, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m4", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 1, interval = 0.7, delay = 2.0 },
+]
+
+[[map.3.wave]]   # wave 12, 77 coins + boss 100
+groups = [
+    { monster = "m0", count = 5, interval = 0.7 },
+    { monster = "m1", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m2", count = 4, interval = 0.7, delay = 2.0 },
+    { monster = "m3", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m4", count = 5, interval = 0.7, delay = 2.0 },
+    { monster = "m0", count = 2, interval = 0.7, delay = 2.0 },
+    { monster = "b3", count = 1, interval = 0.7, delay = 4.0 },
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/routes.toml	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,15 @@
+# manual corrections to the routes that tools/build.py extracts from the masks.
+#
+# route numbers are those the build prints, counted from 0 per map, before
+# any correction. they change when a mask changes, so check the build output
+# and temp/preview/ after editing a mask.
+#
+# per map, all optional:
+#
+#   [map.2]
+#   drop = [1, 3]                   # remove these routes
+#   weights = { "0" = 2.0 }         # fixed weights, no route preference
+#
+#   [[map.2.route]]                 # replace a route with hand-placed points
+#   replace = 4                     # leave out to add a new route
+#   points = [[90, 85], [240, 90], [250, 400]]
--- a/doc/roadmap.md	Sun Oct 18 01:26:39 2026 +0200
+++ b/doc/roadmap.md	Sun Oct 18 14:50:20 2026 +0200
@@ -39,3 +39,114 @@
 
 debug switches (architecture.md) are added as each step needs them, starting
 with step 3.
+
+
+prototype notes
+---------------
+
+decisions taken while building steps 1-5 that the other documents do not
+cover. values marked proto in config/game.toml refer to this list.
+
+build:
+
+- runs on python 3.11 or later with pillow; numpy is not used. a full build
+  takes about 5 s, most of it in the mask step
+- a step is skipped when its outputs are newer than its inputs and the build
+  scripts. the mask step also reruns when the placement settings in
+  game.toml change; it keeps its result in temp/build/maps.json for the
+  checks and previews
+- map images are written as jpeg, quality 88. the maps have no transparency
+- tower strips are split at columns without pencil. pencil is anything darker
+  than luminance 225. outline gaps of up to about 4 pixels are closed before
+  the fill. the white paper edge outside the outline fades to transparent
+- the empty part of the hp bars is a darkened copy made by the build
+  (hpm_empty, hpb_empty)
+- sprite sizes go into config.js, so the game knows them before the images
+  load
+- mask pixels count when at least half opaque, and take the class of their
+  strongest colour. entrance or exit areas under 50 pixels are ignored
+- the placement test draws discs around the path edge instead of keeping a
+  distance for every pixel. the result is the same. edge_distance applies to
+  the tower centre
+- the centre line runs through the entrance and exit areas, so routes start
+  and end inside them. dead ends shorter than 0.8 path widths are dropped.
+  junctions closer together than 0.75 path widths count as one
+- map2 has three loops (the round one at the top left, two squares at the
+  bottom). each leaves the path at a junction and comes back to the same
+  junction, so the rule "no junction twice" would never walk them. a route
+  may walk such a loop once. of its two directions, the one that turns less
+  is kept. map2 gives 8 routes, all kept; map1 gives 3
+- route smoothing: moving average over 17 points, applied twice, then
+  simplified to 0.8 pixel tolerance
+- straightness for the route value is the least turning of the map's routes
+  divided by the route's turning. turning is the total, not per length
+- routes.toml names routes by their number in the build output. the numbers
+  change when a mask changes
+- measured path widths are lower than in balance.md (map1 38, map2 38, map3
+  46) because the centre line length includes the entrance and exit areas.
+  map0's route is 2020 long
+- the coin check compares all coins dropped, boss included, with 10 x
+  starting coins
+- the build prints the early start bonus for skipping every break, including
+  the one before the first wave: 8, 21, 53, 94. balance.md gives 6, 17, 45,
+  82, which leaves that break out. the game pays the bonus before the first
+  wave too. to decide
+
+config:
+
+- per map: [map.N] holds starting_coins, early_bonus, wave_count and
+  monster_share, followed by the [[map.N.wave]] lists
+- added: hit_radius in [animation] (0.4 of the monster sprite's smaller
+  side), min_weight in [route_preference] (the "at least 0.1" of the rule),
+  [art.angle] and [art.pivot]. t1 turns around the middle of its box, not
+  the middle of the image; the pivots for levels 1-5 are set by eye
+- draft waves: monster counts per level from the coin shares. each level is
+  spread over the waves by the coin budget still open, with wave n worth n
+  shares. higher levels start later: m1 after 15 % of the waves, m2 35 %, m3
+  50 %, m4 65 %. groups hold at most 5 monsters and alternate between
+  levels. spawn interval 1.0 s on maps 0 and 1, 0.8 s on map2, 0.7 s on
+  map3. 2 s between groups, 4 s before the boss. totals: 102, 199, 398, 600
+  coins
+
+game:
+
+- scripts share the namespace object MM. audio.js and storage.js are not
+  written yet
+- the simulation runs on wall clock time: at 60 frames per second, 2x gives
+  two steps per frame. at most 4 steps per frame and speed step; a longer
+  frame drops the rest
+- there is no title or map selection yet. the game starts on
+  debug.start_map. the won and lost screens offer a restart only
+- a break starts when all monsters of the wave are gone, killed or escaped,
+  not when the last one has spawned. during a break the wave counter shows
+  the next wave
+- monsters move at constant speed; the hop is drawn only. a hop spends 80 %
+  of its time in the air and 20 % landing. the idle bob is a slow breathing
+  (1.3 s) on top of the hops, as monsters never stand still
+- route choice weighs all routes of the map. on map2 this also picks the
+  entrance
+- "furthest along" means the least distance left to the exit. a monster is in
+  range when its centre is. projectiles hit on reaching the target's hit
+  radius. a new tower attacks at once
+- turning towers face their target at once and keep the last direction when
+  idle
+- t0's melee attack is in place, since without it t0 does nothing. it draws
+  spikes on all four sides and pushes them out for 0.3 s. spike sides, t2
+  slow, upgrades, selling and the boss bar are left for step 6; the boss uses
+  hpm for now
+- placement: a tap within the footprint radius or 28 css pixels of the
+  preview builds. the shop choice is cleared after building, and a second tap
+  on the chosen shop button cancels it. a tap on a built tower selects it and
+  shows its range. a refused tap shows a red cross for 0.5 s. shop buttons
+  the player cannot afford are dimmed and do nothing
+- flying coins: one sprite per coin, at most 8, started 0.05 s apart, flying
+  in game time on an arc. they are dropped when the map ends
+- placeholder icons: c0 for coins, m0 for waves, a drawn heart, one triangle
+  per game speed step (digits for debug speeds), a skip icon with countdown
+  and bonus for the early start. the top bar needs about 500 css pixels of
+  width; narrower screens are not handled
+- debug switches: all from architecture.md except unlocking maps, which waits
+  for step 7. start_coins -1 means the map's own value, seed 0 a new seed per
+  run
+- towers at scale 0.25 are small: t1 level 1 is about 43 x 30 map pixels.
+  worth a look with the hop and squash check of step 3
Binary file game/assets/b0.png has changed
Binary file game/assets/b1.png has changed
Binary file game/assets/b2.png has changed
Binary file game/assets/b3.png has changed
Binary file game/assets/c0.png has changed
Binary file game/assets/c1.png has changed
Binary file game/assets/c2.png has changed
Binary file game/assets/c3.png has changed
Binary file game/assets/hpb.png has changed
Binary file game/assets/hpb_empty.png has changed
Binary file game/assets/hpm.png has changed
Binary file game/assets/hpm_empty.png has changed
Binary file game/assets/m0.png has changed
Binary file game/assets/m1.png has changed
Binary file game/assets/m2.png has changed
Binary file game/assets/m3.png has changed
Binary file game/assets/m4.png has changed
Binary file game/assets/map0.jpg has changed
Binary file game/assets/map1.jpg has changed
Binary file game/assets/map2.jpg has changed
Binary file game/assets/map3.jpg has changed
Binary file game/assets/p0.png has changed
Binary file game/assets/p1.png has changed
Binary file game/assets/p2.png has changed
Binary file game/assets/p3.png has changed
Binary file game/assets/t0.png has changed
Binary file game/assets/t0_2.png has changed
Binary file game/assets/t0_3.png has changed
Binary file game/assets/t0_4.png has changed
Binary file game/assets/t0_5.png has changed
Binary file game/assets/t1.png has changed
Binary file game/assets/t1_2.png has changed
Binary file game/assets/t1_3.png has changed
Binary file game/assets/t1_4.png has changed
Binary file game/assets/t1_5.png has changed
Binary file game/assets/t2.png has changed
Binary file game/assets/t2_2.png has changed
Binary file game/assets/t2_3.png has changed
Binary file game/assets/t2_4.png has changed
Binary file game/assets/t2_5.png has changed
Binary file game/assets/t3.png has changed
Binary file game/assets/t3_2.png has changed
Binary file game/assets/t3_3.png has changed
Binary file game/assets/t3_4.png has changed
Binary file game/assets/t3_5.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/data/config.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,1524 @@
+// generated by tools/build.py from config/game.toml, do not edit
+window.MM = window.MM || {};
+MM.config = {
+ "scale": {
+  "map": 1.0,
+  "sprite": 0.25,
+  "coin": 0.4,
+  "hp_bar": 0.25
+ },
+ "monster": {
+  "m0": {
+   "hp": 5,
+   "coins": 1,
+   "speed": 35
+  },
+  "m1": {
+   "hp": 10,
+   "coins": 2,
+   "speed": 40
+  },
+  "m2": {
+   "hp": 15,
+   "coins": 3,
+   "speed": 45
+  },
+  "m3": {
+   "hp": 20,
+   "coins": 4,
+   "speed": 40
+  },
+  "m4": {
+   "hp": 30,
+   "coins": 6,
+   "speed": 35
+  },
+  "b0": {
+   "hp": 30,
+   "coins": 30,
+   "speed": 25,
+   "boss": true
+  },
+  "b1": {
+   "hp": 50,
+   "coins": 50,
+   "speed": 25,
+   "boss": true
+  },
+  "b2": {
+   "hp": 70,
+   "coins": 70,
+   "speed": 25,
+   "boss": true
+  },
+  "b3": {
+   "hp": 100,
+   "coins": 100,
+   "speed": 25,
+   "boss": true
+  }
+ },
+ "animation": {
+  "hop_time": 0.35,
+  "hop_height": 5,
+  "squash": 0.06,
+  "stretch": 0.04,
+  "idle_bob": 0.02,
+  "hit_radius": 0.4
+ },
+ "route_preference": {
+  "reference_speed": 40,
+  "bias": 3,
+  "min_weight": 0.1
+ },
+ "tower": {
+  "t0": {
+   "damage": [
+    5,
+    10,
+    15,
+    20,
+    25
+   ],
+   "cost": 5,
+   "range": [
+    45,
+    48,
+    51,
+    54,
+    57
+   ],
+   "attack_time": 1.5,
+   "projectile": "p0",
+   "projectile_speed": 0
+  },
+  "t1": {
+   "damage": [
+    3,
+    7,
+    13,
+    17,
+    23
+   ],
+   "cost": 10,
+   "range": [
+    100,
+    104,
+    108,
+    112,
+    116
+   ],
+   "attack_time": 0.7,
+   "projectile": "p1",
+   "projectile_speed": 300
+  },
+  "t2": {
+   "damage": [
+    1,
+    3,
+    5,
+    7,
+    9
+   ],
+   "cost": 20,
+   "range": [
+    90,
+    94,
+    98,
+    102,
+    106
+   ],
+   "attack_time": 1.2,
+   "projectile": "p2",
+   "projectile_speed": 220,
+   "slow": [
+    0.6,
+    0.55,
+    0.5,
+    0.45,
+    0.4
+   ],
+   "slow_time": 2.0
+  },
+  "t3": {
+   "damage": [
+    1,
+    5,
+    7,
+    10,
+    13
+   ],
+   "cost": 25,
+   "range": [
+    220,
+    230,
+    240,
+    250,
+    260
+   ],
+   "attack_time": 1.3,
+   "projectile": "p3",
+   "projectile_speed": 800
+  }
+ },
+ "tower_rules": {
+  "sell_refund": 0.5
+ },
+ "placement": {
+  "footprint_radius": 16,
+  "max_gap": 14,
+  "min_tower_distance": 32,
+  "edge_distance": 16,
+  "snap_radius": 48,
+  "grid_cell": 4
+ },
+ "economy": {
+  "coin_total_factor": 10,
+  "coin_tolerance": 0.05
+ },
+ "waves": {
+  "first_break": 40,
+  "break": 25,
+  "spawn_interval": 1.0
+ },
+ "hearts": {
+  "per_map": 10,
+  "monster": 1,
+  "boss": 5
+ },
+ "coins": {
+  "flight_time": 0.7,
+  "max_sprites": 8
+ },
+ "controls": {
+  "speeds": [
+   1,
+   2
+  ]
+ },
+ "art": {
+  "angle": {
+   "t1": 0,
+   "t1_2": 0,
+   "t1_3": 0,
+   "t1_4": 0,
+   "t1_5": 0,
+   "t2": -90,
+   "t2_2": -90,
+   "t2_3": -90,
+   "t2_4": -90,
+   "t2_5": -90,
+   "t3": -45,
+   "t3_2": -45,
+   "t3_3": -45,
+   "t3_4": -45,
+   "t3_5": -90,
+   "p0": -90,
+   "p3": -45
+  },
+  "pivot": {
+   "t1": [
+    0.36,
+    0.5
+   ],
+   "t1_2": [
+    0.27,
+    0.55
+   ],
+   "t1_3": [
+    0.31,
+    0.5
+   ],
+   "t1_4": [
+    0.34,
+    0.5
+   ],
+   "t1_5": [
+    0.26,
+    0.5
+   ]
+  }
+ },
+ "debug": {
+  "start_coins": -1,
+  "unlimited_coins": false,
+  "start_map": 0,
+  "start_wave": 1,
+  "no_heart_loss": false,
+  "show_routes": false,
+  "show_grid": false,
+  "show_ranges": false,
+  "show_hit_areas": false,
+  "extra_speeds": [],
+  "show_stats": false,
+  "seed": 0
+ },
+ "maps": [
+  {
+   "starting_coins": 10,
+   "early_bonus": 0.05,
+   "wave_count": 6,
+   "monster_share": [
+    40,
+    25,
+    15,
+    10,
+    10
+   ],
+   "waves": [
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 3,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "b0",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 4.0
+      }
+     ]
+    }
+   ]
+  },
+  {
+   "starting_coins": 20,
+   "early_bonus": 0.1,
+   "wave_count": 8,
+   "monster_share": [
+    30,
+    25,
+    20,
+    15,
+    10
+   ],
+   "waves": [
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 4,
+       "interval": 1.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 4,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 4,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 1.0
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 1.0,
+       "delay": 2.0
+      },
+      {
+       "monster": "b1",
+       "count": 1,
+       "interval": 1.0,
+       "delay": 4.0
+      }
+     ]
+    }
+   ]
+  },
+  {
+   "starting_coins": 40,
+   "early_bonus": 0.2,
+   "wave_count": 10,
+   "monster_share": [
+    20,
+    20,
+    20,
+    20,
+    20
+   ],
+   "waves": [
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 5,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 4,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 4,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 5,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 4,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.8
+      },
+      {
+       "monster": "m1",
+       "count": 5,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 4,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 3,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.8,
+       "delay": 2.0
+      },
+      {
+       "monster": "b2",
+       "count": 1,
+       "interval": 0.8,
+       "delay": 4.0
+      }
+     ]
+    }
+   ]
+  },
+  {
+   "starting_coins": 60,
+   "early_bonus": 0.3,
+   "wave_count": 12,
+   "monster_share": [
+    15,
+    15,
+    20,
+    25,
+    25
+   ],
+   "waves": [
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 4,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 2,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 3,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 1,
+       "interval": 0.7,
+       "delay": 2.0
+      }
+     ]
+    },
+    {
+     "groups": [
+      {
+       "monster": "m0",
+       "count": 5,
+       "interval": 0.7
+      },
+      {
+       "monster": "m1",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m2",
+       "count": 4,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m3",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m4",
+       "count": 5,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "m0",
+       "count": 2,
+       "interval": 0.7,
+       "delay": 2.0
+      },
+      {
+       "monster": "b3",
+       "count": 1,
+       "interval": 0.7,
+       "delay": 4.0
+      }
+     ]
+    }
+   ]
+  }
+ ],
+ "sprites": {
+  "b0": [
+   164,
+   160
+  ],
+  "b1": [
+   195,
+   160
+  ],
+  "b2": [
+   127,
+   176
+  ],
+  "b3": [
+   144,
+   183
+  ],
+  "c0": [
+   41,
+   40
+  ],
+  "c1": [
+   53,
+   60
+  ],
+  "c2": [
+   48,
+   52
+  ],
+  "c3": [
+   42,
+   53
+  ],
+  "hpb": [
+   243,
+   31
+  ],
+  "hpb_empty": [
+   243,
+   31
+  ],
+  "hpm": [
+   117,
+   28
+  ],
+  "hpm_empty": [
+   117,
+   28
+  ],
+  "m0": [
+   130,
+   113
+  ],
+  "m1": [
+   128,
+   112
+  ],
+  "m2": [
+   92,
+   87
+  ],
+  "m3": [
+   97,
+   104
+  ],
+  "m4": [
+   111,
+   110
+  ],
+  "p0": [
+   34,
+   88
+  ],
+  "p1": [
+   46,
+   32
+  ],
+  "p2": [
+   51,
+   53
+  ],
+  "p3": [
+   60,
+   64
+  ],
+  "t0": [
+   144,
+   143
+  ],
+  "t0_2": [
+   153,
+   159
+  ],
+  "t0_3": [
+   206,
+   185
+  ],
+  "t0_4": [
+   240,
+   260
+  ],
+  "t0_5": [
+   256,
+   251
+  ],
+  "t1": [
+   174,
+   120
+  ],
+  "t1_2": [
+   203,
+   184
+  ],
+  "t1_3": [
+   239,
+   152
+  ],
+  "t1_4": [
+   216,
+   135
+  ],
+  "t1_5": [
+   359,
+   146
+  ],
+  "t2": [
+   124,
+   149
+  ],
+  "t2_2": [
+   115,
+   154
+  ],
+  "t2_3": [
+   101,
+   159
+  ],
+  "t2_4": [
+   132,
+   177
+  ],
+  "t2_5": [
+   132,
+   190
+  ],
+  "t3": [
+   162,
+   135
+  ],
+  "t3_2": [
+   158,
+   176
+  ],
+  "t3_3": [
+   243,
+   248
+  ],
+  "t3_4": [
+   216,
+   160
+  ],
+  "t3_5": [
+   205,
+   213
+  ]
+ }
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/data/maps.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,8 @@
+// generated by tools/build.py from art/map*mask.png and config/routes.toml, do not edit
+window.MM = window.MM || {};
+MM.maps = [
+{"name":"map0","image":"assets/map0.jpg","width":705,"height":697,"cell":4,"cols":176,"rows":174,"grid":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001111000000000011111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000011111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000011111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000011111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000011111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000001111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000011111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000001111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111100000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000001111100000000000000011111111111000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000001111110000100001111111111111111111111111111111110000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000111111111111110000000000000000000000011111111111111111111111100000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111110000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000001111111111111111111000000000000000011111111111111111000000001111111000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000001111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111100000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111110000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111110000000000000000000000000000000000000001111000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111110000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111000000000000000111111111111100000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111100000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111110000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111100000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111100000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111100000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111100000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111100000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000001111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111110000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111100000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111000000111111111111110000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000001111111111111111000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000011111111111110000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111110000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000111111100000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111111100000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011111111000000000000000000000000000000111111111111111111111111111111111111111111111100000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000001111111111100000000000000000011111111111111111111111111111111111111111111111111111111000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000000000000000000000111111111111111111000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011111111111111111111111111000000000000000000000000000000000000000000000000011111111111110000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111100000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","entrances":[[189.1,59.7,23.3]],"exits":[[606.6,646.0,23.1]],"routes":[{"points":[191.0,71.0,189.2,81.3,188.1,119.0,193.3,130.7,204.4,139.6,211.6,141.9,221.2,142.9,323.3,143.1,351.7,144.6,405.7,152.4,449.5,163.8,489.6,181.8,498.8,188.0,502.5,193.1,505.7,200.6,510.2,216.7,511.4,225.7,508.1,242.6,505.4,248.5,501.4,253.4,495.3,257.4,483.2,262.6,466.7,266.9,428.9,269.8,387.0,270.0,271.4,264.1,219.3,263.9,185.4,266.8,175.6,269.5,168.8,273.8,164.6,279.6,162.2,287.5,161.9,295.8,163.9,306.9,167.1,315.6,171.3,321.7,177.0,326.8,184.4,330.8,197.4,333.7,248.1,336.9,367.8,334.1,387.3,335.3,402.4,337.8,443.5,348.2,455.4,354.4,460.5,359.9,464.0,366.4,470.7,393.4,470.5,401.6,468.4,410.6,463.6,423.8,459.0,431.8,447.9,440.4,425.3,449.3,391.4,457.6,284.9,472.9,234.7,478.0,212.0,481.9,203.1,485.0,197.8,488.7,192.8,494.5,187.9,502.7,185.6,509.4,186.8,520.4,194.2,536.1,200.1,541.6,208.5,545.2,221.6,547.7,242.7,549.6,324.8,545.6,417.5,536.5,468.5,534.0,508.3,536.9,545.7,546.0,559.2,550.8,578.7,561.4,586.4,567.2,591.8,573.9,600.6,591.2,603.7,600.0,605.3,635.7,607.0,646.0],"length":2020.4,"turning":921.9,"value":1.0,"weight":null}]},
+{"name":"map1","image":"assets/map1.jpg","width":663,"height":590,"cell":4,"cols":165,"rows":147,"grid":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111100000000000000000000001111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111100000000000000000000001111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111100000000000000000000001111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000001111111111111111111111110000000000000000000000000000000000000000000000000000000000001111111111111111111110000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000011110000000000000001111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000011110000000000000001111111111111111111111110000000000000000011111111000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000011110000000000000001111111111111111111111110000000000000000011111111111111111111111111111100000000000000000000011110000000000000000000000000000000000000000000000000011110000000000000000111111111111111000001110000000000000000011111111111111111111111111111100000000000000000000011110000000000000000000000000000000000000000000000000011110000000000000000111100000000000000001110000000000000000011111111111111111111111111111100000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000111100000000000000001110000000000000000011110000000000000000000000111100000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000111100000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000011100000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000011100000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000011110000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000011100000000000000000011110000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000011110000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000011110000000000000011110000000000000000011110000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001110000000000000011110000000000000000011100000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001110000000000000011110000000000000000011100000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001111000000000000011110000000000000000111100000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001111000000000000011110000000000000000111100000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001111111111111111111100000000000000000111100000000000000000000000011100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001111111111111111111100000000000000000111111111111111111111111111111100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001111111111111111111100000000000000000111111111111111111111111111111100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000001111111111111111111100000000000000001111111111111111111111111111111100000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000001111111111111111100000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000011111111111111111110000000000000001111110000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000011111000000000000000000000000111111111111100000000000000001111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000001111110000011111111111111111111111111111100000000000000001111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111100000000000000001111111111000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111100000000000000001111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111000000000000000011100000000000000001111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000001111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000011111111111111111111111000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000001111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000001111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000001111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000011111100000111110000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000011111100001111111000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111100000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111100000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111100000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111100000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000001000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","entrances":[[268.6,72.3,20.1]],"exits":[[498.1,540.6,18.9]],"routes":[{"points":[271.0,76.0,268.3,85.9,262.7,121.2,261.9,153.8,260.7,161.0,256.7,165.8,243.9,169.9,239.3,172.8,235.5,177.8,233.4,184.9,233.4,237.5,229.3,286.6,228.9,346.4,226.1,386.2,226.2,399.1,227.8,406.0,232.9,410.9,241.9,412.7,301.0,414.9,375.6,415.7,380.0,417.6,382.5,421.3,383.8,450.6,386.1,455.9,390.5,459.2,404.1,461.7,439.4,461.5,480.6,463.4,490.2,465.5,494.0,469.1,495.8,475.8,495.8,502.2,498.0,543.0],"length":725.8,"turning":530.3,"value":0.839,"weight":null},{"points":[271.0,76.0,268.3,85.9,262.5,122.1,261.5,157.6,259.6,163.1,256.0,166.2,248.2,167.4,230.1,165.2,193.6,164.0,129.4,165.9,99.9,165.2,87.8,167.4,79.1,173.8,76.4,178.5,74.6,185.7,73.0,217.0,77.4,291.1,77.3,311.5,78.9,318.2,82.7,322.1,90.3,323.6,137.5,322.0,213.5,322.0,222.6,323.1,226.8,326.1,228.7,332.4,226.1,397.0,227.7,405.9,232.1,410.5,239.8,412.5,266.3,413.8,375.5,415.6,379.9,417.5,382.5,421.2,383.8,450.4,386.1,455.8,390.4,459.2,406.9,461.8,436.3,461.4,480.4,463.4,490.8,465.8,494.3,469.7,495.7,475.6,495.9,503.0,498.0,543.0],"length":1028.9,"turning":765.8,"value":0.827,"weight":null},{"points":[271.0,76.0,268.3,85.9,262.5,122.1,261.2,159.4,257.4,165.4,248.6,168.0,272.4,166.1,313.3,166.2,399.5,170.4,414.8,172.1,422.3,174.9,427.3,181.5,429.6,195.4,431.0,249.8,430.2,296.5,428.1,305.6,424.4,311.8,418.7,316.2,411.8,318.1,355.9,320.0,298.0,320.1,241.0,322.4,233.8,323.9,230.4,327.6,229.2,333.5,226.0,388.1,226.3,400.0,227.8,406.0,232.9,410.9,241.8,412.7,300.9,414.9,375.6,415.7,380.0,417.6,382.5,421.2,383.8,450.5,386.1,455.9,390.5,459.2,404.0,461.7,439.3,461.5,480.5,463.4,490.1,465.4,494.0,469.1,495.8,475.7,495.9,503.1,498.0,543.0],"length":1070.9,"turning":883.7,"value":0.8,"weight":null}]},
+{"name":"map2","image":"assets/map2.jpg","width":618,"height":537,"cell":4,"cols":154,"rows":134,"grid":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000011111100000001111111110000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111110000000000001111000000000000000000000000011111000111111111111110000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111000000001111100000000000000000000000000111100111111111111111111000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111000000111100000000000000000000000000001111111111100001111111111000000000000000000000000000000000000000000000000011111111110000000000000000000000011111111111000111100000000000000000000000000000011111110000000000111111111000000000000000000000000000000000000000000000011111111000000000000000000000000000000011111110011110000000000000000000000000000001111110000000000000011111110000000000000000000000000000000000000000000011111000000000000000000000000000000000000001111111110000000000000000000000000000000011110000000000000000011111100000000000000000000000000000000000000000010000000000000000000000000000000000000000000011111111000000000000000000000000000000001110000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111000000000000000000000000000000000011000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000001000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000100000000000000000000000011111000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000011110000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000001111000000000000000000000000000000000000001111111000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000111100000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000100000000000000011110000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000111100000000000000000000000000010000000000000001111000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011111000000000000000000000000001000000000000000111100000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000001111100000000000000000000000001100000000000000011110000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000110000000000000001110000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000111111100000000000000000000000111000000000000000111000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000011111110000000000000000000000011100000000000000011100000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000011110111100000000000000000000011110000000000000001110000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000111110011110000000000000000000001111000000000000000111000000000000000000000000000000000000001111000000000000000000000000000000000000000000001111111111111111110000111100000000000000000001111100000000000000011100000000000000000000000000000000000000111100000000000000000000001111110000000000000000111111111111111110000011111000000000000000000111110000000000000011110000000000000000000000000000000000000011110000000000000000000011111110000000000000000011111111111111110000000111110000000000000000111111000000000000001111000000000000000000000000000000000000001111000000000000000000011111111000000000000000011111111111111100000001111111100000000000001111111100000000000000111100000000000000000000000000000000000000111100000000000000000011111111100000000000000001111000011111111111111111111111100000000111111111110000000000000011110000000000000000000000000000000000000011110000000000000000001111111110000000000000000111111111111111111111111111111111111111111111111111000000000000001111000000000000000000000000000000000000001111000000000000000000011111111000000000000000011111111111111111111111111111111000000000000000000100000000000000111100000000000000000000000000000000000000111100000000000000000001111111100000000000000001111111111111111000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000011110000000000000000000001111000000000000000001100000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111000000000000000001111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111110000000000000000111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111100000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111100000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000111111111000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000111000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000011100000000000000000111110000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000110000000000000111111110000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000011000000000000011111110000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000100000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000010000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000001000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000100000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000010000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000001111111111000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000001111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000001111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111110000000000000000011111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000011111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111110000000000000000001111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","entrances":[[94.7,85.3,20.1],[76.8,413.0,18.7]],"exits":[[577.4,264.0,20.7]],"routes":[{"points":[98.0,85.0,177.1,78.1,205.0,78.4,227.8,81.1,238.2,84.4,244.4,90.0,247.2,97.5,251.3,119.7,253.4,124.2,256.3,126.8,266.8,129.0,304.6,128.5,313.0,125.5,318.6,118.6,321.9,108.8,329.6,75.7,333.7,65.3,338.1,58.0,343.4,52.8,349.1,49.9,355.5,48.8,363.9,49.2,380.9,54.2,386.4,57.6,390.9,62.4,396.8,76.0,403.4,110.4,406.9,122.0,409.8,126.5,414.5,130.5,420.2,133.2,426.1,134.2,436.2,131.1,445.5,123.2,450.4,115.2,458.7,94.0,465.9,85.7,471.6,83.0,478.0,82.2,494.2,85.6,501.6,89.3,507.9,95.0,512.1,102.3,514.1,110.5,514.6,124.0,510.5,218.0,512.0,234.2,516.5,248.3,521.5,255.4,528.4,258.8,548.2,261.5,571.7,262.6,577.0,264.0],"length":797.5,"turning":808.5,"value":0.527,"weight":null},{"points":[98.0,85.0,177.1,78.1,205.0,78.4,227.8,81.1,238.2,84.4,244.4,90.0,247.2,97.5,251.3,119.7,253.4,124.2,256.3,126.8,266.8,129.0,304.6,128.5,313.0,125.5,318.6,118.6,321.9,108.8,329.6,75.7,333.7,65.3,338.1,58.0,343.4,52.8,349.1,49.9,355.5,48.8,363.9,49.2,380.9,54.2,386.4,57.6,390.9,62.4,396.8,76.0,403.4,110.4,406.9,122.0,409.8,126.5,414.5,130.5,420.2,133.2,426.1,134.2,436.2,131.1,445.5,123.2,450.4,115.2,459.2,93.2,463.1,88.1,467.4,84.8,474.3,82.4,483.5,82.7,495.9,86.3,504.6,91.6,511.4,100.6,514.4,113.3,510.5,218.9,512.0,234.2,517.1,250.7,517.4,255.3,514.4,258.0,499.5,260.4,494.0,263.5,487.8,282.0,477.1,297.7,475.1,307.9,474.6,350.9,473.4,356.2,470.7,360.6,464.8,364.2,456.5,365.7,429.7,365.9,419.5,364.4,414.9,361.1,412.3,355.8,409.4,328.1,410.0,299.7,412.0,293.0,415.2,289.6,422.7,287.6,469.2,288.0,480.6,286.3,485.3,283.7,488.1,280.4,493.7,263.9,497.4,261.1,502.5,259.8,527.1,259.4,571.7,262.6,577.0,264.0],"length":1176.7,"turning":1362.6,"value":0.542,"weight":null},{"points":[98.0,85.0,171.3,78.4,199.1,78.1,230.6,81.7,239.0,84.8,244.0,89.3,247.9,101.2,250.7,120.0,251.3,132.5,249.4,171.7,241.9,208.1,235.5,218.5,223.7,226.8,211.9,230.2,192.6,231.8,179.1,230.5,164.7,226.3,157.0,221.3,151.7,213.7,146.6,197.6,145.3,179.3,147.7,164.3,154.3,153.0,162.1,145.6,169.2,141.0,189.9,135.0,206.2,133.2,239.0,132.8,261.2,129.1,302.0,128.8,311.7,126.3,316.3,122.3,320.1,114.9,328.0,80.9,333.0,66.8,339.5,56.4,346.7,50.9,356.6,48.7,368.7,50.2,381.1,54.3,389.2,60.4,393.4,66.6,396.7,75.3,403.2,109.6,406.6,121.4,412.5,129.1,422.1,133.7,427.2,134.1,433.1,132.6,444.4,124.4,450.1,115.9,458.8,93.8,466.1,85.6,471.8,82.9,478.2,82.2,494.4,85.7,501.8,89.5,508.0,95.2,512.2,102.5,514.1,110.7,514.6,124.2,510.5,218.2,512.0,234.4,516.6,248.5,521.6,255.5,528.6,258.9,548.4,261.5,571.9,262.6,577.0,264.0],"length":1153.7,"turning":1024.7,"value":0.587,"weight":null},{"points":[98.0,85.0,172.2,78.3,200.0,78.2,217.5,79.4,231.5,81.9,239.7,85.3,244.4,90.0,247.4,98.4,250.7,120.0,250.9,148.4,248.9,175.5,241.6,209.0,234.8,219.2,223.7,226.8,211.9,230.2,191.6,231.8,178.1,230.3,164.7,226.3,157.0,221.3,151.7,213.7,146.6,197.6,145.3,179.3,147.7,164.3,154.3,153.0,162.1,145.6,169.2,141.0,189.9,135.0,206.2,133.2,239.0,132.8,261.2,129.1,302.0,128.8,311.7,126.3,316.3,122.3,320.1,114.9,328.0,80.9,333.0,66.8,339.5,56.4,346.7,50.9,356.6,48.7,368.7,50.2,381.1,54.3,389.2,60.4,393.4,66.6,396.7,75.3,403.2,109.6,406.6,121.4,411.8,128.5,421.2,133.5,427.2,134.1,432.3,133.0,443.7,125.1,450.1,115.9,459.3,93.0,463.2,87.9,468.4,84.2,475.4,82.3,484.6,82.9,496.1,86.4,504.8,91.8,511.4,100.7,514.4,113.5,510.5,218.2,511.9,233.5,517.1,250.9,517.4,255.5,514.3,258.1,500.2,260.2,494.4,263.1,492.0,267.2,488.1,281.4,477.3,297.0,475.1,308.1,474.7,350.1,473.6,355.6,471.1,360.1,465.5,363.9,457.3,365.6,430.4,365.9,420.2,364.6,415.3,361.6,412.5,356.5,409.4,328.9,410.0,299.5,411.7,293.6,415.4,289.5,422.9,287.6,468.5,288.0,480.0,286.6,484.7,284.1,488.2,280.2,493.8,263.7,497.6,261.0,502.8,259.7,527.3,259.4,571.9,262.6,577.0,264.0],"length":1533.1,"turning":1586.2,"value":0.636,"weight":null},{"points":[78.0,414.0,211.7,414.9,225.0,413.3,234.0,409.1,238.8,402.8,241.5,392.0,245.3,324.6,246.9,316.3,249.4,312.1,253.5,309.4,275.2,307.2,279.0,305.6,281.7,302.8,283.8,295.1,286.8,243.4,289.9,237.4,296.5,233.6,323.5,231.3,386.6,229.1,451.0,228.6,459.3,230.4,466.7,234.0,486.7,253.3,495.5,258.4,528.4,259.4,568.2,262.3,577.0,264.0],"length":656.9,"turning":431.1,"value":0.714,"weight":null},{"points":[78.0,414.0,211.7,414.9,225.0,413.3,234.0,409.1,238.8,402.8,241.5,392.0,245.3,324.6,246.9,316.3,249.4,312.1,253.5,309.4,275.2,307.2,279.0,305.6,281.7,302.8,283.8,295.1,286.8,243.4,289.9,237.4,296.5,233.6,323.5,231.3,386.6,229.1,451.0,228.6,460.1,230.7,467.4,234.5,485.9,252.7,492.9,257.5,501.0,259.3,514.3,259.0,500.9,260.1,494.3,263.2,491.9,267.3,488.1,281.5,476.9,298.0,475.1,308.2,474.7,350.3,473.6,355.7,471.0,360.2,466.2,363.6,459.0,365.5,425.4,365.7,419.2,364.3,415.2,361.5,412.7,357.2,411.3,351.0,409.3,325.8,409.4,306.1,411.1,295.0,414.8,289.9,423.0,287.6,468.6,288.0,480.1,286.5,484.8,284.0,488.2,280.1,493.9,263.6,497.0,261.3,502.0,259.9,527.4,259.4,568.2,262.3,577.0,264.0],"length":1027.4,"turning":1148.9,"value":0.523,"weight":null},{"points":[78.0,414.0,209.7,414.9,223.2,413.7,231.8,410.6,238.0,404.4,241.3,392.9,246.3,318.0,248.4,313.3,251.3,310.5,260.7,308.1,328.2,307.2,346.5,308.4,353.0,311.5,355.2,315.7,356.0,323.2,353.9,359.3,349.0,389.4,346.5,396.3,342.8,400.9,337.4,403.6,328.2,405.1,300.0,404.9,290.7,402.5,286.8,396.7,284.0,369.0,285.6,319.9,284.0,293.0,286.1,248.9,288.5,239.2,291.2,236.2,295.7,233.8,327.6,231.2,450.2,228.5,459.4,230.4,466.8,234.1,486.8,253.4,495.6,258.5,528.6,259.5,568.4,262.3,577.0,264.0],"length":973.6,"turning":639.2,"value":0.655,"weight":null},{"points":[78.0,414.0,209.7,414.9,223.2,413.7,231.8,410.6,238.0,404.4,241.3,392.9,246.3,318.0,248.4,313.3,251.3,310.5,260.7,308.1,328.2,307.2,346.5,308.4,353.0,311.5,355.2,315.7,356.0,323.2,353.9,359.3,349.0,389.4,346.5,396.3,342.8,400.9,337.4,403.6,328.2,405.1,300.0,404.9,290.7,402.5,286.8,396.7,284.0,369.0,285.6,319.9,284.0,293.0,286.1,248.9,288.5,239.2,291.2,236.2,295.7,233.8,308.9,232.1,385.7,229.2,451.2,228.6,460.3,230.7,467.5,234.6,486.0,252.8,492.2,257.2,500.2,259.3,514.3,259.0,500.8,260.1,494.2,263.3,491.9,267.4,488.0,281.6,477.2,297.3,475.1,307.4,474.7,350.4,473.5,355.9,470.9,360.3,466.0,363.7,458.9,365.5,425.3,365.6,419.1,364.2,415.1,361.4,412.7,357.1,411.3,350.8,409.3,325.6,409.4,305.9,411.1,294.9,414.9,289.8,423.2,287.6,468.8,288.0,480.2,286.5,484.9,284.0,487.9,280.7,493.9,263.6,502.1,259.8,526.6,259.3,568.3,262.3,577.0,264.0],"length":1344.0,"turning":1355.6,"value":0.597,"weight":null}]},
+{"name":"map3","image":"assets/map3.jpg","width":642,"height":459,"cell":4,"cols":160,"rows":114,"grid":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111110000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111110000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000011111100000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000111111110000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000111111100000000000000000000000000000000011100000000000000000011111111000000000000000000011110000000000000000000000000000000000000000000000000000001111111111111111111111100000000000000000000000000000001110000000000000000001111111100000000000000000001111000000000000000000000000000000000000000011111111111111111111111111111111111111000000000000000000000000000000111000000000000000000111011110000000000000000000111100000000000000000000000000000000011111111111111111111111111111111111111111000000000000000000000000000000000011100000000000000000011101111000000000000000000011110000000000000000000000000000111111111111111111111111111111000000000000000000000000000000000000000000000000001110000000000000000001110111100000000000000000001111000000000000000000000000011111111111111111111100000000000000000000000000000000000000000000000000000000011111111000000000000000000111011110000000000000000000011100000000000000000000000111111111111110000000000000000000000000000000000000000000000000000000000000000111111111100000000000000000011101111000000000000000000001110000000000000000000000111111111000000000000000000000000000000000000000000000000000000000000000000000111111111110000000000000000001110111100000000000000000000111000000000000000000000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111011110000000000000000000011100000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011101111000000000000000000001110000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110111100000000000000000000111000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111011110000000000000000000011100000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011101111000000000000000000001111000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110011100000000000000000000111100000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111101110000000000000000000011110000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110111000000000000000000001111000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111011100000000000000000000111100000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111101110000000000000000000011110000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110111000000000000000000001111000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111011100000000000000000000111100000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111001110000000000000000000011110000000000000011110000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000111100111000000000000000000001111000000000000001111000000000000000000000000000000000000000011111111111111111110000000000000000000000000000000000000000000000000011110011100000000000000000000011100000000000000111100000000000000000000000000000000011111111111111111111111110000000000000000000000000000000000000000000000000111110001110000000000000000000001110000000000000011110000000000000000000001111111111111111111111111111111111110000000000000000000000000000000000000000000000000111110000111000000000000000000000111000000000000001111000000000000000000111111111111111111111111111111111111000000000000000000000000000000000000011111111111111111110000011100000000000000000000011100000000000000111100000000000000000011111111111111111110000000000000000000000000000000000000000000000111111111111111111111111110000001111000000000000000000001110000000000000011110000000000000000001111111100000000000000000000000000000000000000000000000000000000111111111111111111111111110000000111100000000000000000000111000000000000001111000000000000000000111100000000000000000000000000000000000000000000000000000000000000111111111111111111111000000000011110000000000000000000011100000000000000111100000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000001110000000000000011110000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000111000000000000001111000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000011100000000000000111100000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000001110000000000000011110000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000111000000000000001110000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000011100000000000000111000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000001110000000000000011100000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000111000000000000001110000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000011111000000000000111000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000001111111111111000011100000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000111111111111111111110000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000001111111111111111111000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000011111111111100000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000110000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111100000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","entrances":[[43.6,265.1,19.2]],"exits":[[596.6,240.5,22.6]],"routes":[{"points":[44.0,267.0,46.7,264.9,54.9,263.3,109.2,261.4,115.1,259.8,118.6,256.8,121.0,245.7,119.2,196.5,120.5,169.2,123.3,158.4,129.1,151.6,144.6,145.4,172.8,140.7,202.4,140.1,215.3,142.8,222.7,149.1,225.7,158.6,225.9,215.7,231.4,323.4,235.2,356.9,242.8,387.7,247.1,393.6,254.5,399.3,263.7,403.9,272.6,406.7,311.3,409.8,353.9,410.7,368.3,409.3,377.3,407.0,383.1,403.2,386.4,397.2,390.7,358.0,392.7,283.8,396.0,269.3,401.5,261.9,412.5,257.8,446.8,252.5,506.6,246.5,560.8,242.3,586.6,241.7,596.0,240.0],"length":1012.3,"turning":582.9,"value":1.0,"weight":null}]}
+];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/index.html	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,27 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
+<title>minor monsters</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body>
+<canvas id="game"></canvas>
+<!-- plain script tags in a fixed order, so the page runs from disk (architecture.md) -->
+<script src="data/config.js"></script>
+<script src="data/maps.js"></script>
+<script src="js/util.js"></script>
+<script src="js/assets.js"></script>
+<script src="js/map.js"></script>
+<script src="js/monster.js"></script>
+<script src="js/tower.js"></script>
+<script src="js/projectile.js"></script>
+<script src="js/wave.js"></script>
+<script src="js/game.js"></script>
+<script src="js/render.js"></script>
+<script src="js/ui.js"></script>
+<script src="js/input.js"></script>
+<script src="js/main.js"></script>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/assets.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,61 @@
+// image loading and the sprite table
+
+window.MM = window.MM || {};
+
+MM.assets = (function () {
+    "use strict";
+
+    var images = {};
+    var cfg = MM.config;
+
+    // load every sprite of the config's sprite table and every map image.
+    // calls done(failed names) once all have loaded or failed.
+    function load(done) {
+        var names = Object.keys(cfg.sprites);
+        var jobs = names.map(function (n) { return [n, "assets/" + n + ".png"]; });
+        MM.maps.forEach(function (m) { jobs.push([m.name, m.image]); });
+        var left = jobs.length, failed = [];
+        jobs.forEach(function (job) {
+            var img = new Image();
+            img.onload = finish;
+            img.onerror = function () { failed.push(job[1]); finish(); };
+            img.src = job[1];
+            images[job[0]] = img;
+        });
+        function finish() {
+            if (--left === 0) done(failed);
+        }
+    }
+
+    function img(name) {
+        return images[name];
+    }
+
+    // sprite size in map pixels at the given scale
+    function size(name, scale) {
+        var s = cfg.sprites[name];
+        return [s[0] * scale, s[1] * scale];
+    }
+
+    // draw a sprite with its pivot at x, y. angle is the direction to face
+    // in radians, ignored for sprites that do not turn. sx, sy stretch the
+    // sprite around its pivot.
+    function draw(ctx, name, x, y, scale, angle, sx, sy) {
+        var image = images[name];
+        if (!image || !image.complete) return;
+        var w = cfg.sprites[name][0] * scale;
+        var h = cfg.sprites[name][1] * scale;
+        var pivot = cfg.art.pivot[name] || [0.5, 0.5];
+        var drawn = cfg.art.angle[name];
+        ctx.save();
+        ctx.translate(x, y);
+        if (drawn !== undefined && angle !== undefined && angle !== null) {
+            ctx.rotate(angle - MM.util.deg(drawn));
+        }
+        if (sx !== undefined) ctx.scale(sx, sy);
+        ctx.drawImage(image, -pivot[0] * w, -pivot[1] * h, w, h);
+        ctx.restore();
+    }
+
+    return { load: load, img: img, size: size, draw: draw };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/game.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,150 @@
+// game state and rules: coins, hearts, building, win and loss
+
+window.MM = window.MM || {};
+
+MM.Game = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+    var dbg = cfg.debug;
+
+    function Game(mapIndex, seed) {
+        var mc = cfg.maps[mapIndex];
+        this.map = new MM.GameMap(mapIndex);
+        this.seed = seed;
+        this.random = MM.util.rng(seed);
+        this.coins = dbg.start_coins >= 0 ? dbg.start_coins : mc.starting_coins;
+        this.hearts = cfg.hearts.per_map;
+        this.monsters = [];
+        this.towers = [];
+        this.projectiles = [];
+        this.flights = [];      // coins flying to the counter
+        this.waves = new MM.Waves(mapIndex, MM.util.clamp(dbg.start_wave - 1, 0, mc.waves.length - 1));
+        this.time = 0;
+        this.paused = false;
+        this.speeds = cfg.controls.speeds.concat(dbg.extra_speeds);
+        this.speedIndex = 0;
+        this.result = null;     // "won" or "lost"
+        // player selection: shop tower type, its snapped preview, a built tower
+        this.shop = null;
+        this.preview = null;
+        this.selected = null;
+    }
+
+    Game.prototype.speed = function () {
+        return this.speeds[this.speedIndex];
+    };
+
+    Game.prototype.canAfford = function (cost) {
+        return dbg.unlimited_coins || this.coins >= cost;
+    };
+
+    Game.prototype.pay = function (cost) {
+        if (!dbg.unlimited_coins) this.coins -= cost;
+    };
+
+    // one simulation step of dt seconds
+    Game.prototype.step = function (dt) {
+        if (this.result) return;
+        var self = this;
+        this.time += dt;
+        this.waves.update(dt, this.monsters.length, function (kind) {
+            self.monsters.push(MM.monster.create(self, kind));
+        });
+        this.monsters.forEach(function (m) {
+            if (m.alive && MM.monster.update(m, dt)) self.escape(m);
+        });
+        this.towers.forEach(function (t) { MM.tower.update(t, self, dt); });
+        this.projectiles.forEach(function (p) { MM.projectile.update(p, self, dt); });
+        this.monsters = this.monsters.filter(function (m) { return m.alive; });
+        this.projectiles = this.projectiles.filter(function (p) { return !p.done; });
+        this.flights.forEach(function (f) { f.t += dt; });
+        this.flights = this.flights.filter(function (f) { return f.t < cfg.coins.flight_time; });
+
+        if (this.hearts <= 0) {
+            this.result = "lost";
+        } else if (this.waves.phase === "done" && this.monsters.length === 0) {
+            this.result = "won";
+        }
+        // the simulation stops here; the coins in flight are counted already
+        if (this.result) this.flights = [];
+    };
+
+    // a monster reached the exit
+    Game.prototype.escape = function (m) {
+        m.alive = false;
+        if (!dbg.no_heart_loss) {
+            this.hearts = Math.max(0, this.hearts - (m.boss ? cfg.hearts.boss : cfg.hearts.monster));
+        }
+    };
+
+    Game.prototype.damage = function (m, amount) {
+        if (!m.alive) return;
+        m.hp -= amount;
+        if (m.hp > 0) return;
+        m.alive = false;
+        // coins count at once; the flying coins only show it (balance.md)
+        this.coins += m.coins;
+        var n = Math.min(m.coins, cfg.coins.max_sprites);
+        for (var i = 0; i < n; i++) {
+            this.flights.push({
+                x: m.x + (this.random() - 0.5) * m.w,
+                y: m.y - m.h / 2 + (this.random() - 0.5) * m.h / 2,
+                sprite: "c" + Math.floor(this.random() * 4),
+                // stagger the coins a little
+                t: -i * 0.05
+            });
+        }
+    };
+
+    Game.prototype.startEarly = function () {
+        this.coins += this.waves.startEarly();
+    };
+
+    Game.prototype.towerAt = function (x, y) {
+        var r = cfg.placement.footprint_radius;
+        for (var i = 0; i < this.towers.length; i++) {
+            var t = this.towers[i];
+            if (Math.hypot(t.x - x, t.y - y) <= r) return t;
+        }
+        return null;
+    };
+
+    Game.prototype.chooseShop = function (type) {
+        this.selected = null;
+        this.preview = null;
+        this.shop = this.shop === type ? null : type;
+    };
+
+    // a tap on the map at map position x, y. hitRadius is how close the tap
+    // must be to the preview to build. returns false when no legal position
+    // was found for a preview.
+    Game.prototype.tapMap = function (x, y, hitRadius) {
+        var t = this.towerAt(x, y);
+        if (t && !(this.preview && Math.hypot(this.preview.x - x, this.preview.y - y) <= hitRadius)) {
+            this.shop = null;
+            this.preview = null;
+            this.selected = t === this.selected ? null : t;
+            return true;
+        }
+        this.selected = null;
+        if (!this.shop) return true;
+        if (this.preview && Math.hypot(this.preview.x - x, this.preview.y - y) <= hitRadius) {
+            return this.build();
+        }
+        this.preview = this.map.snap(x, y, this.towers);
+        return this.preview !== null;
+    };
+
+    Game.prototype.build = function () {
+        var cost = cfg.tower[this.shop].cost;
+        if (!this.canAfford(cost)) return false;
+        this.pay(cost);
+        this.towers.push(MM.tower.create(this.shop, this.preview.x, this.preview.y));
+        this.shop = null;
+        this.preview = null;
+        return true;
+    };
+
+    return Game;
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/input.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,48 @@
+// pointer events: mouse and touch alike, nothing relies on hover
+
+window.MM = window.MM || {};
+
+MM.input = (function () {
+    "use strict";
+
+    // how close a tap must be to the placement preview to build, css pixels
+    var PREVIEW_HIT = 28;
+    var REFUSED_TIME = 500;
+
+    // app: {canvas, game(), layout(), restart(), view}
+    function attach(app) {
+        var c = app.canvas;
+        c.addEventListener("pointerdown", function (e) {
+            e.preventDefault();
+            var r = c.getBoundingClientRect();
+            tap(app, e.clientX - r.left, e.clientY - r.top);
+        });
+        // block the context menu, double tap zoom and pinch gestures
+        c.addEventListener("contextmenu", function (e) { e.preventDefault(); });
+        c.addEventListener("touchstart", function (e) { e.preventDefault(); }, { passive: false });
+        document.addEventListener("gesturestart", function (e) { e.preventDefault(); });
+        document.addEventListener("dblclick", function (e) { e.preventDefault(); });
+    }
+
+    function tap(app, x, y) {
+        var game = app.game(), L = app.layout();
+        var b = MM.ui.hit(game, L, x, y);
+        if (b) {
+            if (b.id === "restart") app.restart();
+            else if (b.id === "pause") game.paused = !game.paused;
+            else if (b.id === "speed") game.speedIndex = (game.speedIndex + 1) % game.speeds.length;
+            else if (b.id === "early") game.startEarly();
+            else if (b.id === "shop" && game.canAfford(MM.config.tower[b.tower].cost)) game.chooseShop(b.tower);
+            return;
+        }
+        if (game.result) return;
+        var mx = (x - L.ox) / L.scale, my = (y - L.oy) / L.scale;
+        if (mx < 0 || my < 0 || mx > game.map.width || my > game.map.height) return;
+        var hitR = Math.max(MM.config.placement.footprint_radius, PREVIEW_HIT / L.scale);
+        if (!game.tapMap(mx, my, hitR)) {
+            app.view.refused = { x: mx, y: my, until: performance.now() + REFUSED_TIME };
+        }
+    }
+
+    return { attach: attach };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/main.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,82 @@
+// start-up and main loop
+
+window.MM = window.MM || {};
+
+(function () {
+    "use strict";
+
+    var cfg = MM.config;
+    var STEP = 1 / 60;
+    // most simulation steps per frame and game speed step; the rest of a
+    // long frame is dropped, so the game slows down instead of freezing
+    var MAX_STEPS = 4;
+
+    var canvas = document.getElementById("game");
+    var ctx = canvas.getContext("2d");
+    var game = null;
+    var L = null;
+    var view = { dpr: 1, now: 0, refused: null, stats: { ms: 0 } };
+
+    function newGame() {
+        var m = MM.util.clamp(cfg.debug.start_map, 0, MM.maps.length - 1);
+        var seed = cfg.debug.seed || (Math.random() * 4294967296) >>> 0;
+        game = new MM.Game(m, seed);
+        resize();
+    }
+
+    // canvas resolution follows the device pixel ratio
+    function resize() {
+        var w = canvas.clientWidth, h = canvas.clientHeight;
+        view.dpr = window.devicePixelRatio || 1;
+        canvas.width = Math.round(w * view.dpr);
+        canvas.height = Math.round(h * view.dpr);
+        if (game) L = MM.ui.layout(w, h, game.map);
+    }
+
+    var last = 0, acc = 0;
+
+    function frame(now) {
+        var dt = last ? (now - last) / 1000 : 0;
+        last = now;
+        view.now = now;
+        var t0 = performance.now();
+
+        if (!game.paused && !game.result) {
+            var speed = game.speed();
+            acc += dt * speed;
+            var n = 0;
+            while (acc >= STEP && n < MAX_STEPS * speed) {
+                game.step(STEP);
+                acc -= STEP;
+                n++;
+            }
+            if (n >= MAX_STEPS * speed) acc = 0;
+        } else {
+            acc = 0;
+        }
+
+        ctx.setTransform(1, 0, 0, 1, 0, 0);
+        ctx.fillStyle = "#e8e2d4";
+        ctx.fillRect(0, 0, canvas.width, canvas.height);
+        MM.render.draw(ctx, game, L, view);
+        MM.ui.draw(ctx, game, L, view);
+        MM.render.drawFlights(ctx, game, L, view);
+
+        view.stats.ms = view.stats.ms * 0.9 + (performance.now() - t0) * 0.1;
+        requestAnimationFrame(frame);
+    }
+
+    window.addEventListener("resize", resize);
+    MM.input.attach({
+        canvas: canvas,
+        view: view,
+        game: function () { return game; },
+        layout: function () { return L; },
+        restart: newGame
+    });
+    MM.assets.load(function (failed) {
+        if (failed.length) console.error("images not loaded:", failed);
+        newGame();
+        requestAnimationFrame(frame);
+    });
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/map.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,109 @@
+// placement lookup, snapping, route sampling
+
+window.MM = window.MM || {};
+
+MM.Route = (function () {
+    "use strict";
+
+    // a route from the build: a polyline with cumulative distances, so a
+    // point can be found by the distance walked
+    function Route(data) {
+        var p = data.points;
+        this.xs = [];
+        this.ys = [];
+        this.at = [];
+        var d = 0;
+        for (var i = 0; i < p.length; i += 2) {
+            if (i > 0) d += Math.hypot(p[i] - p[i - 2], p[i + 1] - p[i - 1]);
+            this.xs.push(p[i]);
+            this.ys.push(p[i + 1]);
+            this.at.push(d);
+        }
+        this.length = d;
+        this.value = data.value;
+        this.weight = data.weight;
+    }
+
+    // write the point at distance s along the route into out.x, out.y.
+    // out.seg remembers the segment, so the next search for a point
+    // further along starts there
+    Route.prototype.point = function (s, out) {
+        var at = this.at, n = at.length;
+        if (s <= 0) { out.x = this.xs[0]; out.y = this.ys[0]; return out; }
+        if (s >= this.length) { out.x = this.xs[n - 1]; out.y = this.ys[n - 1]; return out; }
+        var i = out.seg || 1;
+        if (i >= n || at[i - 1] > s) i = 1;
+        while (at[i] < s) i++;
+        out.seg = i;
+        var t = (s - at[i - 1]) / (at[i] - at[i - 1]);
+        out.x = this.xs[i - 1] + (this.xs[i] - this.xs[i - 1]) * t;
+        out.y = this.ys[i - 1] + (this.ys[i] - this.ys[i - 1]) * t;
+        return out;
+    };
+
+    return Route;
+})();
+
+MM.GameMap = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+
+    function GameMap(index) {
+        var d = MM.maps[index];
+        this.index = index;
+        this.data = d;
+        this.name = d.name;
+        this.width = d.width;
+        this.height = d.height;
+        this.routes = d.routes.map(function (r) { return new MM.Route(r); });
+    }
+
+    GameMap.prototype.legalCell = function (cx, cy) {
+        var d = this.data;
+        if (cx < 0 || cy < 0 || cx >= d.cols || cy >= d.rows) return false;
+        return d.grid.charCodeAt(cy * d.cols + cx) === 49;
+    };
+
+    // nearest legal tower position to x, y within the snap radius that keeps
+    // the minimum distance to the towers in the list. returns {x, y} or null.
+    GameMap.prototype.snap = function (x, y, towers) {
+        var p = cfg.placement, cell = this.data.cell;
+        var reach = Math.ceil(p.snap_radius / cell);
+        var cx0 = Math.floor(x / cell), cy0 = Math.floor(y / cell);
+        var best = null, bestD = p.snap_radius;
+        for (var cy = cy0 - reach; cy <= cy0 + reach; cy++) {
+            for (var cx = cx0 - reach; cx <= cx0 + reach; cx++) {
+                if (!this.legalCell(cx, cy)) continue;
+                var px = cx * cell + cell / 2, py = cy * cell + cell / 2;
+                var d = Math.hypot(px - x, py - y);
+                if (d > bestD) continue;
+                var free = true;
+                for (var i = 0; i < towers.length; i++) {
+                    if (Math.hypot(towers[i].x - px, towers[i].y - py) < p.min_tower_distance) {
+                        free = false;
+                        break;
+                    }
+                }
+                if (free) {
+                    best = { x: px, y: py };
+                    bestD = d;
+                }
+            }
+        }
+        return best;
+    };
+
+    // route weights for a monster of the given speed (balance.md, route
+    // preference). fixed weights from routes.toml take precedence.
+    GameMap.prototype.routeWeights = function (speed) {
+        var rp = cfg.route_preference;
+        var f = MM.util.clamp((speed - rp.reference_speed) / rp.reference_speed, -1, 1);
+        return this.routes.map(function (r) {
+            if (r.weight !== null) return r.weight;
+            return Math.max(rp.min_weight, 1 + rp.bias * f * (2 * r.value - 1));
+        });
+    };
+
+    return GameMap;
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/monster.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,74 @@
+// monsters: movement along a route, hops, hp
+
+window.MM = window.MM || {};
+
+MM.monster = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+    // share of the hop cycle spent in the air; the rest is the landing
+    var AIR = 0.8;
+
+    // a new monster of the given kind at the start of a route chosen by
+    // the map's route weights
+    function create(game, kind) {
+        var def = cfg.monster[kind];
+        var map = game.map;
+        var r = MM.util.pick(map.routeWeights(def.speed), game.random);
+        var size = MM.assets.size(kind, cfg.scale.sprite);
+        var m = {
+            kind: kind,
+            boss: !!def.boss,
+            route: map.routes[r],
+            routeIndex: r,
+            s: 0,
+            x: 0,
+            y: 0,
+            seg: 1,
+            hp: def.hp,
+            maxHp: def.hp,
+            speed: def.speed,
+            coins: def.coins,
+            w: size[0],
+            h: size[1],
+            hitRadius: cfg.animation.hit_radius * Math.min(size[0], size[1]),
+            // start at a random point of the hop cycle, so a group does not hop in step
+            phase: game.random(),
+            alive: true
+        };
+        m.route.point(0, m);
+        return m;
+    }
+
+    // advance by dt seconds. returns true when the monster reached the exit.
+    function update(m, dt) {
+        m.s += m.speed * dt;
+        m.phase = (m.phase + dt / cfg.animation.hop_time) % 1;
+        m.route.point(m.s, m);
+        return m.s >= m.route.length;
+    }
+
+    function remaining(m) {
+        return m.route.length - m.s;
+    }
+
+    // hop height and stretch for drawing: {lift, sx, sy}
+    function pose(m, time) {
+        var a = cfg.animation, p = m.phase, lift = 0, sx = 1, sy = 1;
+        if (p < AIR) {
+            var k = Math.sin(Math.PI * p / AIR);
+            lift = a.hop_height * k;
+            sx = 1 - a.stretch * k;
+            sy = 1 + a.stretch * k;
+        } else {
+            var q = Math.sin(Math.PI * (p - AIR) / (1 - AIR));
+            sx = 1 + a.squash * q;
+            sy = 1 - a.squash * q;
+        }
+        // slow breathing on top of the hops
+        var bob = a.idle_bob * Math.sin(time * 2 * Math.PI / 1.3 + m.phase * 6.28);
+        return { lift: lift, sx: sx * (1 - bob / 2), sy: sy * (1 + bob) };
+    }
+
+    return { create: create, update: update, remaining: remaining, pose: pose };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/projectile.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,48 @@
+// projectiles: fly towards their target and damage it on arrival
+
+window.MM = window.MM || {};
+
+MM.projectile = (function () {
+    "use strict";
+
+    function create(tower, target, damage) {
+        return {
+            kind: tower.def.projectile,
+            speed: tower.def.projectile_speed,
+            x: tower.x,
+            y: tower.y,
+            tx: target.x,
+            ty: target.y,
+            target: target,
+            damage: damage,
+            angle: Math.atan2(target.y - tower.y, target.x - tower.x),
+            done: false
+        };
+    }
+
+    // home in on the target. if it died first, fly on to its last position
+    // and disappear there without damage.
+    function update(p, game, dt) {
+        var t = p.target;
+        if (t && t.alive) {
+            p.tx = t.x;
+            p.ty = t.y;
+        } else {
+            t = null;
+        }
+        var dx = p.tx - p.x, dy = p.ty - p.y;
+        var d = Math.hypot(dx, dy);
+        var step = p.speed * dt;
+        var reach = t ? Math.max(step, t.hitRadius) : step;
+        if (d <= reach) {
+            if (t) game.damage(t, p.damage);
+            p.done = true;
+            return;
+        }
+        p.angle = Math.atan2(dy, dx);
+        p.x += dx / d * step;
+        p.y += dy / d * step;
+    }
+
+    return { create: create, update: update };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/render.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,174 @@
+// drawing of the map and everything on it. reads the game state, never
+// changes it. the top bar, shop and screens are drawn by ui.js.
+
+window.MM = window.MM || {};
+
+MM.render = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+    var dbg = cfg.debug;
+    var A = MM.assets;
+    // debug placement grid, drawn once per map into a canvas of its own
+    var gridCache = { map: null, canvas: null };
+
+    function gridCanvas(map) {
+        if (gridCache.map === map.index) return gridCache.canvas;
+        var d = map.data;
+        var c = document.createElement("canvas");
+        c.width = d.width;
+        c.height = d.height;
+        var g = c.getContext("2d");
+        g.fillStyle = "rgba(40, 160, 40, 0.55)";
+        for (var i = 0; i < d.grid.length; i++) {
+            if (d.grid.charCodeAt(i) !== 49) continue;
+            g.fillRect((i % d.cols) * d.cell, Math.floor(i / d.cols) * d.cell, d.cell - 1, d.cell - 1);
+        }
+        gridCache.map = map.index;
+        gridCache.canvas = c;
+        return c;
+    }
+
+    function circle(ctx, x, y, r, fill, stroke, width) {
+        ctx.beginPath();
+        ctx.arc(x, y, r, 0, Math.PI * 2);
+        if (fill) {
+            ctx.fillStyle = fill;
+            ctx.fill();
+        }
+        if (stroke) {
+            ctx.strokeStyle = stroke;
+            ctx.lineWidth = width;
+            ctx.stroke();
+        }
+    }
+
+    function drawRoutes(ctx, map) {
+        var colours = ["#d0009f", "#005aff", "#ff7800", "#00a03c", "#8c00ff", "#00b4c8", "#c82828", "#5a5a5a"];
+        map.routes.forEach(function (r, k) {
+            ctx.beginPath();
+            for (var i = 0; i < r.xs.length; i++) ctx.lineTo(r.xs[i], r.ys[i]);
+            ctx.strokeStyle = colours[k % colours.length];
+            ctx.lineWidth = 2;
+            ctx.stroke();
+        });
+    }
+
+    // t0 spikes: one p0 per side, pushed out during an attack
+    function drawSpikes(ctx, t, scale) {
+        var half = A.size(MM.tower.sprite(t), scale)[1] / 2;
+        var spike = A.size("p0", scale)[1];
+        var k = t.burst > 0 ? Math.sin(Math.PI * (1 - t.burst / MM.tower.BURST_TIME)) : 0;
+        var out = half - spike * 0.25 + k * (MM.tower.range(t) - half - spike * 0.5);
+        for (var side = 0; side < 4; side++) {
+            var a = -Math.PI / 2 + side * Math.PI / 2;
+            A.draw(ctx, "p0", t.x + Math.cos(a) * out, t.y + Math.sin(a) * out, scale, a);
+        }
+    }
+
+    function drawTower(ctx, t, alpha) {
+        var scale = cfg.scale.sprite;
+        ctx.globalAlpha = alpha;
+        if (t.def.projectile_speed === 0) drawSpikes(ctx, t, scale);
+        A.draw(ctx, MM.tower.sprite(t), t.x, t.y, scale, t.angle);
+        ctx.globalAlpha = 1;
+    }
+
+    function drawRange(ctx, x, y, r, mapScale) {
+        circle(ctx, x, y, r, "rgba(255, 255, 255, 0.25)", "rgba(40, 40, 40, 0.7)", 2 / mapScale);
+    }
+
+    function drawMonster(ctx, m, time) {
+        var pose = MM.monster.pose(m, time);
+        var img = A.img(m.kind);
+        ctx.save();
+        // feet on the ground point, so squash and stretch keep them down
+        ctx.translate(m.x, m.y + m.h / 2 - pose.lift);
+        ctx.scale(pose.sx, pose.sy);
+        ctx.drawImage(img, -m.w / 2, -m.h, m.w, m.h);
+        ctx.restore();
+
+        // hp bar, cut to the share of hp left over its darkened copy
+        var bar = A.size("hpm", cfg.scale.hp_bar);
+        var bx = m.x - bar[0] / 2, by = m.y - m.h / 2 - pose.lift - bar[1] - 2;
+        var share = Math.max(0, m.hp / m.maxHp);
+        var full = A.img("hpm"), empty = A.img("hpm_empty");
+        ctx.drawImage(empty, bx, by, bar[0], bar[1]);
+        if (share > 0) {
+            ctx.drawImage(full, 0, 0, full.naturalWidth * share, full.naturalHeight,
+                          bx, by, bar[0] * share, bar[1]);
+        }
+    }
+
+    // draw the map area. L is the layout from ui.js, view holds the canvas
+    // pixel ratio, wall clock and tap feedback.
+    function draw(ctx, game, L, view) {
+        var map = game.map, s = L.scale, dpr = view.dpr;
+        ctx.setTransform(dpr * s, 0, 0, dpr * s, dpr * L.ox, dpr * L.oy);
+        ctx.drawImage(A.img(map.name), 0, 0, map.width, map.height);
+
+        if (dbg.show_grid) ctx.drawImage(gridCanvas(map), 0, 0);
+        if (dbg.show_routes) drawRoutes(ctx, map);
+
+        game.towers.slice().sort(function (a, b) { return a.y - b.y; })
+            .forEach(function (t) { drawTower(ctx, t, 1); });
+        if (dbg.show_ranges) {
+            game.towers.forEach(function (t) { drawRange(ctx, t.x, t.y, MM.tower.range(t), s); });
+        }
+        if (game.selected) {
+            var t = game.selected;
+            drawRange(ctx, t.x, t.y, MM.tower.range(t), s);
+            drawTower(ctx, t, 1);
+        }
+        if (game.preview) {
+            var pv = MM.tower.create(game.shop, game.preview.x, game.preview.y);
+            drawRange(ctx, pv.x, pv.y, MM.tower.range(pv), s);
+            drawTower(ctx, pv, 0.65);
+        }
+
+        game.monsters.slice().sort(function (a, b) { return a.y - b.y; })
+            .forEach(function (m) { drawMonster(ctx, m, game.time); });
+        if (dbg.show_hit_areas) {
+            game.monsters.forEach(function (m) {
+                circle(ctx, m.x, m.y, m.hitRadius, null, "rgba(255, 0, 0, 0.8)", 1 / s);
+            });
+        }
+
+        game.projectiles.forEach(function (p) {
+            A.draw(ctx, p.kind, p.x, p.y, cfg.scale.sprite, p.angle);
+        });
+
+        // refused placement: a red cross where the tap was
+        if (view.refused && view.now < view.refused.until) {
+            var f = view.refused, r = 10 / s;
+            ctx.strokeStyle = "#d02020";
+            ctx.lineWidth = 4 / s;
+            ctx.beginPath();
+            ctx.moveTo(f.x - r, f.y - r);
+            ctx.lineTo(f.x + r, f.y + r);
+            ctx.moveTo(f.x + r, f.y - r);
+            ctx.lineTo(f.x - r, f.y + r);
+            ctx.stroke();
+        }
+    }
+
+    // coins flying from the monster to the coin counter, in screen pixels
+    function drawFlights(ctx, game, L, view) {
+        var dpr = view.dpr, ft = cfg.coins.flight_time;
+        ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+        game.flights.forEach(function (f) {
+            var u = MM.util.clamp(f.t / ft, 0, 1);
+            var e = MM.util.easeIn(u);
+            var sx = L.ox + f.x * L.scale, sy = L.oy + f.y * L.scale;
+            var x = MM.util.lerp(sx, L.coinIcon.x, e);
+            var y = MM.util.lerp(sy, L.coinIcon.y, e) - 40 * Math.sin(Math.PI * u);
+            var start = A.size(f.sprite, cfg.scale.coin)[0] * L.scale;
+            var size = MM.util.lerp(start, L.coinIcon.size, e);
+            var img = A.img(f.sprite);
+            var h = size * img.naturalHeight / img.naturalWidth;
+            ctx.drawImage(img, x - size / 2, y - h / 2, size, h);
+        });
+    }
+
+    return { draw: draw, drawFlights: drawFlights };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/tower.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,80 @@
+// towers: targeting and attacks
+
+window.MM = window.MM || {};
+
+MM.tower = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+    // how long a melee attack shows its spikes pushed out
+    var BURST_TIME = 0.3;
+
+    function create(type, x, y) {
+        return {
+            type: type,
+            def: cfg.tower[type],
+            level: 1,
+            x: x,
+            y: y,
+            angle: -Math.PI / 2,
+            cooldown: 0,
+            burst: 0
+        };
+    }
+
+    function sprite(t) {
+        return t.level === 1 ? t.type : t.type + "_" + t.level;
+    }
+
+    function range(t) {
+        return t.def.range[t.level - 1];
+    }
+
+    function damage(t) {
+        return t.def.damage[t.level - 1];
+    }
+
+    function inRange(t, m) {
+        var r = range(t);
+        var dx = m.x - t.x, dy = m.y - t.y;
+        return dx * dx + dy * dy <= r * r;
+    }
+
+    // the monster in range that is furthest along, that is with the least
+    // distance left to its exit
+    function target(t, monsters) {
+        var best = null, left = Infinity;
+        for (var i = 0; i < monsters.length; i++) {
+            var m = monsters[i];
+            if (!m.alive || !inRange(t, m)) continue;
+            var l = MM.monster.remaining(m);
+            if (l < left) {
+                left = l;
+                best = m;
+            }
+        }
+        return best;
+    }
+
+    function update(t, game, dt) {
+        if (t.cooldown > 0) t.cooldown -= dt;
+        if (t.burst > 0) t.burst -= dt;
+        var melee = t.def.projectile_speed === 0;
+        var m = target(t, game.monsters);
+        if (!m) return;
+        if (!melee) t.angle = Math.atan2(m.y - t.y, m.x - t.x);
+        if (t.cooldown > 0) return;
+        t.cooldown += t.def.attack_time;
+        if (melee) {
+            // every monster in range at once
+            var hit = game.monsters.filter(function (o) { return o.alive && inRange(t, o); });
+            hit.forEach(function (o) { game.damage(o, damage(t)); });
+            t.burst = BURST_TIME;
+        } else {
+            game.projectiles.push(MM.projectile.create(t, m, damage(t)));
+        }
+    }
+
+    return { create: create, update: update, sprite: sprite, range: range,
+             BURST_TIME: BURST_TIME };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/ui.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,249 @@
+// screen layout, top bar, tower shop and end screens. icons are placeholder
+// shapes until the drawings arrive (art.md); numbers use a system font.
+
+window.MM = window.MM || {};
+
+MM.ui = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+    var A = MM.assets;
+    var TOP = 60;           // top bar height, css pixels
+    var SHOP = 96;          // shop width (landscape) or height (portrait)
+    var BUTTON = 52;        // top bar buttons, at least 48 for touch
+    var SHOP_BUTTON = 80;
+    var INK = "#3a3530";
+    var PAPER = "#f6f1e6";
+    var FONT = "bold 22px system-ui, -apple-system, Segoe UI, sans-serif";
+    var TOWERS = ["t0", "t1", "t2", "t3"];
+
+    // positions of everything on screen for a window of w x h css pixels
+    function layout(w, h, map) {
+        var land = w >= h;
+        var area = land ? { x: 0, y: TOP, w: w - SHOP, h: h - TOP }
+                        : { x: 0, y: TOP, w: w, h: h - TOP - SHOP };
+        var scale = Math.min(area.w / map.width, area.h / map.height);
+        var L = {
+            w: w, h: h, land: land, area: area, scale: scale,
+            ox: area.x + (area.w - map.width * scale) / 2,
+            oy: area.y + (area.h - map.height * scale) / 2,
+            shop: land ? { x: w - SHOP, y: TOP, w: SHOP, h: h - TOP }
+                       : { x: 0, y: h - SHOP, w: w, h: SHOP },
+            coinIcon: { x: 26, y: TOP / 2, size: 28 }
+        };
+        return L;
+    }
+
+    // the buttons for the current state, each {id, x, y, w, h}
+    function buttons(game, L) {
+        var out = [];
+        var y = (TOP - BUTTON) / 2;
+        if (game.result) {
+            out.push({ id: "restart", x: L.w / 2 - 48, y: L.h / 2 + 50, w: 96, h: 96 });
+            return out;
+        }
+        out.push({ id: "pause", x: L.w - BUTTON - 8, y: y, w: BUTTON, h: BUTTON });
+        out.push({ id: "speed", x: L.w - 2 * BUTTON - 16, y: y, w: BUTTON, h: BUTTON });
+        if (game.waves.phase === "break") {
+            out.push({ id: "early", x: L.w - 2 * BUTTON - 150, y: y, w: 126, h: BUTTON });
+        }
+        TOWERS.forEach(function (t, i) {
+            var pos = 10 + i * (SHOP_BUTTON + 10);
+            var b = L.land ? { x: L.shop.x + (SHOP - SHOP_BUTTON) / 2, y: L.shop.y + pos }
+                           : { x: L.shop.x + pos, y: L.shop.y + (SHOP - SHOP_BUTTON) / 2 };
+            b.id = "shop";
+            b.tower = t;
+            b.w = b.h = SHOP_BUTTON;
+            out.push(b);
+        });
+        return out;
+    }
+
+    function hit(game, L, x, y) {
+        var list = buttons(game, L);
+        for (var i = 0; i < list.length; i++) {
+            var b = list[i];
+            if (x >= b.x && x < b.x + b.w && y >= b.y && y < b.y + b.h) return b;
+        }
+        return null;
+    }
+
+    function text(ctx, s, x, y, align, size) {
+        ctx.font = size ? FONT.replace("22px", size + "px") : FONT;
+        ctx.textAlign = align || "left";
+        ctx.textBaseline = "middle";
+        ctx.lineWidth = 4;
+        ctx.strokeStyle = PAPER;
+        ctx.strokeText(s, x, y);
+        ctx.fillStyle = INK;
+        ctx.fillText(s, x, y);
+    }
+
+    // a sprite fitted into a box of size s, centred on x, y
+    function icon(ctx, name, x, y, s) {
+        var img = A.img(name);
+        var k = s / Math.max(img.naturalWidth, img.naturalHeight);
+        var w = img.naturalWidth * k, h = img.naturalHeight * k;
+        ctx.drawImage(img, x - w / 2, y - h / 2, w, h);
+    }
+
+    function heart(ctx, x, y, s, fill) {
+        ctx.beginPath();
+        ctx.moveTo(x, y + s * 0.4);
+        ctx.bezierCurveTo(x - s * 0.6, y, x - s * 0.5, y - s * 0.5, x, y - s * 0.2);
+        ctx.bezierCurveTo(x + s * 0.5, y - s * 0.5, x + s * 0.6, y, x, y + s * 0.4);
+        ctx.fillStyle = fill;
+        ctx.fill();
+        ctx.lineWidth = 2;
+        ctx.strokeStyle = INK;
+        ctx.stroke();
+    }
+
+    function triangle(ctx, x, y, s) {
+        ctx.beginPath();
+        ctx.moveTo(x - s * 0.35, y - s * 0.45);
+        ctx.lineTo(x + s * 0.45, y);
+        ctx.lineTo(x - s * 0.35, y + s * 0.45);
+        ctx.closePath();
+        ctx.fill();
+    }
+
+    function star(ctx, x, y, r) {
+        ctx.beginPath();
+        for (var i = 0; i < 10; i++) {
+            var a = -Math.PI / 2 + i * Math.PI / 5, rr = i % 2 ? r * 0.45 : r;
+            ctx.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr);
+        }
+        ctx.closePath();
+        ctx.fillStyle = "#f2c230";
+        ctx.fill();
+        ctx.lineWidth = 3;
+        ctx.strokeStyle = INK;
+        ctx.stroke();
+    }
+
+    function restartIcon(ctx, x, y, r) {
+        ctx.lineWidth = 7;
+        ctx.strokeStyle = INK;
+        ctx.beginPath();
+        ctx.arc(x, y, r, -Math.PI * 0.35, Math.PI * 1.45);
+        ctx.stroke();
+        var a = -Math.PI * 0.35, tx = x + Math.cos(a) * r, ty = y + Math.sin(a) * r;
+        ctx.fillStyle = INK;
+        ctx.beginPath();
+        ctx.moveTo(tx + 12, ty - 4);
+        ctx.lineTo(tx - 8, ty - 12);
+        ctx.lineTo(tx - 2, ty + 10);
+        ctx.closePath();
+        ctx.fill();
+    }
+
+    function box(ctx, b, fill, line) {
+        ctx.fillStyle = fill;
+        ctx.strokeStyle = line || INK;
+        ctx.lineWidth = 2;
+        ctx.beginPath();
+        if (ctx.roundRect) ctx.roundRect(b.x, b.y, b.w, b.h, 10);
+        else ctx.rect(b.x, b.y, b.w, b.h);
+        ctx.fill();
+        ctx.stroke();
+    }
+
+    function drawButton(ctx, game, b) {
+        var cx = b.x + b.w / 2, cy = b.y + b.h / 2;
+        if (b.id === "pause") {
+            box(ctx, b, game.paused ? "#ffe9a8" : PAPER);
+            ctx.fillStyle = INK;
+            if (game.paused) {
+                triangle(ctx, cx, cy, 26);
+            } else {
+                ctx.fillRect(cx - 10, cy - 12, 7, 24);
+                ctx.fillRect(cx + 3, cy - 12, 7, 24);
+            }
+        } else if (b.id === "speed") {
+            // one triangle per speed step; numbers for the debug speeds
+            var sp = game.speed();
+            box(ctx, b, sp > 1 ? "#ffe9a8" : PAPER);
+            ctx.fillStyle = INK;
+            if (sp <= 3) {
+                for (var i = 0; i < sp; i++) triangle(ctx, cx + (i - (sp - 1) / 2) * 12, cy, 20);
+            } else {
+                text(ctx, sp + "", cx, cy, "center");
+            }
+        } else if (b.id === "early") {
+            box(ctx, b, PAPER);
+            ctx.fillStyle = INK;
+            triangle(ctx, b.x + 20, cy, 22);
+            ctx.fillRect(b.x + 29, cy - 10, 4, 20);
+            text(ctx, Math.ceil(game.waves.left) + "", b.x + 58, cy, "center");
+            var bonus = game.waves.bonus();
+            if (bonus > 0) text(ctx, "+" + bonus, b.x + b.w - 6, cy, "right", 18);
+        } else if (b.id === "shop") {
+            var def = cfg.tower[b.tower];
+            var ok = game.canAfford(def.cost);
+            box(ctx, b, game.shop === b.tower ? "#ffe9a8" : PAPER,
+                game.shop === b.tower ? "#c08000" : INK);
+            ctx.globalAlpha = ok ? 1 : 0.35;
+            icon(ctx, b.tower, cx, b.y + 30, 46);
+            icon(ctx, "c0", b.x + 22, b.y + b.h - 14, 16);
+            text(ctx, def.cost + "", b.x + 34, b.y + b.h - 13, "left", 18);
+            ctx.globalAlpha = 1;
+        } else if (b.id === "restart") {
+            box(ctx, b, PAPER);
+            restartIcon(ctx, cx, cy, 26);
+        }
+    }
+
+    function draw(ctx, game, L, view) {
+        var dpr = view.dpr;
+        ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+
+        // top bar: coins, hearts, wave
+        ctx.fillStyle = "rgba(246, 241, 230, 0.92)";
+        ctx.fillRect(0, 0, L.w, TOP);
+        ctx.fillStyle = "rgba(246, 241, 230, 0.92)";
+        ctx.fillRect(L.shop.x, L.shop.y, L.shop.w, L.shop.h);
+        ctx.fillStyle = "rgba(58, 53, 48, 0.25)";
+        ctx.fillRect(0, TOP - 2, L.w, 2);
+        icon(ctx, "c0", L.coinIcon.x, L.coinIcon.y, L.coinIcon.size);
+        text(ctx, game.coins + "", 46, TOP / 2);
+        heart(ctx, 126, TOP / 2 + 2, 30, "#e03a3a");
+        text(ctx, game.hearts + "", 146, TOP / 2);
+        icon(ctx, "m0", 206, TOP / 2, 30);
+        text(ctx, game.waves.shown() + "/" + game.waves.list.length, 226, TOP / 2);
+
+        if (!game.result) buttons(game, L).forEach(function (b) { drawButton(ctx, game, b); });
+
+        if (game.paused && !game.result) {
+            ctx.fillStyle = "rgba(255, 255, 255, 0.18)";
+            ctx.fillRect(L.ox, L.oy, game.map.width * L.scale, game.map.height * L.scale);
+        }
+        if (game.result) {
+            ctx.fillStyle = "rgba(40, 35, 30, 0.45)";
+            ctx.fillRect(0, 0, L.w, L.h);
+            if (game.result === "won") {
+                star(ctx, L.w / 2, L.h / 2 - 40, 70);
+            } else {
+                heart(ctx, L.w / 2, L.h / 2 - 30, 140, "#8a8a8a");
+                ctx.strokeStyle = INK;
+                ctx.lineWidth = 5;
+                ctx.beginPath();
+                ctx.moveTo(L.w / 2 - 6, L.h / 2 - 72);
+                ctx.lineTo(L.w / 2 + 10, L.h / 2 - 40);
+                ctx.lineTo(L.w / 2 - 10, L.h / 2 - 20);
+                ctx.lineTo(L.w / 2 + 4, L.h / 2 + 22);
+                ctx.stroke();
+            }
+            buttons(game, L).forEach(function (b) { drawButton(ctx, game, b); });
+        }
+
+        if (cfg.debug.show_stats && view.stats) {
+            var st = view.stats;
+            text(ctx, st.ms.toFixed(1) + " ms  " + game.monsters.length + " m  " +
+                 game.towers.length + " t  " + game.projectiles.length + " p  seed " + game.seed,
+                 8, L.h - 14, "left", 14);
+        }
+    }
+
+    return { layout: layout, hit: hit, draw: draw };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/util.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,58 @@
+// vector maths, random numbers, easing
+
+window.MM = window.MM || {};
+
+MM.util = (function () {
+    "use strict";
+
+    function clamp(v, lo, hi) {
+        return v < lo ? lo : v > hi ? hi : v;
+    }
+
+    function lerp(a, b, t) {
+        return a + (b - a) * t;
+    }
+
+    function dist(ax, ay, bx, by) {
+        return Math.hypot(bx - ax, by - ay);
+    }
+
+    function deg(d) {
+        return d * Math.PI / 180;
+    }
+
+    function easeIn(t) {
+        return t * t;
+    }
+
+    function easeOut(t) {
+        return 1 - (1 - t) * (1 - t);
+    }
+
+    // seeded random numbers (mulberry32): returns a function giving [0, 1)
+    function rng(seed) {
+        var a = seed >>> 0;
+        return function () {
+            a = (a + 0x6d2b79f5) >>> 0;
+            var t = a;
+            t = Math.imul(t ^ (t >>> 15), t | 1);
+            t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
+            return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+        };
+    }
+
+    // pick an index from a list of weights with the random function r
+    function pick(weights, r) {
+        var total = 0, i;
+        for (i = 0; i < weights.length; i++) total += weights[i];
+        var x = r() * total;
+        for (i = 0; i < weights.length; i++) {
+            x -= weights[i];
+            if (x < 0) return i;
+        }
+        return weights.length - 1;
+    }
+
+    return { clamp: clamp, lerp: lerp, dist: dist, deg: deg, easeIn: easeIn,
+             easeOut: easeOut, rng: rng, pick: pick };
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/js/wave.js	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,89 @@
+// wave timing: breaks with countdown, spawning, early start bonus
+
+window.MM = window.MM || {};
+
+MM.Waves = (function () {
+    "use strict";
+
+    var cfg = MM.config;
+
+    // phases: "break" counts down to the next wave, "spawning" releases
+    // the wave's monsters, "clearing" waits until the wave's monsters are
+    // gone, "done" follows the last wave
+    function Waves(mapIndex, firstWave) {
+        this.list = cfg.maps[mapIndex].waves;
+        this.rate = cfg.maps[mapIndex].early_bonus;
+        this.next = firstWave;
+        this.phase = "break";
+        this.left = cfg.waves.first_break;
+        this.queue = [];
+        this.clock = 0;
+    }
+
+    // spawn times of a wave: a group starts after the previous group has
+    // finished spawning, plus its delay
+    function schedule(wave) {
+        var out = [], t = 0;
+        wave.groups.forEach(function (g, gi) {
+            var iv = g.interval !== undefined ? g.interval : cfg.waves.spawn_interval;
+            if (gi > 0) t += g.delay || 0;
+            for (var i = 0; i < g.count; i++) {
+                if (i > 0) t += iv;
+                out.push({ time: t, monster: g.monster });
+            }
+        });
+        return out;
+    }
+
+    // number of the wave shown in the top bar, from 1
+    Waves.prototype.shown = function () {
+        return Math.min(this.next + (this.phase === "break" ? 1 : 0), this.list.length);
+    };
+
+    Waves.prototype.bonus = function () {
+        return this.phase === "break" ? Math.floor(this.left * this.rate) : 0;
+    };
+
+    Waves.prototype.start = function () {
+        this.queue = schedule(this.list[this.next]);
+        this.clock = 0;
+        this.phase = "spawning";
+        this.next++;
+    };
+
+    // start the next wave during a break. returns the bonus coins.
+    Waves.prototype.startEarly = function () {
+        if (this.phase !== "break") return 0;
+        var b = this.bonus();
+        this.start();
+        return b;
+    };
+
+    // advance by dt. spawn(kind) creates a monster; alive is the number of
+    // monsters on the map.
+    Waves.prototype.update = function (dt, alive, spawn) {
+        if (this.phase === "break") {
+            this.left -= dt;
+            if (this.left <= 0) this.start();
+            return;
+        }
+        if (this.phase === "spawning") {
+            this.clock += dt;
+            while (this.queue.length && this.queue[0].time <= this.clock) {
+                spawn(this.queue.shift().monster);
+            }
+            if (!this.queue.length) this.phase = "clearing";
+            return;
+        }
+        if (this.phase === "clearing" && alive === 0) {
+            if (this.next >= this.list.length) {
+                this.phase = "done";
+            } else {
+                this.phase = "break";
+                this.left = cfg.waves.break;
+            }
+        }
+    };
+
+    return Waves;
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/game/style.css	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,20 @@
+html, body {
+    margin: 0;
+    padding: 0;
+    height: 100%;
+    overflow: hidden;
+    background: #e8e2d4;
+}
+
+canvas {
+    display: block;
+    width: 100vw;
+    height: 100vh;
+    height: 100dvh;
+    /* no browser zoom, scroll or selection gestures on the game */
+    touch-action: none;
+    user-select: none;
+    -webkit-user-select: none;
+    -webkit-touch-callout: none;
+    -webkit-tap-highlight-color: transparent;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/build.py	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,473 @@
+#!/usr/bin/env python3
+"""
+build the game data from art/ and config/ into game/assets/ and game/data/.
+
+usage: python3 tools/build.py [--force] [--watch]
+
+steps: sprites, tower levels, maps, masks, config, checks, previews. a step
+is skipped when all its outputs are newer than its inputs and the build
+scripts; --force runs every step. --watch reruns the build whenever a file
+in art/ or config/ changes.
+
+requires python 3.11 or later and pillow.
+"""
+
+import json
+import math
+import sys
+import time
+import tomllib
+from pathlib import Path
+
+from PIL import Image
+
+# keep tools/ free of __pycache__
+sys.dont_write_bytecode = True
+
+import images
+import masks
+import preview
+
+ROOT = Path(__file__).resolve().parent.parent
+ART = ROOT / "art"
+CONFIG = ROOT / "config"
+ASSETS = ROOT / "game" / "assets"
+DATA = ROOT / "game" / "data"
+TEMP = ROOT / "temp"
+PREVIEW = TEMP / "preview"
+# route data of the last mask step, read when the step is skipped
+MAPS_CACHE = TEMP / "build" / "maps.json"
+
+TOOLS = sorted((ROOT / "tools").glob("*.py"))
+HEADER = "// generated by tools/build.py from {src}, do not edit\n"
+
+SPRITES = (["m%d" % i for i in range(5)] + ["b%d" % i for i in range(4)]
+           + ["t%d" % i for i in range(4)] + ["p%d" % i for i in range(4)]
+           + ["c%d" % i for i in range(4)] + ["hpm", "hpb"])
+# empty part of an hp bar: a darkened copy (art.md)
+BAR_DARKEN = 0.35
+MAPS = 4
+MAP_QUALITY = 88
+# centre line smoothing: moving average half window, simplify tolerance
+ROUTE_SMOOTH = 8
+ROUTE_TOLERANCE = 0.8
+# number of decimals of route points in maps.js
+ROUTE_DECIMALS = 1
+
+warnings = []
+
+
+def warn(msg):
+    warnings.append(msg)
+    print("  warning:", msg)
+
+
+def stale(inputs, outputs, force):
+    """true when an output is missing or older than an input or a build script."""
+    if force:
+        return True
+    try:
+        oldest = min(p.stat().st_mtime for p in outputs)
+    except FileNotFoundError:
+        return True
+    newest = max(p.stat().st_mtime for p in list(inputs) + TOOLS)
+    return newest > oldest
+
+
+def write_text(path, text):
+    path.parent.mkdir(parents=True, exist_ok=True)
+    path.write_text(text)
+
+
+# 1. sprites
+
+def step_sprites(force):
+    inputs = [ART / f"{n}.png" for n in SPRITES]
+    outputs = [ASSETS / f"{n}.png" for n in SPRITES] + [ASSETS / "hpm_empty.png", ASSETS / "hpb_empty.png"]
+    if not stale(inputs, outputs, force):
+        print("sprites: up to date")
+        return False
+    ASSETS.mkdir(parents=True, exist_ok=True)
+    for n in SPRITES:
+        im = images.trim(Image.open(ART / f"{n}.png").convert("RGBA"))
+        im.save(ASSETS / f"{n}.png", optimize=True)
+        if n in ("hpm", "hpb"):
+            images.darken(im, BAR_DARKEN).save(ASSETS / f"{n}_empty.png", optimize=True)
+    print(f"sprites: wrote {len(SPRITES)} sprites and 2 empty bars")
+    return True
+
+
+# 2. tower levels
+
+def step_towers(force):
+    changed = False
+    for t in range(4):
+        src = ART / f"t{t}p.png"
+        outputs = [ASSETS / f"t{t}_{lv}.png" for lv in range(2, 6)]
+        if not stale([src], outputs, force):
+            continue
+        for lv, im in enumerate(images.tower_levels(src), start=2):
+            im.save(ASSETS / f"t{t}_{lv}.png", optimize=True)
+        changed = True
+    print("towers:", "wrote levels 2-5" if changed else "up to date")
+    return changed
+
+
+# 3. maps
+
+def step_maps(force):
+    changed = False
+    for m in range(MAPS):
+        src, dst = ART / f"map{m}.png", ASSETS / f"map{m}.jpg"
+        if stale([src], [dst], force):
+            images.map_copy(src, dst, MAP_QUALITY)
+            changed = True
+    print("maps:", "wrote jpeg copies" if changed else "up to date")
+    return changed
+
+
+# 4. masks
+
+def apply_corrections(m, routes, fix):
+    """
+    apply routes.toml corrections for map m to a list of route dicts.
+    each route dict has points, and gets a fixed weight or None.
+    """
+    for r in routes:
+        r["weight"] = None
+    for spec in fix.get("route", []):
+        pts = [tuple(p) for p in spec["points"]]
+        if "replace" in spec:
+            routes[spec["replace"]]["points"] = pts
+            routes[spec["replace"]]["manual"] = True
+        else:
+            routes.append({"points": pts, "weight": None, "manual": True})
+    for k, v in fix.get("weights", {}).items():
+        routes[int(k)]["weight"] = float(v)
+    drop = set(fix.get("drop", []))
+    for i, r in enumerate(routes):
+        r["number"] = i
+    return [r for i, r in enumerate(routes) if i not in drop]
+
+
+def route_values(routes):
+    """
+    fill in length, turning and value of each route (balance.md, route
+    preference): the average of length relative to the longest route and
+    straightness relative to the straightest, that is the least turning.
+    """
+    for r in routes:
+        r["length"] = masks.polyline_length(r["points"])
+        r["turning"] = masks.turning(r["points"])
+    longest = max(r["length"] for r in routes)
+    least = min(r["turning"] for r in routes)
+    for r in routes:
+        straight = least / r["turning"] if r["turning"] else 1.0
+        r["value"] = (r["length"] / longest + straight) / 2
+
+
+def step_masks(cfg, force):
+    placement = cfg["placement"]
+    routes_toml = CONFIG / "routes.toml"
+    inputs = [ART / f"map{m}mask.png" for m in range(MAPS)] + [routes_toml]
+    outputs = [DATA / "maps.js", MAPS_CACHE]
+    cached = None
+    if MAPS_CACHE.exists():
+        cached = json.loads(MAPS_CACHE.read_text())
+    # the placement settings are part of the input, compared by value
+    if not stale(inputs, outputs, force) and cached and cached["placement"] == placement:
+        print("masks: up to date")
+        return cached["maps"], False
+
+    fixes = tomllib.loads(routes_toml.read_text()).get("map", {})
+    out = []
+    for m in range(MAPS):
+        t0 = time.time()
+        mask = masks.Mask(ART / f"map{m}mask.png")
+        cols, rows, grid = masks.placement_grid(mask, placement)
+        found = masks.extract_routes(mask, ROUTE_SMOOTH, ROUTE_TOLERANCE)
+        routes = [{"points": pts, "manual": False} for pts in found["routes"]]
+        routes = apply_corrections(m, routes, fixes.get(str(m), {}))
+        route_values(routes)
+        g = found["graph"]
+        out.append({
+            "name": f"map{m}",
+            "width": mask.w,
+            "height": mask.h,
+            "cell": placement["grid_cell"],
+            "cols": cols,
+            "rows": rows,
+            "grid": grid,
+            "path_width": found["width"],
+            "entrances": [b[:3] for b in found["entrances"]],
+            "exits": [b[:3] for b in found["exits"]],
+            "routes": routes,
+            "graph": {
+                "nodes": [list(p) for p in g.nodes.values()],
+                "edges": [e[2] for e in g.edges.values()],
+            },
+        })
+        print(f"masks: map{m} {len(routes)} route(s), {time.time() - t0:.1f} s")
+
+    write_maps_js(out)
+    MAPS_CACHE.parent.mkdir(parents=True, exist_ok=True)
+    MAPS_CACHE.write_text(json.dumps({"placement": placement, "maps": out}))
+    return out, True
+
+
+def write_maps_js(maps):
+    def rnd(v):
+        return round(v, ROUTE_DECIMALS)
+
+    js = []
+    for mp in maps:
+        js.append({
+            "name": mp["name"],
+            "image": f"assets/{mp['name']}.jpg",
+            "width": mp["width"],
+            "height": mp["height"],
+            "cell": mp["cell"],
+            "cols": mp["cols"],
+            "rows": mp["rows"],
+            "grid": mp["grid"],
+            "entrances": [[rnd(v) for v in b] for b in mp["entrances"]],
+            "exits": [[rnd(v) for v in b] for b in mp["exits"]],
+            "routes": [{
+                "points": [rnd(v) for p in r["points"] for v in p],
+                "length": rnd(r["length"]),
+                "turning": rnd(r["turning"]),
+                "value": round(r["value"], 3),
+                "weight": r["weight"],
+            } for r in mp["routes"]],
+        })
+    body = ",\n".join(json.dumps(m, separators=(",", ":")) for m in js)
+    write_text(DATA / "maps.js", HEADER.format(src="art/map*mask.png and config/routes.toml")
+               + "window.MM = window.MM || {};\nMM.maps = [\n" + body + "\n];\n")
+
+
+# 5. config
+
+class ConfigError(Exception):
+    pass
+
+
+def need(table, key, kind, where):
+    if key not in table:
+        raise ConfigError(f"{where}: {key} missing")
+    v = table[key]
+    if kind is float:
+        ok = isinstance(v, (int, float)) and not isinstance(v, bool)
+    else:
+        ok = isinstance(v, kind)
+    if not ok:
+        raise ConfigError(f"{where}: {key} should be {kind.__name__}, is {v!r}")
+    return v
+
+
+def check_config(cfg):
+    """raise ConfigError on missing or malformed settings."""
+    for sec in ("scale", "monster", "animation", "route_preference", "tower", "placement",
+                "economy", "waves", "hearts", "coins", "controls", "art", "debug", "map"):
+        if sec not in cfg:
+            raise ConfigError(f"section [{sec}] missing")
+    for mid, mon in cfg["monster"].items():
+        for k in ("hp", "coins", "speed"):
+            need(mon, k, float, f"monster.{mid}")
+    for tid, tw in cfg["tower"].items():
+        for k in ("damage", "range"):
+            v = need(tw, k, list, f"tower.{tid}")
+            if len(v) != 5:
+                raise ConfigError(f"tower.{tid}: {k} needs 5 levels, has {len(v)}")
+        for k in ("cost", "attack_time", "projectile_speed"):
+            need(tw, k, float, f"tower.{tid}")
+        need(tw, "projectile", str, f"tower.{tid}")
+        if "slow" in tw and len(tw["slow"]) != 5:
+            raise ConfigError(f"tower.{tid}: slow needs 5 levels")
+    for k in ("footprint_radius", "max_gap", "min_tower_distance", "edge_distance",
+              "snap_radius", "grid_cell"):
+        need(cfg["placement"], k, float, "placement")
+    for m in range(MAPS):
+        mp = cfg["map"].get(str(m))
+        if mp is None:
+            raise ConfigError(f"[map.{m}] missing")
+        where = f"map.{m}"
+        for k in ("starting_coins", "early_bonus", "wave_count"):
+            need(mp, k, float, where)
+        need(mp, "monster_share", list, where)
+        for w, wave in enumerate(mp.get("wave", []), start=1):
+            for g, grp in enumerate(need(wave, "groups", list, f"{where} wave {w}"), start=1):
+                gw = f"{where} wave {w} group {g}"
+                mon = need(grp, "monster", str, gw)
+                if mon not in cfg["monster"]:
+                    raise ConfigError(f"{gw}: unknown monster {mon}")
+                need(grp, "count", int, gw)
+                for k in ("interval", "delay"):
+                    if k in grp:
+                        need(grp, k, float, gw)
+
+
+def sprite_table():
+    """name -> [width, height] of every image in game/assets/ except maps."""
+    out = {}
+    for p in sorted(ASSETS.glob("*.png")):
+        with Image.open(p) as im:
+            out[p.stem] = list(im.size)
+    return out
+
+
+def step_config(cfg, force, assets_changed):
+    src = CONFIG / "game.toml"
+    dst = DATA / "config.js"
+    if not stale([src], [dst], force) and not assets_changed:
+        print("config: up to date")
+        return
+    out = {k: v for k, v in cfg.items() if k != "map"}
+    out["maps"] = []
+    for m in range(MAPS):
+        mp = dict(cfg["map"][str(m)])
+        mp["waves"] = mp.pop("wave", [])
+        out["maps"].append(mp)
+    out["sprites"] = sprite_table()
+    write_text(dst, HEADER.format(src="config/game.toml")
+               + "window.MM = window.MM || {};\nMM.config = "
+               + json.dumps(out, indent=1) + ";\n")
+    print("config: wrote game/data/config.js")
+
+
+# 6. checks
+
+def wave_totals(cfg, waves):
+    """return per monster counts, regular coins, boss coins, regular hp."""
+    counts = {}
+    for wave in waves:
+        for grp in wave["groups"]:
+            counts[grp["monster"]] = counts.get(grp["monster"], 0) + grp["count"]
+    mons = cfg["monster"]
+    reg = sum(n * mons[k]["coins"] for k, n in counts.items() if not mons[k].get("boss"))
+    boss = sum(n * mons[k]["coins"] for k, n in counts.items() if mons[k].get("boss"))
+    hp = sum(n * mons[k]["hp"] for k, n in counts.items() if not mons[k].get("boss"))
+    return counts, reg, boss, hp
+
+
+def step_checks(cfg, maps):
+    print("\nchecks")
+    mons = cfg["monster"]
+    regular = sorted(k for k, v in mons.items() if not v.get("boss"))
+    speeds = sorted({v["speed"] for v in mons.values()})
+    for m, mp in enumerate(maps):
+        c = cfg["map"][str(m)]
+        print(f"\nmap{m}: {mp['width']}x{mp['height']}, path width {mp['path_width']:.0f},"
+              f" {mp['grid'].count('1')} placement cells")
+        if len(mp["entrances"]) == 0 or len(mp["exits"]) == 0:
+            warn(f"map{m}: no entrance or no exit found")
+        if not mp["routes"]:
+            warn(f"map{m}: no routes")
+        for r in mp["routes"]:
+            times = ", ".join(f"{r['length'] / s:.0f}" for s in speeds)
+            fixed = f", weight {r['weight']}" if r["weight"] is not None else ""
+            manual = ", manual" if r.get("manual") else ""
+            print(f"  route {r['number']}: length {r['length']:.0f}, turning {r['turning']:.0f} deg,"
+                  f" value {r['value']:.2f}{fixed}{manual}; walk time {times} s"
+                  f" at speed {', '.join(str(s) for s in speeds)}")
+
+        waves = c.get("wave", [])
+        if len(waves) != c["wave_count"]:
+            warn(f"map{m}: {len(waves)} waves, wave_count says {c['wave_count']}")
+        if not waves:
+            continue
+        counts, reg, boss, hp = wave_totals(cfg, waves)
+        target = c["starting_coins"] * cfg["economy"]["coin_total_factor"]
+        total = reg + boss
+        print("  monsters: " + ", ".join(f"{k} {counts.get(k, 0)}" for k in sorted(counts))
+              + f", {sum(counts.values())} in all")
+        share = [100 * counts.get(k, 0) * mons[k]["coins"] / reg if reg else 0 for k in regular]
+        print("  coin share %: " + ", ".join(f"{k} {s:.0f} ({t})" for k, s, t
+                                             in zip(regular, share, c["monster_share"])))
+        print(f"  coins: regular {reg}, boss {boss}, total {total}, target {target:.0f};"
+              f" regular hp {hp}")
+        if abs(total - target) > cfg["economy"]["coin_tolerance"] * target:
+            warn(f"map{m}: coins {total} are more than"
+                 f" {cfg['economy']['coin_tolerance'] * 100:.0f} % off the target {target:.0f}")
+        per_wave = []
+        for w, wave in enumerate(waves, start=1):
+            _, r, b, _ = wave_totals(cfg, [wave])
+            per_wave.append(r + b)
+        print("  coins per wave: " + ", ".join(str(v) for v in per_wave))
+
+        last = waves[-1]["groups"]
+        bosses = [g["monster"] for w in waves for g in w["groups"] if mons[g["monster"]].get("boss")]
+        if bosses != [f"b{m}"] or not mons[last[-1]["monster"]].get("boss") or last[-1]["count"] != 1:
+            warn(f"map{m}: expected one b{m} as the last group of the last wave")
+        bonus = c["early_bonus"] * (cfg["waves"]["first_break"]
+                                    + cfg["waves"]["break"] * (len(waves) - 1))
+        print(f"  early start bonus if every break is skipped: {math.floor(bonus)}")
+
+
+# 7. previews
+
+def step_previews(maps, force, changed):
+    outputs = [PREVIEW / f"map{m}.png" for m in range(MAPS)] + [PREVIEW / "towers.png"]
+    if not changed and not stale([], outputs, force):
+        print("previews: up to date")
+        return
+    PREVIEW.mkdir(parents=True, exist_ok=True)
+    for m, mp in enumerate(maps):
+        preview.map_preview(ART / f"map{m}.png", mp).save(PREVIEW / f"map{m}.png")
+        if len(mp["routes"]) > 1:
+            preview.route_sheet(ART / f"map{m}.png", mp).save(PREVIEW / f"map{m}_routes.png")
+    preview.tower_sheet(ASSETS).save(PREVIEW / "towers.png")
+    print(f"previews: wrote {PREVIEW.relative_to(ROOT)}/")
+
+
+def build(force):
+    warnings.clear()
+    try:
+        cfg = tomllib.loads((CONFIG / "game.toml").read_text())
+        check_config(cfg)
+    except (tomllib.TOMLDecodeError, ConfigError) as e:
+        print("config error:", e)
+        return False
+    changed = step_sprites(force)
+    changed |= step_towers(force)
+    step_maps(force)
+    maps, masks_changed = step_masks(cfg, force)
+    step_config(cfg, force, changed)
+    step_checks(cfg, maps)
+    step_previews(maps, force, changed or masks_changed)
+    print(f"\n{len(warnings)} warning(s)")
+    return True
+
+
+def watch():
+    def snapshot():
+        files = list(ART.iterdir()) + list(CONFIG.iterdir()) + TOOLS
+        return {p: p.stat().st_mtime for p in files if p.is_file()}
+
+    seen = None
+    while True:
+        now = snapshot()
+        if now != seen:
+            seen = now
+            print(time.strftime("\n== build %H:%M:%S"))
+            try:
+                build(False)
+            except Exception as e:  # keep watching after a failed build
+                print("build failed:", e)
+        time.sleep(1)
+
+
+def main():
+    args = sys.argv[1:]
+    if "--watch" in args:
+        # show each line at once, also when the output goes to a file
+        sys.stdout.reconfigure(line_buffering=True)
+        try:
+            watch()
+        except KeyboardInterrupt:
+            pass
+        return 0
+    return 0 if build("--force" in args) else 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/images.py	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,132 @@
+"""
+image steps of the build: sprite trimming, tower level strips, map copies.
+
+all functions take and return pillow images or file paths. no numpy; the
+per-pixel loops run on crops of a few hundred pixels and stay fast enough.
+"""
+
+from PIL import Image, ImageDraw, ImageFilter
+
+# pencil lines in the tower strips are darker than this luminance
+INK_LUM = 225
+# light pixels outside a drawing fade from opaque at LUM_OPAQUE to
+# transparent at LUM_CLEAR, which removes the white paper halo
+LUM_OPAQUE = 200
+LUM_CLEAR = 250
+# gaps in the pencil outline up to about twice this many pixels are closed
+# before the inside is filled
+GAP_CLOSE = 2
+
+
+def trim(im):
+    """return the image cropped to its non-transparent pixels."""
+    box = im.getbbox()
+    return im.crop(box) if box else im
+
+
+def darken(im, factor):
+    """return a copy with the colour scaled by factor, alpha unchanged."""
+    r, g, b, a = im.split()
+    r, g, b = (c.point(lambda v: int(v * factor)) for c in (r, g, b))
+    return Image.merge("RGBA", (r, g, b, a))
+
+
+def split_strip(im):
+    """
+    split a strip of drawings side by side at columns without pencil.
+
+    returns a list of crops, left to right. column runs narrower than
+    4 pixels count as specks and are dropped.
+    """
+    w, h = im.size
+    data = im.tobytes()
+    used = [False] * w
+    for y in range(h):
+        row = y * w * 4
+        for x in range(w):
+            i = row + x * 4
+            if data[i + 3] and data[i] + data[i + 1] + data[i + 2] < 3 * INK_LUM:
+                used[x] = True
+    runs = []
+    start = None
+    for x, u in enumerate(used + [False]):
+        if u and start is None:
+            start = x
+        elif not u and start is not None:
+            if x - start > 3:
+                runs.append((start, x))
+            start = None
+    # cut halfway between drawings so nothing of a drawing is lost
+    crops = []
+    for i, (a, b) in enumerate(runs):
+        left = 0 if i == 0 else (runs[i - 1][1] + a) // 2
+        right = w if i == len(runs) - 1 else (b + runs[i + 1][0]) // 2
+        crops.append(im.crop((left, 0, right, h)))
+    return crops
+
+
+def fill_inside(im):
+    """
+    fill the inside of a pencil outline drawing with white.
+
+    the outside is found by a flood fill from the image border over pixels
+    that are not pencil. outline gaps are closed first by thickening the
+    pencil lines, and the outside is grown back by the same amount
+    afterwards. light pixels outside become transparent. returns a new
+    image, trimmed.
+    """
+    pad = GAP_CLOSE + 2
+    src = Image.new("RGBA", (im.width + 2 * pad, im.height + 2 * pad))
+    src.paste(im, (pad, pad))
+    w, h = src.size
+    data = src.tobytes()
+
+    ink = bytearray(w * h)
+    for i in range(w * h):
+        j = i * 4
+        if data[j + 3] > 64 and data[j] + data[j + 1] + data[j + 2] < 3 * INK_LUM:
+            ink[i] = 255
+    size = 2 * GAP_CLOSE + 1
+    walls = Image.frombytes("L", (w, h), bytes(ink)).filter(ImageFilter.MaxFilter(size))
+
+    # outside: flood fill from a corner, which the padding keeps free
+    ImageDraw.floodfill(walls, (0, 0), 128, thresh=0)
+    outside = walls.point(lambda v: 255 if v == 128 else 0)
+    outside = outside.filter(ImageFilter.MaxFilter(size)).tobytes()
+
+    out = bytearray(w * h * 4)
+    for i in range(w * h):
+        j = i * 4
+        r, g, b, a = data[j:j + 4]
+        lum = (r + g + b) / 3
+        if outside[i]:
+            # fade light pixels out, keep pencil
+            if lum >= LUM_CLEAR:
+                a = 0
+            elif lum > LUM_OPAQUE:
+                a = int(a * (LUM_CLEAR - lum) / (LUM_CLEAR - LUM_OPAQUE))
+            out[j:j + 4] = bytes((r, g, b, a))
+        else:
+            # composite over white
+            k = a / 255
+            out[j:j + 4] = bytes((int(r * k + 255 * (1 - k)),
+                                  int(g * k + 255 * (1 - k)),
+                                  int(b * k + 255 * (1 - k)), 255))
+    return trim(Image.frombytes("RGBA", (w, h), bytes(out)))
+
+
+def tower_levels(path):
+    """return the four level images (levels 2-5) of a t*p strip."""
+    strip = Image.open(path).convert("RGBA")
+    levels = [fill_inside(c) for c in split_strip(strip)]
+    if len(levels) != 4:
+        raise ValueError(f"{path}: found {len(levels)} drawings, expected 4")
+    return levels
+
+
+def map_copy(src, dst, quality):
+    """write the map scan as jpeg. maps are opaque, so nothing is lost."""
+    im = Image.open(src)
+    if im.mode == "RGBA" and im.getextrema()[3][0] < 255:
+        raise ValueError(f"{src}: map has transparent pixels, jpeg would lose them")
+    im.convert("RGB").save(dst, quality=quality, optimize=True)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/masks.py	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,465 @@
+"""
+mask steps of the build: pixel classes, placement grid and routes.
+
+a mask is a map-sized image with a red path, blue entrances and green exits
+on a transparent background. pixels are indexed as y * width + x throughout.
+"""
+
+import math
+from collections import deque
+
+from PIL import Image, ImageDraw
+
+FREE, PATH, ENTRANCE, EXIT = 0, 1, 2, 3
+
+# 8-neighbour offsets in the order n, ne, e, se, s, sw, w, nw
+NEIGHBOURS = ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1))
+
+
+class Mask:
+    """pixel classes of one map mask."""
+
+    def __init__(self, path):
+        im = Image.open(path).convert("RGBA")
+        self.w, self.h = im.size
+        data = im.tobytes()
+        cls = bytearray(self.w * self.h)
+        # the edges are soft: a pixel counts when it is at least half covered,
+        # and belongs to its strongest colour channel
+        for i in range(self.w * self.h):
+            j = i * 4
+            if data[j + 3] >= 128:
+                r, g, b = data[j], data[j + 1], data[j + 2]
+                if r >= g and r >= b:
+                    cls[i] = PATH
+                elif b >= g:
+                    cls[i] = ENTRANCE
+                else:
+                    cls[i] = EXIT
+        self.cls = cls
+
+    def count(self, kind):
+        return self.cls.count(kind)
+
+    def blobs(self, kind):
+        """
+        return the connected areas of one class, largest first, as a list
+        of (centre x, centre y, radius, pixel count). radius is that of a
+        disc with the same area.
+        """
+        w, h, cls = self.w, self.h, self.cls
+        seen = bytearray(w * h)
+        out = []
+        for start in range(w * h):
+            if cls[start] != kind or seen[start]:
+                continue
+            seen[start] = 1
+            queue = deque([start])
+            sx = sy = n = 0
+            while queue:
+                i = queue.popleft()
+                x, y = i % w, i // w
+                sx += x
+                sy += y
+                n += 1
+                for dx, dy in NEIGHBOURS:
+                    nx, ny = x + dx, y + dy
+                    if 0 <= nx < w and 0 <= ny < h:
+                        k = ny * w + nx
+                        if cls[k] == kind and not seen[k]:
+                            seen[k] = 1
+                            queue.append(k)
+            out.append((sx / n, sy / n, math.sqrt(n / math.pi), n))
+        out.sort(key=lambda b: -b[3])
+        return out
+
+    def grown(self, kinds, radius):
+        """
+        return an L image, 255 on pixels of the given classes and on every
+        pixel within radius of one. drawn as discs around the edge pixels
+        of the area, which is the same as a distance test.
+        """
+        w, h, cls = self.w, self.h, self.cls
+        im = Image.new("L", (w, h), 0)
+        draw = ImageDraw.Draw(im)
+        inside = bytes(255 if c in kinds else 0 for c in cls)
+        im.paste(Image.frombytes("L", (w, h), inside))
+        for y in range(h):
+            row = y * w
+            for x in range(w):
+                if not inside[row + x]:
+                    continue
+                edge = (x == 0 or x == w - 1 or y == 0 or y == h - 1
+                        or not inside[row + x - 1] or not inside[row + x + 1]
+                        or not inside[row + x - w] or not inside[row + x + w])
+                if edge:
+                    draw.ellipse((x - radius, y - radius, x + radius, y + radius), fill=255)
+        return im
+
+
+def placement_grid(mask, p):
+    """
+    return (cols, rows, grid string) for placement table p. a cell is legal
+    when a tower footprint centred on it does not overlap the path,
+    entrances or exits, comes within max_gap of the path, and keeps
+    edge_distance from the map edge. the string has one '1' or '0' per
+    cell, row by row.
+    """
+    cell = p["grid_cell"]
+    r = p["footprint_radius"]
+    blocked = mask.grown((PATH, ENTRANCE, EXIT), r).tobytes()
+    near = mask.grown((PATH,), r + p["max_gap"]).tobytes()
+    edge = p["edge_distance"]
+    w, h = mask.w, mask.h
+    cols, rows = w // cell, h // cell
+    out = []
+    for cy in range(rows):
+        y = cy * cell + cell // 2
+        for cx in range(cols):
+            x = cx * cell + cell // 2
+            i = y * w + x
+            ok = (near[i] and not blocked[i]
+                  and edge <= x <= w - edge and edge <= y <= h - edge)
+            out.append("1" if ok else "0")
+    return cols, rows, "".join(out)
+
+
+def thin(shape, w, h):
+    """
+    reduce a 0/1 bytearray shape to a one pixel wide centre line
+    (zhang-suen thinning). the shape must not touch the image border.
+    only pixels next to removed ones are re-examined, which keeps the
+    pure python loop fast. returns the thinned bytearray.
+    """
+    img = bytearray(shape)
+    offs = [dy * w + dx for dx, dy in NEIGHBOURS]
+
+    def touches_background(i):
+        return any(not img[i + o] for o in offs)
+
+    cand = {i for i in range(w * h) if img[i] and touches_background(i)}
+    while True:
+        removed_any = False
+        for step in (0, 1):
+            remove = []
+            for i in cand:
+                if not img[i]:
+                    continue
+                p = [img[i + o] for o in offs]
+                b = sum(p)
+                if b < 2 or b > 6:
+                    continue
+                a = sum(1 for k in range(8) if not p[k] and p[(k + 1) % 8])
+                if a != 1:
+                    continue
+                n, e, s, wst = p[0], p[2], p[4], p[6]
+                if step == 0:
+                    if n and e and s or e and s and wst:
+                        continue
+                else:
+                    if n and e and wst or n and s and wst:
+                        continue
+                remove.append(i)
+            if remove:
+                removed_any = True
+                nxt = set()
+                for i in remove:
+                    img[i] = 0
+                for i in remove:
+                    for o in offs:
+                        if img[i + o]:
+                            nxt.add(i + o)
+                cand = (cand | nxt) - set(remove)
+        if not removed_any:
+            return img
+
+
+class Graph:
+    """
+    the centre line as a graph. nodes are junctions and line ends, edges
+    the pixel chains between them.
+
+    nodes: id -> (x, y)
+    edges: id -> [node a, node b, [(x, y), ...] from a to b]
+    """
+
+    def __init__(self, skel, w):
+        self.w = w
+        pix = {i for i, v in enumerate(skel) if v}
+        offs = [dy * w + dx for dx, dy in NEIGHBOURS]
+
+        def nbrs(i):
+            return [i + o for o in offs if i + o in pix]
+
+        # line pixels have exactly two neighbours, all others belong to nodes
+        nodepix = {i for i in pix if len(nbrs(i)) != 2}
+        node_of = {}
+        self.nodes = {}
+        for i in nodepix:
+            if i in node_of:
+                continue
+            nid = len(self.nodes)
+            members = []
+            queue = deque([i])
+            node_of[i] = nid
+            while queue:
+                j = queue.popleft()
+                members.append(j)
+                for k in nbrs(j):
+                    if k in nodepix and k not in node_of:
+                        node_of[k] = nid
+                        queue.append(k)
+            self.nodes[nid] = (sum(m % w for m in members) / len(members),
+                               sum(m // w for m in members) / len(members))
+        self.edges = {}
+        seen = set()
+        for i in nodepix:
+            for j in nbrs(i):
+                if j in nodepix or j in seen:
+                    continue
+                chain = [i, j]
+                seen.add(j)
+                prev, cur = i, j
+                while True:
+                    nxt = [k for k in nbrs(cur) if k != prev]
+                    if not nxt:
+                        break
+                    k = nxt[0]
+                    chain.append(k)
+                    if k in nodepix:
+                        break
+                    seen.add(k)
+                    prev, cur = cur, k
+                if chain[-1] not in nodepix:
+                    continue
+                a, b = node_of[i], node_of[chain[-1]]
+                if a == b and len(chain) < 8:
+                    continue
+                self.add_edge(a, b, [(c % w, c // w) for c in chain])
+
+    def add_edge(self, a, b, pts):
+        eid = max(self.edges, default=-1) + 1
+        self.edges[eid] = [a, b, pts]
+        return eid
+
+    def degree(self, n):
+        return sum((e[0] == n) + (e[1] == n) for e in self.edges.values())
+
+    def incident(self, n):
+        return [eid for eid, e in self.edges.items() if n in (e[0], e[1])]
+
+    def nearest_end(self, x, y):
+        """return the node of degree 1 nearest to a point."""
+        ends = [n for n in self.nodes if self.degree(n) == 1]
+        return min(ends, key=lambda n: math.dist(self.nodes[n], (x, y)))
+
+    def prune(self, keep, min_len):
+        """drop dead ends shorter than min_len, except at nodes in keep."""
+        changed = True
+        while changed:
+            changed = False
+            for n in list(self.nodes):
+                if n in keep or self.degree(n) != 1:
+                    continue
+                eid = self.incident(n)[0]
+                if polyline_length(self.edges[eid][2]) < min_len:
+                    del self.edges[eid]
+                    del self.nodes[n]
+                    changed = True
+            changed |= self.merge()
+
+    def contract(self, keep, min_len):
+        """
+        join junctions closer than min_len along an edge into one node,
+        except nodes in keep. thinning splits a wide crossing into several
+        nearby junctions; a loop attached to one of them could otherwise
+        not be walked without visiting a junction twice.
+        """
+        changed = True
+        while changed:
+            changed = False
+            # shortest first, so a chain of nearby junctions joins around its middle
+            for eid, (a, b, pts) in sorted(self.edges.items(),
+                                           key=lambda e: polyline_length(e[1][2])):
+                if a == b or a in keep or b in keep or polyline_length(pts) >= min_len:
+                    continue
+                del self.edges[eid]
+                # reattach the edges of b to a, extended by the joining pixels
+                for f in self.edges.values():
+                    if f[0] == b:
+                        f[0], f[2] = a, pts[:-1] + f[2]
+                    if f[1] == b:
+                        f[1], f[2] = a, f[2] + pts[::-1][1:]
+                del self.nodes[b]
+                changed = True
+                break
+
+    def merge(self):
+        """join the two edges at every node of degree 2. returns True on change."""
+        changed = False
+        for n in list(self.nodes):
+            inc = self.incident(n)
+            if len(inc) != 2 or inc[0] == inc[1]:
+                continue
+            e1, e2 = (self.edges[i] for i in inc)
+            p1 = e1[2] if e1[1] == n else e1[2][::-1]
+            a = e1[0] if e1[1] == n else e1[1]
+            p2 = e2[2] if e2[0] == n else e2[2][::-1]
+            b = e2[1] if e2[0] == n else e2[0]
+            if a == n or b == n:
+                continue
+            del self.edges[inc[0]], self.edges[inc[1]]
+            del self.nodes[n]
+            self.add_edge(a, b, p1 + p2[1:])
+            changed = True
+        return changed
+
+    def paths(self, start, goal):
+        """
+        list every route from start to goal that visits no node twice, as
+        a list of (points, key) pairs. a loop that leaves a node and comes
+        back to it (a self-loop edge) may be walked once, in either
+        direction; key names the edges taken without the loop directions,
+        so the two directions of the same route share a key.
+        """
+        out = []
+
+        def walk(n, visited, used, pts, key):
+            if n == goal:
+                out.append((pts, tuple(key)))
+                return
+            for eid in self.incident(n):
+                a, b, epts = self.edges[eid]
+                if a == b:
+                    if eid in used:
+                        continue
+                    for seg in (epts, epts[::-1]):
+                        walk(n, visited, used | {eid}, pts + seg[1:], key + [("loop", eid)])
+                    continue
+                if a == n:
+                    m, seg = b, epts
+                else:
+                    m, seg = a, epts[::-1]
+                if m in visited:
+                    continue
+                walk(m, visited | {m}, used, pts + seg[1:], key + [eid])
+
+        walk(start, {start}, frozenset(), [self.nodes[start]], [])
+        return out
+
+
+def polyline_length(pts):
+    return sum(math.dist(pts[i], pts[i + 1]) for i in range(len(pts) - 1))
+
+
+def turning(pts):
+    """sum of direction changes along a polyline, in degrees."""
+    total = 0.0
+    for i in range(1, len(pts) - 1):
+        a1 = math.atan2(pts[i][1] - pts[i - 1][1], pts[i][0] - pts[i - 1][0])
+        a2 = math.atan2(pts[i + 1][1] - pts[i][1], pts[i + 1][0] - pts[i][0])
+        d = (a2 - a1 + math.pi) % (2 * math.pi) - math.pi
+        total += abs(d)
+    return math.degrees(total)
+
+
+def resample(pts, step):
+    """return points spaced step apart along the polyline, ends kept."""
+    out = [pts[0]]
+    carry = 0.0
+    for i in range(len(pts) - 1):
+        (x0, y0), (x1, y1) = pts[i], pts[i + 1]
+        seg = math.dist(pts[i], pts[i + 1])
+        d = step - carry
+        while d <= seg:
+            t = d / seg
+            out.append((x0 + (x1 - x0) * t, y0 + (y1 - y0) * t))
+            d += step
+        carry = seg - (d - step)
+    if math.dist(out[-1], pts[-1]) > step * 0.25:
+        out.append(pts[-1])
+    else:
+        out[-1] = pts[-1]
+    return out
+
+
+def smooth(pts, half):
+    """moving average over 2 * half + 1 points; the window shrinks at the ends."""
+    n = len(pts)
+    out = []
+    for i in range(n):
+        k = min(half, i, n - 1 - i)
+        xs = pts[i - k:i + k + 1]
+        out.append((sum(p[0] for p in xs) / len(xs), sum(p[1] for p in xs) / len(xs)))
+    return out
+
+
+def simplify(pts, tol):
+    """ramer-douglas-peucker: drop points closer than tol to the line."""
+    if len(pts) < 3:
+        return list(pts)
+    (x0, y0), (x1, y1) = pts[0], pts[-1]
+    dx, dy = x1 - x0, y1 - y0
+    norm = math.hypot(dx, dy) or 1.0
+    best, idx = 0.0, 0
+    for i in range(1, len(pts) - 1):
+        d = abs(dy * (pts[i][0] - x0) - dx * (pts[i][1] - y0)) / norm
+        if d > best:
+            best, idx = d, i
+    if best <= tol:
+        return [pts[0], pts[-1]]
+    return simplify(pts[:idx + 1], tol)[:-1] + simplify(pts[idx:], tol)
+
+
+def path_width(mask, skel_len):
+    """average path width: path area divided by centre line length."""
+    return mask.count(PATH) / skel_len if skel_len else 0.0
+
+
+def extract_routes(mask, smooth_half, tol):
+    """
+    find the routes of a mask. returns a dict with the graph, the
+    entrance and exit blobs, the measured path width and the routes as
+    point lists, entrance to exit, smoothed and simplified.
+    """
+    w, h = mask.w, mask.h
+    shape = bytearray(1 if c != FREE else 0 for c in mask.cls)
+    # keep a free border so the thinning never reads past the image
+    for x in range(w):
+        shape[x] = shape[(h - 1) * w + x] = 0
+    for y in range(h):
+        shape[y * w] = shape[y * w + w - 1] = 0
+    skel = thin(shape, w, h)
+    graph = Graph(skel, w)
+
+    entrances = mask.blobs(ENTRANCE)
+    exits = mask.blobs(EXIT)
+    # specks of colour from the soft edges are not entrances or exits
+    entrances = [b for b in entrances if b[3] >= 50]
+    exits = [b for b in exits if b[3] >= 50]
+    width = path_width(mask, sum(polyline_length(e[2]) for e in graph.edges.values()))
+    terminals = [graph.nearest_end(b[0], b[1]) for b in entrances + exits]
+    graph.prune(set(terminals), 0.8 * width)
+    graph.contract(set(terminals), 0.75 * width)
+    graph.merge()
+    starts = terminals[:len(entrances)]
+    goals = terminals[len(entrances):]
+
+    routes = []
+    for s in starts:
+        for g in goals:
+            # of the two directions around a loop, keep the one that turns less
+            best = {}
+            for raw, key in graph.paths(s, g):
+                pts = resample(raw, 1.0)
+                pts = simplify(smooth(smooth(pts, smooth_half), smooth_half), tol)
+                if key not in best or turning(pts) < turning(best[key]):
+                    best[key] = pts
+            routes.extend(best.values())
+    return {
+        "graph": graph,
+        "entrances": entrances,
+        "exits": exits,
+        "width": width,
+        "routes": routes,
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/preview.py	Sun Oct 18 14:50:20 2026 +0200
@@ -0,0 +1,114 @@
+"""
+preview images of the build, for checking routes, placement and tower levels
+without starting the game.
+"""
+
+from PIL import Image, ImageDraw
+
+ROUTE_COLOURS = [(220, 0, 160), (0, 90, 255), (255, 120, 0), (0, 160, 60),
+                 (140, 0, 255), (0, 180, 200), (200, 40, 40), (90, 90, 90)]
+
+
+def _base(map_path, mp):
+    """map image faded towards white, with the placement grid drawn on it."""
+    im = Image.open(map_path).convert("RGBA")
+    im = Image.blend(im, Image.new("RGBA", im.size, (255, 255, 255, 255)), 0.55)
+    draw = ImageDraw.Draw(im)
+    cell, cols = mp["cell"], mp["cols"]
+    for i, c in enumerate(mp["grid"]):
+        if c == "1":
+            x, y = (i % cols) * cell, (i // cols) * cell
+            draw.rectangle((x, y, x + cell - 2, y + cell - 2), fill=(60, 170, 60, 255))
+    return im, draw
+
+
+def _route(draw, pts, colour, width):
+    pts = [tuple(p) for p in pts]
+    draw.line(pts, fill=colour, width=width, joint="curve")
+    for x, y in pts:
+        draw.ellipse((x - 2, y - 2, x + 2, y + 2), fill=(0, 0, 0))
+    # arrow heads at a few points, showing the walking direction
+    for k in range(1, 6):
+        i = k * (len(pts) - 1) // 6
+        (x0, y0), (x1, y1) = pts[i], pts[i + 1]
+        dx, dy = x1 - x0, y1 - y0
+        n = (dx * dx + dy * dy) ** 0.5 or 1
+        dx, dy = dx / n, dy / n
+        tip = (x0 + dx * 6, y0 + dy * 6)
+        draw.polygon([tip, (x0 - dx * 6 - dy * 6, y0 - dy * 6 + dx * 6),
+                      (x0 - dx * 6 + dy * 6, y0 - dy * 6 - dx * 6)], fill=colour)
+
+
+def _ends(draw, mp):
+    for x, y, r in mp["entrances"]:
+        draw.ellipse((x - r, y - r, x + r, y + r), outline=(0, 0, 255), width=3)
+    for x, y, r in mp["exits"]:
+        draw.ellipse((x - r, y - r, x + r, y + r), outline=(0, 160, 0), width=3)
+
+
+def map_preview(map_path, mp):
+    """the map with grid, centre line graph, routes, entrances and exits."""
+    im, draw = _base(map_path, mp)
+    for pts in mp["graph"]["edges"]:
+        draw.line([tuple(p) for p in pts], fill=(120, 120, 120), width=1)
+    for x, y in mp["graph"]["nodes"]:
+        draw.rectangle((x - 3, y - 3, x + 3, y + 3), outline=(0, 0, 0))
+    for k, r in enumerate(mp["routes"]):
+        _route(draw, r["points"], ROUTE_COLOURS[k % len(ROUTE_COLOURS)], 3)
+    _ends(draw, mp)
+    for k, r in enumerate(mp["routes"]):
+        x, y = r["points"][len(r["points"]) // 3]
+        draw.text((x + 6, y + 6 + 10 * k), f"route {r['number']}", fill=(0, 0, 0))
+    return im
+
+
+def route_sheet(map_path, mp):
+    """one panel per route, half size, for maps with several routes."""
+    panels = []
+    for k, r in enumerate(mp["routes"]):
+        im, draw = _base(map_path, mp)
+        _route(draw, r["points"], ROUTE_COLOURS[k % len(ROUTE_COLOURS)], 5)
+        _ends(draw, mp)
+        draw.text((10, 10), f"route {r['number']}: length {r['length']:.0f},"
+                  f" turning {r['turning']:.0f}, value {r['value']:.2f}", fill=(0, 0, 0))
+        panels.append(im.resize((im.width // 2, im.height // 2)))
+    cols = min(3, len(panels))
+    rows = (len(panels) + cols - 1) // cols
+    pw, ph = panels[0].size
+    sheet = Image.new("RGBA", (cols * pw, rows * ph), (255, 255, 255, 255))
+    for k, p in enumerate(panels):
+        sheet.paste(p, ((k % cols) * pw, (k // cols) * ph))
+    return sheet
+
+
+def tower_sheet(assets):
+    """
+    tower levels 1-5 per row: at full size on grey, so the white fill shows,
+    and at game scale next to each other.
+    """
+    rows = []
+    for t in range(4):
+        names = [f"t{t}"] + [f"t{t}_{lv}" for lv in range(2, 6)]
+        rows.append([Image.open(assets / f"{n}.png") for n in names])
+    pad = 16
+    cell_w = max(im.width for r in rows for im in r) + pad
+    cell_h = max(im.height for r in rows for im in r) + pad
+    small_w = cell_w // 4 + 4
+    sheet = Image.new("RGBA", (5 * cell_w + 5 * small_w + pad, 4 * cell_h + 20),
+                      (170, 170, 170, 255))
+    draw = ImageDraw.Draw(sheet)
+    for lv in range(5):
+        draw.text((lv * cell_w + pad, 4), f"level {lv + 1}", fill=(0, 0, 0))
+    draw.text((5 * cell_w + pad, 4), "game scale 0.25", fill=(0, 0, 0))
+    for t, r in enumerate(rows):
+        y = 20 + t * cell_h
+        for lv, im in enumerate(r):
+            x = lv * cell_w + pad // 2
+            # cross at the image centre, the default rotation point
+            sheet.alpha_composite(im, (x, y))
+            cx, cy = x + im.width // 2, y + im.height // 2
+            draw.line((cx - 5, cy, cx + 5, cy), fill=(255, 0, 0))
+            draw.line((cx, cy - 5, cx, cy + 5), fill=(255, 0, 0))
+            small = im.resize((max(1, im.width // 4), max(1, im.height // 4)), Image.LANCZOS)
+            sheet.alpha_composite(small, (5 * cell_w + pad + lv * small_w, y + cell_h // 3))
+    return sheet