### Normal surface generation bug

This page describes the bug found in the normal distribution clustered surface generator for the scalable abm work.

There was a logical error in the comparison statement in the 'make circle' function - which draws the normally distributed clusters.

int makecircle(gridtype **grid,int r,int c,int h,int radius) { int i,j; int pr,pc; float d; gridtype sv,gv; for(i=0;i<radius*2;i++) for(j=0;j<radius*2;j++) { // draw the circle (radius*2) pr=r+i-radius; pc=c+j-radius; // offset the points by i-radius (to get positive and negative) d=distance(pr,pc,r,c); if(d<=radius) { pr=(pr+R)%(R); pc=(pc+C)%(C); sv=scaledval(d,radius,h); // return the scaled value for normal distribution gv=grid[pr][pc]; if(sv>gv) // *BUG* grid[pr][pc]=BASE+sv; // notice: BASE+sv } } }

The last few lines of the code should have read like:

if(BASE+sv>gv) // no bug, included base in comparison grid[pr][pc]=BASE+sv;

This bug would not have shown up if BASE=0, which it was during some of the testing. It is fixed and now the surface is generated as it should be.