#include "declares.h" #define S_CHECK(x) if(x != EXIT_SUCCESS){return EXIT_FAILURE;} /* Sausage node */ typedef struct s_node { double offset; double range; double score; double *states; double *rewards; struct s_node *top; struct s_node *bottom; struct s_node *parent; } s_node; /* creates a new s_node init-ed */ s_node *s_node_new(double offset, double range, s_node *parental); /* splits up an s_node into sub-nodes according to static rules*/ int s_node_split(s_node *to_split); /* free's all memory at and under an s_node: BEWARE JUMPS AND PLACEHODERS!*/ int s_node_free(s_node *to_free); /* refreshes the score of a node (using first level children only) */ int s_node_refresh_score(s_node *to_update); /* updates all reward for node and all parents */ int s_node_update_score(s_node *to_update); /* inserts more state/reward pairs into a node and calls for a split if needed*/ int s_node_update_states(s_node *to_update, double state, double reward); /* prints a crappy graphical version of the tree highest to lowest nodes */ int s_node_print_tree(s_node *s_node_root); /* use the sausage tree to run the function */ int s_node_run(s_node *s_node_root);