/************************************************************************\ * Filename: creation.h * * Author: Sue Evans * * Date Written: 3/20/05 * * Section: 01XX & 02XX * * Email: bogar@cs.umbc.edu * * * * This file is meant to be used as an interface for the creation.o file * * being given to the students as a part of their project 3 assignment, * * WATOR. * * * * This file must be #included in both the proj3.c and wator.c files. * * * * Since function prototypes in this file make use of our typedef'ed * * type, CELL, and the symbolic constant COLS, the #includes of the * * "wator.h" file in both the proj3.c file and the wator.c file MUST * * precede the #include of this file. * * * * This file contains the function prototype for the function, * * PopulateOcean() which sets up an ocean with all of its lifeforms, the * * function prototypes for its helper functions: PlaceSharks(), * * PlaceTunas and PlaceAlgae() and GetRandomNumber() which return a * * random number within the range of the values passed into it. It is * * used by the helper functions to randomly place the lifeforms in the * * ocean and to get random times until starvation, reproduction and * * growth for the original population of the ocean. * * * * The GetRandomNumber function can also be used by the students' code to * * get random directions for movement of fish or growth of algae. * \************************************************************************/ /******************** * PopulateOcean() * Inputs: ocean - a 2D array of CELLs of size ROWS X COLS to be * populated with lifeforms in this function * rows - integer number of rows in the array, ocean * cols - integer number of columns in the array, ocean * numSharks - integer number of sharks to have initially * numTunas - integer number of tunas to have initially * numAlgae - integer number of algae to have initially * starveShark - integer number of timeclicks until starvation * for a shark * starveTuna - integer number of timeclicks until starvation * for a tuna * reproShark - integer number of timeclicks until reproduction * for a shark * reproTuna - integer number of timeclicks until reproduction * for a tuna * grow - integer number of timeclicks until growing for * an alga * * Output: None, but the contents of the array, ocean, is modified by the * function. * * Assumptions : Relies on #define of COLS * Relies on typedefs of CELL, SHARK, TUNA, and ALGA * * PopulateOcean() populates the array, ocean, passed into it with CELLs * that contain lifeforms in the quantities passed in as the parameters * numSharks, numTunas and numAlgae. Each of the individuals are placed in * random positions in the ocean. These lifeforms will be initialized by this * function to have varying times until reproduction and starvation for all * fish and varying times until growth for algae. All of these times are * within the maximum time limits passed into the function as the parameters * starveShark, starveTuna, reproShark, reproTuna and grow. ********************/ void PopulateOcean(CELL ocean[][COLS], int rows, int cols, int numSharks, int numTunas, int numAlgae, int starveShark, int starveTuna, int reproShark, int reproTuna, int grow); /******************** * ClearOcean () * Inputs: 2D array of CELLs called ocean, and its size: an integer # of rows and an integer # of columns * Output: None, but the array passed in is modified * * ClearOcean() fills the array passed in with 0s in all of the cells * members. ********************/ void ClearOcean (CELL ocean[][COLS], int rows, int cols); /******************** * PlaceSharks() * Inputs: 2D array of CELLs called ocean, and its size: * an integer # of rows and an integer # of columns, * an integer number of SHARKs to place, an integer * number of time clicks before reproduction, and an * integer number of time clicks before starvation. * Output: None, but the array passed in is modified * * PlaceSharks() places the number of SHARKs passed in at random positions * within the ocean. The time clicks until reproduction is a random number * between half the reproShark and the maximum reproShark that was passed in. * Likewise the time clicks until starvation is a random number between half * the starveShark and the maximum starveShark passed in. ********************/ void PlaceSharks(CELL ocean[][COLS], int rows, int cols, int numSharks, int reproShark, int starveShark); /******************** * PlaceTunas() * Inputs: 2D array of CELLs called ocean, and its size: * an integer # of rows and an integer # of columns, * an integer number of TUNAs to place, an integer * number of time clicks before reproduction, and an * integer number of time clicks before starvation. * Output: None, but the array passed in is modified * * PlaceTunas() places the number of TUNAs passed in at random positions * within the ocean. Tunas are not placed in the same CELLS as SHARKs, but * a new position is determined for their placement. The time clicks until * reproduction is a random number between half the reproTuna and the maximum * reproTuna that was passed in. Likewise the time clicks until starvation is * a random number between half the starveTuna and the maximum starveTuna * passed in. ********************/ void PlaceTunas (CELL ocean[][COLS], int rows, int cols, int numTunas, int reproTuna, int starveTuna); /******************** * PlaceAlgae() * Inputs: 2D array of CELLs called ocean, and its size: * an integer # of rows and an integer # of columns, * an integer number of ALGAe to place, and an * integer number of time clicks before growth. * Output: None, but the array passed in is modified * * PlaceAlgae() places the number of ALGAe passed in at random positions * within the ocean. Algae are not placed in the same CELLS as TUNAs, but * a new position is determined for their placement. The time clicks until * growth is a random number between half the grow and the maximum grow that * was passed in. ********************/ void PlaceAlgae (CELL ocean[][COLS], int rows, int cols, int numAlgae, int grow); /******************** * GetRandomNumber() * * Inputs: min - integer minimum value desired * max - integer maximum value desired * * Output: a random number in the range min - max, inclusive * * GetRandomNumber() returns a random number in the range of * min to max, integer values that are passed into the function. ********************/ int GetRandomNumber(int min, int max);