fn weighted_index( len: usize, weight_at: impl Fn(usize) -> u32, random: &mut WorldgenRandom, ) -> Option<usize>