Skip to content

Commit

Permalink
Test code that counts occurrence of a given object on the map.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrohrer committed Jul 22, 2019
1 parent 5ef8402 commit 79b4c9f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions server/map.cpp
Expand Up @@ -1600,6 +1600,42 @@ void printBiomeSamples() {



void printObjectSamples() {
int objectToCount = 2285;

JenkinsRandomSource sampleRandSource;

int numSamples = 0;

int range = 500;

int count = 0;

for( int y=-range; y<range; y++ ) {
for( int x=-range; x<range; x++ ) {
int obj = getMapObjectRaw( x, y );


if( obj == objectToCount ) {
count++;
}
numSamples++;
}
}


int rangeSize = (range + range ) * ( range + range );

float sampleFraction =
numSamples /
( float ) rangeSize;

printf( "Counted %d objects in %d/%d samples, expect %d total\n",
count, numSamples, rangeSize, (int)( count / sampleFraction ) );
}





// optimization:
Expand Down Expand Up @@ -3404,6 +3440,7 @@ char initMap() {


// for debugging the map
// printObjectSamples();
// printBiomeSamples();
//outputMapImage();

Expand Down

0 comments on commit 79b4c9f

Please sign in to comment.