Noble Ape
The Central Directories of the Noble Ape Simulation.
|
This covers vector math, the hash/random mathematics, (Newton) square root, the Bresenham's line algorithm, the bilinear interpolation and other abstract math that is used in Noble Ape. More...
#include "noble.h"
Go to the source code of this file.
Data Structures | |
struct | math_round_smarter_struct |
Macros | |
#define | POSITIVE_TILE_COORD(num) ((num+(3*MAP_DIMENSION))&(MAP_DIMENSION-1)) |
#define | NUMBER_TURN_TOWARDS_POINTS 8 |
This covers vector math, the hash/random mathematics, (Newton) square root, the Bresenham's line algorithm, the bilinear interpolation and other abstract math that is used in Noble Ape.
Definition in file math.c.
#define POSITIVE_TILE_COORD | ( | num | ) | ((num+(3*MAP_DIMENSION))&(MAP_DIMENSION-1)) |
void math_general_execution | ( | n_int | instruction, |
n_int | is_constant0, | ||
n_int | is_constant1, | ||
n_byte * | addr0, | ||
n_byte * | addr1, | ||
n_int | value0, | ||
n_int * | i, | ||
n_int | is_const0, | ||
n_int | is_const1, | ||
n_byte * | pspace, | ||
n_byte ** | maddr0, | ||
n_byte ** | maddr1, | ||
n_byte * | bc0, | ||
n_byte * | bc1, | ||
n_int | braincode_min_loop | ||
) |
Logical and
Logical or
Move a byte, with no particular alignment
Move a block of instructions
Add
Subtract
Multiply
Divide
Modulus
Count up or down
Goto
Goto if zero
Goto if not zero
Goto and decrement if not zero
If two values are equal then skip the next n instructions
If two values are not equal then skip the next n instructions
Skip the next n instructions if less than
No operation (data only)
swap
invert
Save to Pspace
Load from Pspace
Definition at line 956 of file math.c.
n_byte4 math_hash_fnv1 | ( | n_constant_string | key | ) |
This is used to produce a series of steps between two points useful for drawing a line or a line of sight test.
sx | The starting x location. |
sy | The starting y location. |
dx | The distance to be traveled in the x direction. |
dy | The distance to be traveled in the y direction. |
draw | The generic draw function used to traverse the line points. |
Definition at line 594 of file math.c.
void math_patch | ( | n_byte * | local_map, |
n_memory_location * | mem_func, | ||
n_patch * | func, | ||
n_byte2 * | arg, | ||
n_int | refine | ||
) |
This function creates the fractal landscapes and the genetic fur patterns currently.
local_map | pointer to the map array |
func | the n_patch function that takes the form n_byte2 (n_patch)(n_byte2 * local) |
arg | the pointer that is passed into the patch function |
patch_bits | each side of the map is 2^patch_bits, total area is 2^(patch_bits*2) |
size of the local tiles
number of 256 x 256 tiles in each dimension
begin the tile traversal in the y dimension
begin the tile traversal in the x dimension
scan through the span_minor values
each of the smaller tiles are based on 256 * 256 tiles
perform rotation on 2,3,6,7,10,11 etc
include the wrap around for the 45 degree rotation cases in particular
Definition at line 496 of file math.c.
Generates a random number from two change-able two-byte random number values passed into the function in the form of a pointer.
local | The pointer leading to both the two-byte numbers used to seed (and change in the process). |
Definition at line 825 of file math.c.
void math_random3 | ( | n_byte2 * | local | ) |
void math_round | ( | n_byte * | local_map, |
n_byte * | scratch, | ||
n_memory_location * | mem_func | ||
) |
void math_round_smarter | ( | n_byte * | local_map, |
n_byte * | scratch, | ||
n_memory_location * | mem_func | ||
) |
Calculates the direction location needs to turn to turn towards a vector.
px | The x vector direction. |
py | The y vector direction. |
fac | The current direction facing. |
turn | The number of facing angle units that could be turned (it may not be the number of angle units turned). |
Definition at line 757 of file math.c.
Adds one 2d vector with another 2d vector times a multiplier divided by a divisor.
equals | the vector that holds the result. |
initial | the first vector that takes the summation of the second vector. |
second | the second vector to be multiplied. |
multiplier | the scalar multiplier. |
divisor | the the scalar divisor. |
Definition at line 163 of file math.c.
This produces the dot product of two vectors with the scalar multiplier and divisor noted.
initial | The first vector |
second | The second vector |
reference | The specific Noble Ape checked for being awake |
Definition at line 185 of file math.c.
n_vect2* vect2_min_max_init | ( | void | ) |
void vect2_multiplier | ( | n_vect2 * | equals, |
n_vect2 * | initial, | ||
n_vect2 * | second, | ||
n_int | multiplier, | ||
n_int | divisor | ||
) |
Multiplies one 2d vector with another 2d vector times a multiplier divided by a divisor.
equals | the vector that holds the result. |
initial | the first vector. |
second | the second vector to be multiplied. |
multiplier | the scalar multiplier. |
divisor | the the scalar divisor. |