sim.log.info("initializing default map...")

local uav_count = 9
local coords = { x = 1, y = 0 }

for idx = 1, uav_count do
    sim.map.spawn_uav {
        robot_id = idx,
        position = {
            x = coords.x,
            y = coords.y,
            z = 0
        }
    }

    local angle = 2.0 * math.pi / uav_count
    local new_x = math.cos(angle) * coords.x - math.sin(angle) * coords.y
    local new_y = math.sin(angle) * coords.x + math.cos(angle) * coords.y
    coords.x, coords.y = new_x, new_y
end

-- for x = -50, 50, 5 do
--     for y = -50, 50, 5 do
--         if x == 0 and y == 0 then
--             goto continue
--         end

--         map.spawn {
--             mesh = (math.random(2) == 1) and "trees/tree_a.glb" or "trees/tree_b.glb",
--             position = {
--                 x = x + math.random() * 2,
--                 y = y + math.random() * 2,
--             },
--             scale = 1,
--         }

--         ::continue::
--     end
-- end

sim.session.run()
