- int moduleSize = totalModuleSize / 7;\r
- // Allow less than 50% deviance from 1-1-3-1-1 pattern\r
- return Math.abs(moduleSize - stateCount[0]) << 1 <= moduleSize &&\r
- Math.abs(moduleSize - stateCount[1]) << 1 <= moduleSize &&\r
- Math.abs(3 * moduleSize - stateCount[2]) << 1 <= 3 * moduleSize &&\r
- Math.abs(moduleSize - stateCount[3]) << 1 <= moduleSize &&\r
- Math.abs(moduleSize - stateCount[4]) << 1 <= moduleSize;\r
+ float moduleSize = (float) totalModuleSize / 7.0f;\r
+ float maxVariance = moduleSize / 2.5f;\r
+ // Allow less than 40% variance from 1-1-3-1-1 proportions\r
+ return Math.abs(moduleSize - stateCount[0]) < maxVariance &&\r
+ Math.abs(moduleSize - stateCount[1]) < maxVariance &&\r
+ Math.abs(3.0f * moduleSize - stateCount[2]) < 3.0f * maxVariance &&\r
+ Math.abs(moduleSize - stateCount[3]) < maxVariance &&\r
+ Math.abs(moduleSize - stateCount[4]) < maxVariance;\r