/* THE GAME OF LIFE Written and produced by Chris C. Keeser on 6/8/04 sitting on my couch listening to music at 12:30 in the morning oh what a good feeling that was. (seriously, it was the most peace I have had all week) */ #include "life.hxx" //////////////////////////////////////////// /* NAME: FIND_FUTURE_STATE but *should* have been called "THE_RULES_OF_LIFE" DESCRIPTION: I decide your fate based on the number of neighbors you have PAPRAMETERS: INT *grandpa is a pointer to the position in the old_g array that represents and old timer whose time has come. INT neighbors is the number of neighbors that grandpa has, and is the deciding factor in whether or not grandpa can "live on" through is children. INT *children is a pointer to the new_g array that represents the position of the hopeful parents. PRE-CONDITIONS: old_g(100 X 100) MUST exist and MUST have gone through function where_am_i in order to have determined the number of neighbors that grandpa has. POST-CONDITIONS: There must exist an array new_g(100 X 100) for the results to be stored into RETURN: nada, void function SIDE EFFECTS: some live and some die. */ ///////////////////////////////////////////// void find_future_state(int *grandpa, int neighbors, int *children) { if(neighbors > 3 || neighbors < 2) // the conditions for unconditional DEATH { *children = 0; } if(*grandpa == 0 && neighbors == 3) // the condition for BIRTH { *children = 1; } if(*grandpa == 1 && (neighbors == 2 || neighbors == 3)) // the condition for survival { *children = 1; } return; }