Skip to content

Commit

Permalink
Working through the map space and ape space issues
Browse files Browse the repository at this point in the history
  • Loading branch information
barbalet committed Mar 6, 2015
1 parent af38b53 commit ef55a80
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sim/entity/drives.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static void drives_sociability_loop(noble_simulation * local_sim, noble_being *
n_int distance_squared;
n_vect2 difference_vector;
/* this needs to be checked against simulation near sight and sound values */
const n_int apespace_span = APESPACE_TO_MAPSPACE(10);
const n_int apespace_span = 2; /*(10) >> APE_TO_MAP_BIT_RATIO; too low */
being_delta(dsd->being, other, &difference_vector);
/* los should not be used here, it's too expensive */
distance_squared = vect2_dot(&difference_vector, &difference_vector, 1, 1);
Expand Down
16 changes: 6 additions & 10 deletions sim/noble/land.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,19 +514,15 @@ n_int land_operator_interpolated(n_int locx, n_int locy, n_byte * kind)
n_int map_dimension = land_map_dimension();
n_int map_x = APESPACE_TO_MAPSPACE(locx);
n_int map_y = APESPACE_TO_MAPSPACE(locy);
n_int interpolated;

n_int interpolated;
NA_ASSERT(kind, "kind NULL");

/* Not bilinear interpolation but linear interpolation. Probably should replace with bilinear (ie each value has x and y dependency) */
interpolated = APESPACE_TO_MAPSPACE(
land_operator((map_x+1)&(map_dimension-1), map_y, kind)*(locx-MAPSPACE_TO_APESPACE(map_x)));
interpolated += APESPACE_TO_MAPSPACE(
land_operator((map_x-1)&(map_dimension-1), map_y, kind)*(MAPSPACE_TO_APESPACE(map_x+1)-locx));
interpolated += APESPACE_TO_MAPSPACE(
land_operator(map_x, (map_y+1)&(map_dimension-1), kind)*(locy-MAPSPACE_TO_APESPACE(map_y)));
interpolated += APESPACE_TO_MAPSPACE(
land_operator(map_x, (map_y-1)&(map_dimension-1), kind)*(MAPSPACE_TO_APESPACE(map_y+1)-locy));
interpolated = (land_operator((map_x+1)&(map_dimension-1), map_y, kind)*(locx-(map_x << APE_TO_MAP_BIT_RATIO))) >> APE_TO_MAP_BIT_RATIO;
interpolated += (land_operator((map_x-1)&(map_dimension-1), map_y, kind)*(((map_x+1)<<APE_TO_MAP_BIT_RATIO)-locx)) >> APE_TO_MAP_BIT_RATIO;
interpolated += (land_operator(map_x, (map_y+1)&(map_dimension-1), kind)*(locy-(map_y<<APE_TO_MAP_BIT_RATIO))) >> APE_TO_MAP_BIT_RATIO;
interpolated += (land_operator(map_x, (map_y-1)&(map_dimension-1), kind)*(((map_y+1)<<APE_TO_MAP_BIT_RATIO)-locy)) >> APE_TO_MAP_BIT_RATIO;

return interpolated >> 1;
}

Expand Down
6 changes: 4 additions & 2 deletions sim/noble/noble.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,10 @@ void compress_expand(n_file *input, n_file *output);
#define MAP_DIMENSION (1<<(MAP_BITS))
#define MAP_AREA (1<<(2*MAP_BITS))

#define APESPACE_TO_MAPSPACE(num) ((num)>>6)
#define MAPSPACE_TO_APESPACE(num) ((num)<<6)
#define APE_TO_MAP_BIT_RATIO (6)

#define APESPACE_TO_MAPSPACE(num) ((num)>>APE_TO_MAP_BIT_RATIO)
#define MAPSPACE_TO_APESPACE(num) ((num)<<APE_TO_MAP_BIT_RATIO)

#define HI_RES_MAP_BITS (MAP_BITS+3)

Expand Down
4 changes: 2 additions & 2 deletions sim/universe/universe.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
#undef FEATURE_SET

/* dimension of the territory map */
#define TERRITORY_DIMENSION (MAP_DIMENSION>>6)
#define TERRITORY_DIMENSION (MAP_DIMENSION>>APE_TO_MAP_BIT_RATIO)
#define TERRITORY_AREA (TERRITORY_DIMENSION*TERRITORY_DIMENSION)
#define APESPACE_TO_TERRITORY(num) (APESPACE_TO_MAPSPACE(num)>>6)
#define APESPACE_TO_TERRITORY(num) (APESPACE_TO_MAPSPACE(num)>>APE_TO_MAP_BIT_RATIO)

#define SINGLE_BRAIN (32768)
#define DOUBLE_BRAIN (SINGLE_BRAIN*2)
Expand Down

0 comments on commit ef55a80

Please sign in to comment.