QY27OCPL2PEW4TRTMKEOK2IJRQFUQX2A2YF2FHEFI52EE7WU43CQC }// Compute the imbalance, defined as the// number of consecutive diagonal or orthogonal moves// in the ray. This is a reasonable measure of deviation from// the Bresenham line between our selected source and// destination.int _imbalance(const std::vector<coord_def>& ray){int imb = 0;int diags = 0, straights = 0;for (int i = 1, size = ray.size(); i < size; ++i){const int dist =(ray[i] - ray[i - 1]).abs();if (dist == 2){straights = 0;if (++diags > imb)imb = diags;}else{diags = 0;if (++straights > imb)imb = straights;}}return imb;
// the imbalance. I'm defining 'imbalance' as the// number of consecutive diagonal or orthogonal moves// in the ray. This is a reasonable measure of deviation from// the Bresenham line between our selected source and// destination.
// the imbalance.int cimbalance = 0;