/*----------------------------------------------------------------------------------------------------------------------------*
 * programmer	: nam tran [neuropunk]                                                                                      *
 * e-mail		: neuroticism@hotmail.com														*
 * affiliations	: neuropunk productions && neuronetwork												*
 * urls		: neuropunk.com && neuronetwork.cx													*
 * version		: 0.95                                                                                                      *
 * status		: not supported anymore                                                                                     *
 * date		: summer of 1999                                                                                            *
 * released		: 12/5/99                                                                                                   *
 * purpose		: I think the motivation for this program was formed from watching THE MATRIX. Anyway, there are these      *
 *			  "noids" that populate the program, they can move throughout the "world", they can breed [which involves   *
 *			  genes], and they can fight, among other things. There is a "gui" or anything like that, basically, the    *
 *			  program just does a bunch of math calculations and goes on, I HAD TO write certain functions to           *
 *			  "report" on this world. Unfortunately, maybe due to wrong logic, the program only works about 15% of      *
 *			  the time, as in expected results, the rest of the time, it doesn't. It's extremely hard for me to         *
 *			  diagnose the problem due to the extreme amount of rand() used througout the program                       *
 *----------------------------------------------------------------------------------------------------------------------------*/


/*
	[PROGRAMMING LOGS]

	6/19/99		actually i think i figured out why the bugs never really "evolved", probably because after a fight, the
				winning bug won't get his body part increased, but just his stats, but when it's breeding time, stats
				don't play a part, and only the genes play a part, and since the genes weren't ever increased, that's why
				there didn't seem to be "evolution", going to fix that now

				things i want to do w/ this program
				1) implement evolution
				2) implement "food"
				3) implement breeding
				4) implement fighting
				5) implement "i'm sick of fighting" [low population from fighting]
				6) implement a mathematical world that can be changed w/ constants


	6/20/99		i'm just going to declare my little noids globally, because i have a lot of functions that take
				the entire array as an argument, and it will be much easier for me

				i'm deciding whether i'm going to want to change my thinking on using the array as a global variable
				it's just that i think that somebody might edit the array [change the name], and the function will
				take a s*, because it referenced the old array by it's old name, on the other hand, if somebody
				DOES edit the array, and i made it to where my function has the argument of the noid array, then
				they're also going to have to change all the places where i passed off the old argument w/ the old
				array name, i guess if anything it would be good practice to make your function, as functional as possible
				and not make it so "attached" to your entire program


	6/22/99		before i can even really get done w/ the move() function, i'm going to have to make a rules() function
				so these things can function

				i keep on thinking about whether it's going to affect my programming if i don't pass the actual humanoid
				that we're focusing on as an argument, i don't think i have to do that, because the function is inside
				the humanoid itself, and all i think i really need is the entire array of humanoids as an argument.
				f* THIS s*, i keep on get f*ing errors, so i'm just going to make it a requirement to pass off,
				the name of the humanoid as an argument


	6/25/99		it now compiles w/o errors, just had to tie up some loose ends

				i made an interesting discovery, even if you already declared the class that you're going to use to define
				something, if the "definition" of that definition is after the declaration, your program won't compile, so
				you need to put all that info before the declaration


	6/26/99		i realized that the randomizer function doesn't require name/array, i'm afraid that this might cause future
				problems, but i will just leave it like that for now, and continue working on the other stuff

				i sometimes forget to add the "()" after a function call, i must not try to forget that


	6/28/99		i almost forgot about the whole "sex organ" thing, i thought about making it to where you would get the
				status [sex wise] of the noid, from a derived sex organ, but that's just a waste of my time, i'll just make
				it to where i'll directly determine the sex stat by rand() % 2

				last time i was messing around w/ this breeding thing, i forgot to set the kid as alive, can't forgot that
				this time around

				i had a thought, i wonder, in the randomization thing, if it also set values for the genes [ALL the genes...]
				and not just assign some random s*, going to have to check that out...., I CHECKED IT OUT, and it
				initialized all the genes, but didn't actually set values for the other stuff, so i'm goign to make a function
				that takes the gene info, and setup the actual info [in this context, actual as in not genes, but what you
				actually use]

				i'm also going to have to stick the function i finished inside the body_parts::randomize()  function

				i remember a while back, i was wondering why i didn't have to specify the name/array parameters for something
				like randomize, i think it's because randomize is directly editing it's own private variables, the only
				reason i ask that you pass paramenters to randomize is that, inside that function, it calls another function
				that requires that info

 				it's pretty funny actually, you can't use another class inside of a class until you previously defined it,
 				that was fine by me, so i put all the code for a certain class [call it uno] before another class [call it
 				dos] [literally], then i decided to use class dos inside of class uno w/o really thinking about what i said
 				previously [a function required it], it didn't work, catch - 22


	6/29/99		this whole problem is inside body_parts::randomize(), as s*ty as this sounds, the best solution i can
				possibly see from all of this, is stick the randomize() in the humanoids class, and re-edit the function

				just finished re-editing the function, now you need to pass off a, int name, and a humanoids *noids...
				now i can call the d_parts function from inside the randomize, to do that, i had to pass off name, and noids
				off as the argument, where i previously couldn't have done that, because randomize didn't even use
				arguments/parameters

				now i'm getting problems whenever i try to call the d_parts function, it gives me some major bs, and i have
				no idea why

				i'm not sure about this, but when i was looking over the humanoids::move() function, it seems that whenever
				i call the rules function, it's not checking for the new location, as in, it's checking the same thing every
				single time, it doesn't look like i assigned the value of the location to the bug, i think i might have to
				do that for it to work, then at the end of the program, after the dust has settled, it'll do whatever, i
				think i'll just check it again

				i really wonder what i was i was thinking when i wrote that function, i mean cmon, what's up w/ "noids + name"
				it's suppose to be "name + noids", hmm... i'm making myself rethink the true meaning, because i did the
				same thing w/ the rules() function... time to go do some actual tinkering [or just read a book], bah... i'm
				going to bed, i'll just f* around w/ the program a little bit more tomorrow


	6/30/99		i don't know what the hell i was thinking, but it's suppose to be (array + x)... i didn't really even have
				to look in the book, when i really thought about it, it came to me, this is f*ing bs, because i'm going
				to have to correct my f*ing mistakes

				i still have to fix the humanoids::move() thingamajig


	7/1/99		i feel so f*ing stupid, the reason the program kept on tripping over d_parts, was that i forgot to add
				the class name in front of the member function

				i would like to point some stuff out now, you might have notice on how some functions, i don't require
				int name, and humanoids *noids, just a humanoid *, the point is, that when you call the function, you're
				passing the memory address of the location you want to edit, i don't care how you do it, you're just going
				to do it that way, the same goes for humanoids::breed(), when you pass the paramenters, pass the mem addresses
				of the locations you want to edit

				i still have to fix humanoids::move(), fixed it [i think]

				wonder if i ever fixed the problem w/ humanoids::breed() in relationship to whether it determines the sex
				of the bug or not


	7/2/99		when i'm really thinking about it, i don't think directly editing the "actual" body part info is enough,
				i mean, how is it's kid going to be stronger then any other kid, since i'm not editing the genes [where
				the kid gets it's info] and only editing the current noid's actual info, i think i'm going to edit both
				genes


	7/3/99		i fixed the kid's sex thing, his "set alive" thing, and i think the humanoids::fight() should work right,
				and so should the humanoids::breed()

				i still have to do the reaper thingy, technically, there's a limit of 5000 noids at one time, it's because
				of the way i coded the reaper() thingy, that sets this limit, people might want to edit that later to
				make the simulation bigger

				going to have to write a function that prints out the info, maybe make it accept an argument, where
				depending on what was passed, it will print only certain things

				i'm going to put the print() function on hold, and just work on some stuff that will get a beta up so i can
				see it, like print birth info, on stdout, amount of males/females, dead/alive, etc...

				i'm going to assign a random location for every noid, the thing is, even though the locations might overlap,
				when it's the noid's turn to move(), it will surely not be on another noid again, hopefully, i dont think
				being overlapped will reasonablly affect the programming code much

				came up w/ a somewhat decent "see if they are going to fight" using global variables, i can manipulate their
				fighting attitude, there's a M_FIGHT, and a F_FIGHT, and there's a set FIGHT, obviously, the higher the num
				of X_FIGHT, the bigger selection you get, and less likely you will be below FIGHT [which means they will
				fight] if you wanted them to fight 24/7, set X_FIGHT to be below FIGHT

				edited some stuff at humanoids::fight(), might want to check that out tomorrow to make sure i didn't f*
				up major stuff, i'm not sure, but it might seems that both of the noids are killing each other off, but
				that still wouldn't explain about the unmatched breed/fight, if anything the breed, would be double, but
				that is obviously not the case, there must be a noid w/ a 0 that i don't know about

	7/4/99 		i think these things are f*ing dead bodies, maybe if i fix that...
*/



/*
	[NOTES ON USING THE PROGRAM]

				void humanoids::randomize(int name, humanoids *noids)
						~to randomize the humanoid's genes [t, h, and a]
						~used primarily at the beginning of the program
						~it also calls d_parts/d_stats at the end of the
						~function

				int humanoids::rules(int name, humanoids *noids)
						~sees if the humanoids is following the rules of the
						~simulation, returns a 1 if it is, anything else, it
						~returns a 0 [not following the rules]

 				void humanoids::move(int name, humanoids *noids)
 						~moves the noid one step [using rand() % 8]
 						~in case the noid is surrounded, there is a feature
 						~to prevent the loop from going bad, this also
 						~uses the humanoids::rules to make sure the move
 						~is legal before it actually assigns it

 				void humanoids::d_stats(int name, humanoids *noids)
 						~use the info already filled in body [body_parts]
 						~to fill in the derived stats of humanodis [class wise]
 						~use must have already filled out the info manually
 						~or use randomize()

				void humanoids::d_parts(humanoids *kayla)
						~use when you already have the gene info from
						~that info, it will form the "actual" body info

				void humanoids::breed(humanoids *p_1, humanoids *p_2, humanoids *kid)
						~takes two parents, and forms a kid, also calls d_parts/d_stats
						~at the end of the function

 				void fight(humanoids *f_1, humanoids *f_2)
 						~takes two mem addresses, and they duke it out, it
 						~also updates the life/death of the noids fighting
 						~it also increases [using rand()] the "amount" of
 						~random body parts

				int humanoids::reaper(humanoids *noids)
						~it takes the array of humanoids, searches for a
						~dead noid, and return it's name, if there wasn't
						~a dead noid, it will return a value of 5000

				void humanoids::almanac(humanoids *noids)
						~prints info about the matrix, like amount of
						~females, males, lifes, deaths, etc...

*/


/*-----------*
 * constants *
 *-----------*/


 /*-------------------------------------------------------------------------------------------------------*
  * the general idea is that you're trying to fill in the distance from the exact middle to the 		  *
  * given position [UL, UC, etc...], like if you had a 49x49 [which is a 50x50 that starts at 0]          *
  * there would be 2401 possible points for the humanoid to be on, and the distance from the center       *
  *	to the UL would be something like 49 [using subtraction], to figure this out, this is what i          *
  *	did... i would write down the rows on a piece of paper or something,                                  *
  *	                                                                                                      *
  *	100  101  102  103  104  105	.... until 149                                                        *
  *	50   51   52   53   54   55     .... until 99                                                         *
  *	0    1    2    3    4    5      .... until 49 [it's a 49 by 49 grid, or a 50 by 50 that starts at 0]  *
  *	                                                                                                      *
  *	then i just busted out my calculator, and w/ a chosen number, i would figure out what the distance    *
  *	would be from it to it's surrounding points, so, to figure out some of this stuff, you're going to    *
  *	have to use a piece of paper/pen, if you're going to whine about this, then i dont' think this is     *
  *	for you, because this is simple as s*                                                               *
  *                                                                                                  	  *
  * if it isn't obvious yet, the whole thing changes as you change the size of the matrix [grid/world]    *
  *-------------------------------------------------------------------------------------------------------*/

 const int MATRIX = 576;	//size of the world, calculated by (X^2) [assuming your grid was even, if not (x * y)]

 const int BEGIN = 0; 		//limitation of the matrix
 const int END = 2401;		//limitation of the matrix

 const int SURROUNDED = 20;	//how many loops [turns] before the program realizes it's surrounded, and stop sending the
 							//humanoid as an argument, because it failed the rules function, to prevent a bad loop

 const int UL =	24;			//distance from upper left to exact middle
 const int UC = 25;			//distance from upper center to exact middle
 const int UR = 26;			//distance from upper right to exact middle
 const int ML = 1;			//distance from middle left to exact middle
 const int MR = 1;			//distance from middle right to exact middle
 const int LL = 26;			//distance from lower left to exact middle
 const int LC = 25;			//distance from lower center to exact middle
 const int LR = 24;			//distance from lower right to exact middle

 const int HUMANOIDS = 50;	//how many people we're going to use for the simulation


 const int M_BRAIN = 3;		//multiplier for corresponding stat [smart = brain amount * M_BRAIN]
 const int M_ARM = 2;		//multiplier for corresponding stat
 const int M_LEG = 5;		//multiplier for corresponding stat
 const int M_SKIN = 6;		//multiplier for corresponding stat


 const int M_FIGHT = 100;	//the higher the #, less likely that sex will fight
 const int F_FIGHT = 15;	//the higher the #, less likely that sex will fight
 const int FIGHT = 20;		//hard to explain, but what is below this will fight

 const int R_REAPER = 5000;	//return value of reaper, 5000 signifies no dead bodies, so theoretically, there's a 5000 cap
 							//on the number of noids, you can easily change this value to have a higher amount of noids



/*------------------*
 * global variables *
 *------------------*/
 int year = 0;
 int fights = 0;
 int breeds = 0;

/*---------------------*
 * function prototypes *
 *---------------------*/
 char check_esc(void);					//to see if the user pressed esc


/*--------------*
 * header files *
 *--------------*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>



/*---------*
 * classes *
 *---------*/



/*---------------------------------------------*
 * name		:	body_parts                     *
 * purpose	:	info about body, genes, etc... *
 * comments	:   none						   *
 *---------------------------------------------*/
 class body_parts
 {
 public:
 	//constructors - deconstructors
 	body_parts() { ; }
 	~body_parts() { ; }



	//[brain]
	int get_brain_h(void) const { return(brain_h); }
	int get_brain_a(void) const { return(brain_a); }
	int get_brain_gx_t(void) const { return(brain_gx_t); }
	int get_brain_gx_h(void) const { return(brain_gx_h); }
	int get_brain_gx_a(void) const { return(brain_gx_a); }
	int get_brain_gy_t(void) const { return(brain_gy_t); }
	int get_brain_gy_h(void) const { return(brain_gy_h); }
	int get_brain_gy_a(void) const { return(brain_gy_a); }

	void set_brain_h(int x) { brain_h = x; }
	void set_brain_a(int x) { brain_a = x; }
	void set_brain_gx_t(int x) { brain_gx_t = x; }
	void set_brain_gx_h(int x) { brain_gx_h = x; }
	void set_brain_gx_a(int x) { brain_gx_a = x; }
	void set_brain_gy_t(int x) { brain_gy_t = x; }
	void set_brain_gy_h(int x) { brain_gy_h = x; }
	void set_brain_gy_a(int x) { brain_gy_a = x; }


	//[arm]
	int get_arm_h(void) const { return(arm_h); }
	int get_arm_a(void) const { return(arm_a); }
	int get_arm_gx_t(void) const { return(arm_gx_t); }
	int get_arm_gx_h(void) const { return(arm_gx_h); }
	int get_arm_gx_a(void) const { return(arm_gx_a); }
	int get_arm_gy_t(void) const { return(arm_gy_t); }
	int get_arm_gy_h(void) const { return(arm_gy_h); }
	int get_arm_gy_a(void) const { return(arm_gy_a); }

	void set_arm_h(int x) { arm_h = x; }
	void set_arm_a(int x) { arm_a = x; }
	void set_arm_gx_t(int x) { arm_gx_t = x; }
	void set_arm_gx_h(int x) { arm_gx_h = x; }
	void set_arm_gx_a(int x) { arm_gx_a = x; }
	void set_arm_gy_t(int x) { arm_gy_t = x; }
	void set_arm_gy_h(int x) { arm_gy_h = x; }
	void set_arm_gy_a(int x) { arm_gy_a = x; }


	//[leg]
	int get_leg_h(void) const { return(leg_h); }
	int get_leg_a(void) const { return(leg_a); }
	int get_leg_gx_t(void) const { return(leg_gx_t); }
	int get_leg_gx_h(void) const { return(leg_gx_h); }
	int get_leg_gx_a(void) const { return(leg_gx_a); }
	int get_leg_gy_t(void) const { return(leg_gy_t); }
	int get_leg_gy_h(void) const { return(leg_gy_h); }
	int get_leg_gy_a(void) const { return(leg_gy_a); }

	void set_leg_h(int x) { leg_h = x; }
	void set_leg_a(int x) { leg_a = x; }
	void set_leg_gx_t(int x) { leg_gx_t = x; }
	void set_leg_gx_h(int x) { leg_gx_h = x; }
	void set_leg_gx_a(int x) { leg_gx_a = x; }
	void set_leg_gy_t(int x) { leg_gy_t = x; }
	void set_leg_gy_h(int x) { leg_gy_h = x; }
	void set_leg_gy_a(int x) { leg_gy_a = x; }


	//[skin]
	int get_skin_h(void) const { return(skin_h); }
	int get_skin_a(void) const { return(skin_a); }
	int get_skin_gx_t(void) const { return(skin_gx_t); }
	int get_skin_gx_h(void) const { return(skin_gx_h); }
	int get_skin_gx_a(void) const { return(skin_gx_a); }
	int get_skin_gy_t(void) const { return(skin_gy_t); }
	int get_skin_gy_h(void) const { return(skin_gy_h); }
	int get_skin_gy_a(void) const { return(skin_gy_a); }

	void set_skin_h(int x) { skin_h = x; }
	void set_skin_a(int x) { skin_a = x; }
	void set_skin_gx_t(int x) { skin_gx_t = x; }
	void set_skin_gx_h(int x) { skin_gx_h = x; }
	void set_skin_gx_a(int x) { skin_gx_a = x; }
	void set_skin_gy_t(int x) { skin_gy_t = x; }
	void set_skin_gy_h(int x) { skin_gy_h = x; }
	void set_skin_gy_a(int x) { skin_gy_a = x; }



 private:
    /*-----------------------------------------------------------------------*
 	 * [NOTES]																 *
 	 * "h" stands for "have", like does it have that body part               *
 	 * "a" stands for "amount", like how high is the quality of that part    *
 	 * "t" stands for "trait", like is it dominant or recessive			     *
 	 *                                                                       *
 	 * the general idea is that your actual body parts info comes from       *
 	 * your genes info using the dominant/recessive theory, so whether you   *
 	 * actually have a body part, body part amount, or what not depends on   *
 	 * your genes 												             *
 	 *                                                                       *
 	 * for values like "h", there's only 2,                                  *
 	 * 0 == no body part                                                     *
 	 * 1 == it possesses the body part						                 *
 	 *                                                                       *
 	 * same thing for "t", there's only 2. 									 *
 	 * 0 == recessive                                                        *
 	 * 1 == dominant                                                         *
 	 *                                                                       *
	 *                                                                       * 	                                                                       *
     * everybody has a skin, it's just a matter of who has the highest level *
 	 *-----------------------------------------------------------------------*/


 	int brain_h;					//will determine smart, aka who has first strike in a fight
 	int brain_a;
 	int brain_gx_t;                 //gene x info
 	int brain_gx_h;
 	int brain_gx_a;
 	int brain_gy_t;                 //gene y info
 	int brain_gy_h;
 	int brain_gy_a;

 	int arm_h;						//will determine strength, aka who can punch the hardest
 	int arm_a;
 	int arm_gx_t;
 	int arm_gx_h;
 	int arm_gx_a;
 	int arm_gy_t;
 	int arm_gy_h;
 	int arm_gy_a;

 	int leg_h;						//will determine agility, aka how fast you can run
 	int leg_a;
 	int leg_gx_t;
 	int leg_gx_h;
 	int leg_gx_a;
 	int leg_gy_t;
 	int leg_gy_h;
 	int leg_gy_a;

 	int skin_h;						//will determine endurance, aka can you handle a hit
 	int skin_a;
 	int skin_gx_t;
 	int skin_gx_h;
 	int skin_gx_a;
 	int skin_gy_t;
 	int skin_gy_h;
 	int skin_gy_a;
 };




/*---------------------------------------------*
 * name		:	humanoids                      *
 * purpose	:	stats, functions, etc...       *
 * comments	:   none						   *
 *---------------------------------------------*/
 class humanoids
 {
 public:
 	//constructors - deconstructors
 	humanoids() { life = 1; }
 	~humanoids() { ; }


 	//declaring the "body"
	body_parts body;




 	//getting [general] stats
 	int get_name(void) const { return(name); }
 	int get_life(void) const { return(life); }
 	int get_fights(void) const { return(fights); }
 	int get_age(void) const { return(age); }
 	int get_generation(void) const { return(generation); }
 	int get_location(void) const { return(location); }
 	int get_fed(void) const { return(fed); }
 	int get_offspring(void) const { return(offspring); }
 	int get_sex(void) const { return(sex); }

	//getting [body part derived] stats
 	int get_smart(void) const { return(smart); }
 	int get_agility(void) const { return(agility); }
 	int get_strength(void) const { return(strength); }
 	int get_endurance(void) const { return(endurance); }



 	//setting [general] stats
 	void set_name(int x) { name = x; }
 	void set_life(int x) { life = x; }
 	void set_fights(void) { fights++; }					//no argument[s] because it just increments it by one
 	void set_age(void) { age++; }						//no argument[s] because it just increments it by once
 	void set_generation(int x) { generation = x; }
 	void set_location(int x) { location = x; }
 	void set_fed(int x) { fed = x; }
 	void set_offspring(void) { offspring++; }			//no argument[s] because it just increments it by one
 	void set_sex(int x) { sex = x; }

 	//setting [body part derived] stats
 	void set_smart(int x) { smart = x; }
 	void set_agility(int x) { agility = x; }
 	void set_strength(int x) { strength = x; }
 	void set_endurance(int x) { endurance = x; }

	//the more interesting functions
    void randomize(int name, humanoids *noids);			//fills in random values for genes [for beginning of the program]

	void move(int name, humanoids *noids);				//moving the bug, and also checks at the same time to see if it's
														//legal, if it isn't, then the bug keeps on trying until a certain
														//variable is ticked off to a number, which probably means the bug
														//is surrounded, i don't need to pass off the name of the bug
														//to make sure it doesn't check itself, because i can get all
														//the info i need from the class itself, much easier  I CHANGE
														//MY MIND ABOUT THE GLOBAL ARRAY THING, read 6/20/99, i'm going
														//to make move() accept an argument of the entire array, name
														//is the name of the humanodi

	int rules(int name, humanoids *noids);				//checks to see if the rules are followed, like, no overlapping
														//of humans, don't be out of the boundaries of the matrix, etc...
														//returns a "1" if the rules are followed, returns a "0" if the
														//rules aren't followed, name is the name of the humanoid

	void d_stats(int name, humanoids *noids);			//take the info about he "h" part [have] of the body stats, and
														//using that info to fill in the stats of the corresponding
														//variables, it's hard to say, but the info about smart would
														//be derived from the brain body part, the name of the function
														//is suppose to mean "derived stats", takes a name and array
														//so you know which element of the array to edit

	void breed(humanoids *p_1, humanoids *p_2, humanoids *kid);		//the general idea is that, you pass off as parameters,
																	//the mem address of the first parent, the second
																	//parent, and then, after whatever instructions has been
																	//executed, the info is stored in the *kid, when the
																	//function is running, it first stores the corresponding
																	//gene info, then calls a function, to make order
																	//out of the chaotic gene info, which essentially means
																	//you get the "actual" [real world or whatever] info
																	//of the noid from the genes from that called function

	void d_parts(humanoids *kayla);						//this assumes that the noid you are passing off already has
														//all the gene info filled out, what this function does, is that it
														//forms "actual" info out of the genes, like if one gene is rec, and
														//the other is dom, which one does it get, or if they are both dom
														//which one does it get, and so on, it directly edits the pointer

	void fight(humanoids *f_1, humanoids *f_2);			//fighting between two noids, in the end, what it does is,
														//directly edit the life variable of the dead noid, increase
														//directly, either the endurance of strength of the noid [body
														//part wise], then call d_stats, to edit the stats to reflect
														//the new && improved noid, who goes first is determined by how
														//smart it is

    int reaper(humanoids *noids);						//will search through the entire array for any dead noids, it will
    													//return a "5000" if there is !, anything else is the "name" of the
    													//dead noid, it doesn't go outside the amount of actual noids inside
    													//the array when it's checking it because of the global variable
    													//that tells you how many noids there are

    void print(int choice);								//depending on what value was passed, it will print certain info
    													//like a 0 would mean the works, a 1 would mean just breeding info
    													//etc... actually, the latter statement was wrong, but just go along
    													//with me

	void almanac(humanoids *noids);						//prints info, like how many births, how many fights, what year
														//how many female, how many male, etc..., it uses the array to search
														//for stuff through it

	void physics(int name, humanoids *noids);			//ties all these functions together, only focuses on one noid at
														//a time though






 private:
 	//general stats
 	int name;								//it's name is a numerical number
 	int life;								//0 == dead, 1 == alive
 	int fights;								//number of fights it's been in
 	int age;								//how old it is
 	int generation;							//what generation is it from aka loop number
 	int location;							//location
 	int fed;								//0 == hasn't been fed, 1 == has been fed
 	int offspring; 							//number of kids it helped to produce
 	int sex;								//1 == male, 0 == female

 	//basic body derived stats

 	int smart;								//higher == hits first
 	int agility;							//higher == move more per turn [loop]
 	int strength;							//higher == more powerful hits
 	int endurance;	 						//higher == can take more hits
 };




/*-----------------------------------------------------*
 * function		: humanoids::randomize()   			   *
 * purpose		: fill random values for genes		   *
 * accepts		: int, humanoids *				       *
 * returns		: void                                 *
 * comment		: for beginning of the program		   *
 *-----------------------------------------------------*/
 void humanoids::randomize(int name, humanoids *noids)
 {
    //setting random values [between 0 and 1] for the "h", determining if it's going to have a body part or not
	(noids + name)->body.set_brain_gx_h((rand() % 2));
	(noids + name)->body.set_brain_gy_h((rand() % 2));
	(noids + name)->body.set_arm_gx_h((rand() % 2));
	(noids + name)->body.set_arm_gy_h((rand() % 2));
	(noids + name)->body.set_leg_gx_h((rand() % 2));
	(noids + name)->body.set_leg_gy_h((rand() % 2));
	(noids + name)->body.set_skin_gx_h((rand() % 2));
	(noids + name)->body.set_skin_gy_h((rand() % 2));

	//setting random values [between 0 and 1] for the "t", determining whether gene is dom/rec
	(noids + name)->body.set_brain_gx_t((rand() % 2));
	(noids + name)->body.set_brain_gy_t((rand() % 2));
	(noids + name)->body.set_arm_gx_t((rand() % 2));
	(noids + name)->body.set_arm_gy_t((rand() % 2));
	(noids + name)->body.set_leg_gx_t((rand() % 2));
	(noids + name)->body.set_leg_gy_t((rand() % 2));
	(noids + name)->body.set_skin_gx_t((rand() % 2));
	(noids + name)->body.set_skin_gy_t((rand() % 2));


	//setting the "a" of the genes to 0, after that, depending on whether "h" is 1 or not, the "a" may be altered
	(noids + name)->body.set_brain_gx_a(0);
	(noids + name)->body.set_brain_gy_a(0);
	(noids + name)->body.set_arm_gx_a(0);
	(noids + name)->body.set_arm_gy_a(0);
	(noids + name)->body.set_leg_gx_a(0);
	(noids + name)->body.set_leg_gy_a(0);
	(noids + name)->body.set_skin_gx_a(0);
	(noids + name)->body.set_skin_gy_a(0);




	//depending on the value of "h", "a" may be altered to a (1 + (rand() % 10)), eventually, everybody will start w/ a
	//low value like that, but eventually, because of "evolution", the value may be increased dramatically, actually
	//the stats won't be altered, but the body parts will directly be altered, and somewhere later, i plan to implement
	//a function that will get derived info from the body parts and apply it to the stats, so for evolution to take place
	//i'm going to have to directly edit the body part info

	if((noids + name)->body.get_brain_gx_h() != 0)
		(noids + name)->body.set_brain_gx_a((1 + (rand() % 10)));;

	if((noids + name)->body.get_brain_gy_h() != 0)
		(noids + name)->body.set_brain_gy_a((1 + (rand() % 10)));

	if((noids + name)->body.get_arm_gx_h() != 0)
		(noids + name)->body.set_arm_gx_a((1 + (rand() % 10)));

	if((noids + name)->body.get_arm_gx_h() != 0)
		(noids + name)->body.set_arm_gy_a((1 + (rand() % 10)));

	if((noids + name)->body.get_leg_gx_h() != 0)
		(noids + name)->body.set_leg_gx_a((1 + (rand() % 10)));

	if((noids + name)->body.get_leg_gy_h() != 0)
		(noids + name)->body.set_leg_gy_a((1 + (rand() % 10)));

	if((noids + name)->body.get_skin_gx_h() != 0)
		(noids + name)->body.set_skin_gx_a((1 + (rand() % 10)));

	if((noids + name)->body.get_skin_gy_h() != 0)
		(noids + name)->body.set_skin_gy_a((1 + (rand() % 10)));


	d_parts((noids + name));										//form "actual" body info
	d_stats(name, noids);											//form stats of the noid

	(noids + name)->set_location((rand() % MATRIX));				//setting a random location
	(noids + name)->set_sex((rand() % 2));							//setting random sex
 }



/*-----------------------------------------------------*
 * function		: humanoids::move()			   		   *
 * purpose		: mv the noid, & chk if lgl w/ otr fnc *
 * accepts		: int, humanoids *	 			       *
 * returns		: void                                 *
 * comment		: classes rock! 					   *
 *-----------------------------------------------------*/
 void humanoids::move(int name, humanoids *noids)
 {
	int x = 0;								//for loop

	int rand_move = 0;						//what type of move it will make, there are 8 possible choices [0 - 7]
											//0 == UL   1 == UC   2 == UR
											//3 == ML			  4 == MR
											//5 == LL   6 == LC   7 == LR

    int old_location = get_location();		//old location
    int new_location = 0;					//new location

    int surrounded = 0;						//if this reaches a certain amount, the constant SURROUNEDED, the humanoid
    										//is probably surrounded, and the program will not keep on trying to send
    										//it as an argument, because the rules function kept on failing
    										//to prevent a bad loop

	int status = 0;							//will hold the return value passed from the rules function, used
											//in conjunction w/ a while loop



	//it's saying either, keep on trying if either
	//[1] the fules are broken, or
	//[2] the maximum amount of tries has been reached

	//i keep old_location, because new_location may be changing all the time, because i have to overwrite the original
	//value, so i'm able to check it w/ the rules() function [just take a look and you will understand]

	while(surrounded != SURROUNDED)
	{
	    rand_move = rand() % 8;

    	if(rand_move == 0)
    	{
			new_location = old_location + UL;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

		if(rand_move == 1)
		{
			new_location = old_location + UC;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

    	if(rand_move == 2)
    	{
			new_location = old_location + UR;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

		if(rand_move == 3)
		{
			new_location = old_location - ML;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

		if(rand_move == 4)
		{
			new_location = old_location + MR;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

    	if(rand_move == 5)
    	{
			new_location = old_location - LL;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

		if(rand_move == 6)
		{
			new_location = old_location - LC;
			(noids + name)->set_location(new_location);
			surrounded++;
		}

		if(rand_move == 7)
		{
			new_location = old_location - LR;
			(noids + name)->set_location(new_location);
			surrounded++;
		}


		status = (noids + name)->rules(name, noids);

		if(status == 1)
			break;
	}

	if(status == 0)
	{
		(noids + name)->set_location(old_location);			//assign old location, rules were incorrect
	}
 }


/*-----------------------------------------------------*
 * function		: humanoids::rules()			   	   *
 * purpose		: see if rules are being followed      *
 * accepts		: int, humanoids *				       *
 * returns		: int                                  *
 * comment		: 1 == rules being followed, 0 == !1   *
 *-----------------------------------------------------*/
 int humanoids::rules(int name, humanoids *noids)
 {
	int status = 0;													//what we will return, 1 == rules followed, 0 == (!1)
	int x = 0;														//for the loop


	//CHECKING FOR HUMANOIDS OUTSIDE THE MATRIX
	if(((noids + name)->get_location() < BEGIN) || ((noids + name)->get_location() > END))
	{
		status = 0;
		return(status);
	}



	//CHECKING FOR OVERLAPPING HUMANOIDS
    for(x = 0; x < HUMANOIDS; x++)
    {
    	if(name != (noids + x)->get_name())							//doesn't compare itself
    	{
    		if((noids + name)->get_location() == (noids + x)->get_location())
    		{
    			status = 0;
    			return(status);
    		}
        }
    }


	status = 1;														//it passed all the tests, so it followed the rules
	return(status);
 }



/*-----------------------------------------------------*
 * function		: humanoids::d_stats()			   	   *
 * purpose		: use bdy nfo to fll stats [derived]   *
 * accepts		: int, humanoids *				       *
 * returns		: void                                 *
 * comment		: none								   *
 *-----------------------------------------------------*/
 void humanoids::d_stats(int name, humanoids *noids)
 {
	//getting derived info, my multiplying "a" [amount] part by the corresponding multiplier
	(noids + name)->set_smart((((noids + name)->body.get_brain_a()) * M_BRAIN));
	(noids + name)->set_agility((((noids + name)->body.get_arm_a()) * M_LEG));
	(noids + name)->set_strength((((noids + name)->body.get_leg_a()) * M_ARM));
	(noids + name)->set_endurance((((noids + name)->body.get_skin_a()) * M_SKIN));



	//the derived stats have at the very least, a value of "1"
	if((noids + name)->get_smart() == 0)
		(noids + name)->set_smart(1);

	if((noids + name)->get_agility() == 0)
		(noids + name)->set_agility(1);

	if((noids + name)->get_strength() == 0)
		(noids + name)->set_strength(1);

	if((noids + name)->get_endurance() == 0)
		(noids + name)->set_endurance(1);
 }








/*-----------------------------------------------------*
 * function		: humanoids::breed()			   	   *
 * purpose		: breeding							   *
 * accepts		: 3x humanoids *				       *
 * returns		: void                                 *
 * comment		: store results in kid pointer		   *
 *-----------------------------------------------------*/
 void humanoids::breed(humanoids *p_1, humanoids *p_2, humanoids *kid)
 {
   /*--------------------------------------------------------------------*
	* [comments]                                 						 *
	* the idea is that, before we even factor in dom/rec traits          *
	* we are just going to assign the corresponding genes to the kid's   *
	* genes, then worry about the other stuff later, what i mean is      *
	* if genes == 0, it means use gene x from the parent 1, and gene x   *
	* from parent 2, you assign gene x from p_1 to gene x from kid, and  *
	* gene x from p_2, to gene y from the kid, confusing, but it really  *
	* does make sense                                                    *
	*																	 *
	* at the beginning of the function, it's just literally assigning    *
	* the genes of the parents to the kid, after that, i plan to write   *
	* a function, that will, from that info, form the "actual" [used]    *
	* stats from the kid's genes, but that will only be called at the    *
	* end of the prog                                                    *
	*                                                                    *
	*--------------------------------------------------------------------*/






	int genes = (rand() % 4);							//what genes we're goign to use, 0 == XX, 1 == XY, 2 == YX, 3 == YY
														//and no, XY and YX aren't the same, the "first gene" is from the
														//male [or p_1], and the second is the female [or p_2], actually
														//male/female is really irrelevant [including p_1/p_2] just as long
														//as p_1 and p_2 are different sexes



    //just copying the corresponding [as in rand()] gene info to the kid

    //[GENE XX]
	if(genes == 0)
	{
		//[brain]
		kid->body.set_brain_gx_t(p_1->body.get_brain_gx_t());
		kid->body.set_brain_gx_h(p_1->body.get_brain_gx_h());
		kid->body.set_brain_gx_a(p_1->body.get_brain_gx_a());

		kid->body.set_brain_gy_t(p_2->body.get_brain_gx_t());
		kid->body.set_brain_gy_h(p_2->body.get_brain_gx_h());
		kid->body.set_brain_gy_a(p_2->body.get_brain_gx_a());


		//[skin]
		kid->body.set_skin_gx_t(p_1->body.get_skin_gx_t());
		kid->body.set_skin_gx_h(p_1->body.get_skin_gx_h());
		kid->body.set_skin_gx_a(p_1->body.get_skin_gx_a());

		kid->body.set_skin_gy_t(p_2->body.get_skin_gx_t());
		kid->body.set_skin_gy_h(p_2->body.get_skin_gx_h());
		kid->body.set_skin_gy_a(p_2->body.get_skin_gx_a());


		//[arm]
		kid->body.set_arm_gx_t(p_1->body.get_arm_gx_t());
		kid->body.set_arm_gx_h(p_1->body.get_arm_gx_h());
		kid->body.set_arm_gx_a(p_1->body.get_arm_gx_a());

		kid->body.set_arm_gy_t(p_2->body.get_arm_gx_t());
		kid->body.set_arm_gy_h(p_2->body.get_arm_gx_h());
		kid->body.set_arm_gy_a(p_2->body.get_arm_gx_a());


		//[leg]
		kid->body.set_leg_gx_t(p_1->body.get_leg_gx_t());
		kid->body.set_leg_gx_h(p_1->body.get_leg_gx_h());
		kid->body.set_leg_gx_a(p_1->body.get_leg_gx_a());

		kid->body.set_leg_gy_t(p_2->body.get_leg_gx_t());
		kid->body.set_leg_gy_h(p_2->body.get_leg_gx_h());
		kid->body.set_leg_gy_a(p_2->body.get_leg_gx_a());
	}


    //[GENE XY]
	if(genes == 0)
	{
		//[brain]
		kid->body.set_brain_gx_t(p_1->body.get_brain_gx_t());
		kid->body.set_brain_gx_h(p_1->body.get_brain_gx_h());
		kid->body.set_brain_gx_a(p_1->body.get_brain_gx_a());

		kid->body.set_brain_gy_t(p_2->body.get_brain_gy_t());
		kid->body.set_brain_gy_h(p_2->body.get_brain_gy_h());
		kid->body.set_brain_gy_a(p_2->body.get_brain_gy_a());


		//[skin]
		kid->body.set_skin_gx_t(p_1->body.get_skin_gx_t());
		kid->body.set_skin_gx_h(p_1->body.get_skin_gx_h());
		kid->body.set_skin_gx_a(p_1->body.get_skin_gx_a());

		kid->body.set_skin_gy_t(p_2->body.get_skin_gy_t());
		kid->body.set_skin_gy_h(p_2->body.get_skin_gy_h());
		kid->body.set_skin_gy_a(p_2->body.get_skin_gy_a());


		//[arm]
		kid->body.set_arm_gx_t(p_1->body.get_arm_gx_t());
		kid->body.set_arm_gx_h(p_1->body.get_arm_gx_h());
		kid->body.set_arm_gx_a(p_1->body.get_arm_gx_a());

		kid->body.set_arm_gy_t(p_2->body.get_arm_gy_t());
		kid->body.set_arm_gy_h(p_2->body.get_arm_gy_h());
		kid->body.set_arm_gy_a(p_2->body.get_arm_gy_a());


		//[leg]
		kid->body.set_leg_gx_t(p_1->body.get_leg_gx_t());
		kid->body.set_leg_gx_h(p_1->body.get_leg_gx_h());
		kid->body.set_leg_gx_a(p_1->body.get_leg_gx_a());

		kid->body.set_leg_gy_t(p_2->body.get_leg_gy_t());
		kid->body.set_leg_gy_h(p_2->body.get_leg_gy_h());
		kid->body.set_leg_gy_a(p_2->body.get_leg_gy_a());
	}


    //[GENE YX]
	if(genes == 0)
	{
		//[brain]
		kid->body.set_brain_gx_t(p_1->body.get_brain_gx_t());
		kid->body.set_brain_gx_h(p_1->body.get_brain_gx_h());
		kid->body.set_brain_gx_a(p_1->body.get_brain_gx_a());

		kid->body.set_brain_gy_t(p_2->body.get_brain_gy_t());
		kid->body.set_brain_gy_h(p_2->body.get_brain_gy_h());
		kid->body.set_brain_gy_a(p_2->body.get_brain_gy_a());


		//[skin]
		kid->body.set_skin_gx_t(p_1->body.get_skin_gx_t());
		kid->body.set_skin_gx_h(p_1->body.get_skin_gx_h());
		kid->body.set_skin_gx_a(p_1->body.get_skin_gx_a());

		kid->body.set_skin_gy_t(p_2->body.get_skin_gy_t());
		kid->body.set_skin_gy_h(p_2->body.get_skin_gy_h());
		kid->body.set_skin_gy_a(p_2->body.get_skin_gy_a());


		//[arm]
		kid->body.set_arm_gx_t(p_1->body.get_arm_gx_t());
		kid->body.set_arm_gx_h(p_1->body.get_arm_gx_h());
		kid->body.set_arm_gx_a(p_1->body.get_arm_gx_a());

		kid->body.set_arm_gy_t(p_2->body.get_arm_gy_t());
		kid->body.set_arm_gy_h(p_2->body.get_arm_gy_h());
		kid->body.set_arm_gy_a(p_2->body.get_arm_gy_a());


		//[leg]
		kid->body.set_leg_gx_t(p_1->body.get_leg_gx_t());
		kid->body.set_leg_gx_h(p_1->body.get_leg_gx_h());
		kid->body.set_leg_gx_a(p_1->body.get_leg_gx_a());

		kid->body.set_leg_gy_t(p_2->body.get_leg_gy_t());
		kid->body.set_leg_gy_h(p_2->body.get_leg_gy_h());
		kid->body.set_leg_gy_a(p_2->body.get_leg_gy_a());
	}


    //[GENE YY]
	if(genes == 0)
	{
		//[brain]
		kid->body.set_brain_gx_t(p_1->body.get_brain_gy_t());
		kid->body.set_brain_gx_h(p_1->body.get_brain_gy_h());
		kid->body.set_brain_gx_a(p_1->body.get_brain_gy_a());

		kid->body.set_brain_gy_t(p_2->body.get_brain_gy_t());
		kid->body.set_brain_gy_h(p_2->body.get_brain_gy_h());
		kid->body.set_brain_gy_a(p_2->body.get_brain_gy_a());


		//[skin]
		kid->body.set_skin_gx_t(p_1->body.get_skin_gy_t());
		kid->body.set_skin_gx_h(p_1->body.get_skin_gy_h());
		kid->body.set_skin_gx_a(p_1->body.get_skin_gy_a());

		kid->body.set_skin_gy_t(p_2->body.get_skin_gy_t());
		kid->body.set_skin_gy_h(p_2->body.get_skin_gy_h());
		kid->body.set_skin_gy_a(p_2->body.get_skin_gy_a());


		//[arm]
		kid->body.set_arm_gx_t(p_1->body.get_arm_gy_t());
		kid->body.set_arm_gx_h(p_1->body.get_arm_gy_h());
		kid->body.set_arm_gx_a(p_1->body.get_arm_gy_a());

		kid->body.set_arm_gy_t(p_2->body.get_arm_gy_t());
		kid->body.set_arm_gy_h(p_2->body.get_arm_gy_h());
		kid->body.set_arm_gy_a(p_2->body.get_arm_gy_a());


		//[leg]
		kid->body.set_leg_gx_t(p_1->body.get_leg_gy_t());
		kid->body.set_leg_gx_h(p_1->body.get_leg_gy_h());
		kid->body.set_leg_gx_a(p_1->body.get_leg_gy_a());

		kid->body.set_leg_gy_t(p_2->body.get_leg_gy_t());
		kid->body.set_leg_gy_h(p_2->body.get_leg_gy_h());
		kid->body.set_leg_gy_a(p_2->body.get_leg_gy_a());
	}

	p_1->set_offspring();										//incrementing it's offspring variable
	p_2->set_offspring();										//incrementing it's offspring variable

	breeds++;													//incrementing the global variable


	kid->set_generation(year);									//setting the generation [current year]
	kid->set_sex((rand() % 2));									//randomally determining sex
	kid->set_life(1);											//setting the kid as alive

	d_parts(kid);												//setting the "actual" body info

	d_stats(0, kid);											//setting the stats of the kid, it's a neat trick, the
																//passing the 0 part, it doesn't mean that you're editing
																//the first element, it just means you're editing
																//whatever mem address kid is + 0, which is that right
																//there
 }




/*-----------------------------------------------------*
 * function		: humanoids::d_parts()			   	   *
 * purpose		: form actual nfo from genes		   *
 * accepts		: humanoids *					       *
 * returns		: void                                 *
 * comment		: directly edits the pointer		   *
 *-----------------------------------------------------*/
 void humanoids::d_parts(humanoids *kayla)
 {
 	int choice = 0;						//will determine which gene to use when they are both of the same type [rec || dom]
 										//1 means we use gx of kayla, and 0 means we use gy of kayla

 	//the theory is that if one gene is somehow superior, the "actual" gets EVERYTHING from that gene
 	//if somehow, they're both the same, then i use rand() to determine which gene the kid gets


 	//[brain]
 	if(kayla->body.get_brain_gx_t() > kayla->body.get_brain_gy_t())					//gx is dom, gy is rec
 	{
 		kayla->body.set_brain_h(kayla->body.get_brain_gx_h());
		kayla->body.set_brain_a(kayla->body.get_brain_gx_a());
	}


	if(kayla->body.get_brain_gx_t() < kayla->body.get_brain_gy_t())					//gx is rec, gy is dom
	{
 		kayla->body.set_brain_h(kayla->body.get_brain_gy_h());
		kayla->body.set_brain_a(kayla->body.get_brain_gy_a());
	}

	if(kayla->body.get_brain_gx_t() == kayla->body.get_brain_gy_t())				//both the same type
	{
		choice = (rand() % 2);

		if(choice == 1)
		{
			kayla->body.set_brain_h(kayla->body.get_brain_gx_h());
			kayla->body.set_brain_a(kayla->body.get_brain_gx_a());
		}

		if(choice == 0)
		{
			kayla->body.set_brain_h(kayla->body.get_brain_gy_h());
			kayla->body.set_brain_a(kayla->body.get_brain_gy_a());
		}
	}


 	//[arm]
 	if(kayla->body.get_arm_gx_t() > kayla->body.get_arm_gy_t())					//gx is dom, gy is rec
 	{
 		kayla->body.set_arm_h(kayla->body.get_arm_gx_h());
		kayla->body.set_arm_a(kayla->body.get_arm_gx_a());
	}


	if(kayla->body.get_arm_gx_t() < kayla->body.get_arm_gy_t())					//gx is rec, gy is dom
	{
 		kayla->body.set_arm_h(kayla->body.get_arm_gy_h());
		kayla->body.set_arm_a(kayla->body.get_arm_gy_a());
	}

	if(kayla->body.get_arm_gx_t() == kayla->body.get_arm_gy_t())				//both the same type
	{
		choice = (rand() % 2);

		if(choice == 1)
		{
			kayla->body.set_arm_h(kayla->body.get_arm_gx_h());
			kayla->body.set_arm_a(kayla->body.get_arm_gx_a());
		}

		if(choice == 0)
		{
			kayla->body.set_arm_h(kayla->body.get_arm_gy_h());
			kayla->body.set_arm_a(kayla->body.get_arm_gy_a());
		}
	}


 	//[leg]
 	if(kayla->body.get_leg_gx_t() > kayla->body.get_leg_gy_t())					//gx is dom, gy is rec
 	{
 		kayla->body.set_leg_h(kayla->body.get_leg_gx_h());
		kayla->body.set_leg_a(kayla->body.get_leg_gx_a());
	}


	if(kayla->body.get_leg_gx_t() < kayla->body.get_leg_gy_t())					//gx is rec, gy is dom
	{
 		kayla->body.set_leg_h(kayla->body.get_leg_gy_h());
		kayla->body.set_leg_a(kayla->body.get_leg_gy_a());
	}

	if(kayla->body.get_leg_gx_t() == kayla->body.get_leg_gy_t())				//both the same type
	{
		choice = (rand() % 2);

		if(choice == 1)
		{
			kayla->body.set_leg_h(kayla->body.get_leg_gx_h());
			kayla->body.set_leg_a(kayla->body.get_leg_gx_a());
		}

		if(choice == 0)
		{
			kayla->body.set_leg_h(kayla->body.get_leg_gy_h());
			kayla->body.set_leg_a(kayla->body.get_leg_gy_a());
		}
	}


 	//[skin]
 	if(kayla->body.get_skin_gx_t() > kayla->body.get_skin_gy_t())					//gx is dom, gy is rec
 	{
 		kayla->body.set_skin_h(kayla->body.get_skin_gx_h());
		kayla->body.set_skin_a(kayla->body.get_skin_gx_a());
	}


	if(kayla->body.get_skin_gx_t() < kayla->body.get_skin_gy_t())					//gx is rec, gy is dom
	{
 		kayla->body.set_skin_h(kayla->body.get_skin_gy_h());
		kayla->body.set_skin_a(kayla->body.get_skin_gy_a());
	}

	if(kayla->body.get_skin_gx_t() == kayla->body.get_skin_gy_t())					//both the same type
	{
		choice = (rand() % 2);

		if(choice == 1)
		{
			kayla->body.set_skin_h(kayla->body.get_skin_gx_h());
			kayla->body.set_skin_a(kayla->body.get_skin_gx_a());
		}

		if(choice == 0)
		{
			kayla->body.set_skin_h(kayla->body.get_skin_gy_h());
			kayla->body.set_skin_a(kayla->body.get_skin_gy_a());
		}
	}


 }



/*-----------------------------------------------------*
 * function		: humanoids::fight()			   	   *
 * purpose		: fighting between two noids		   *
 * accepts		: 2x humanoids *				       *
 * returns		: void                                 *
 * comment		: directly edits the pointer		   *
 *-----------------------------------------------------*/
 void humanoids::fight(humanoids *f_1, humanoids *f_2)
 {
 	int status_strike = 0;								//who goes first, 0 means f_1 goes first, 1 means f_2 goes first
 														//to be determined later in the code

 	int f1_endurance = f_1->get_endurance();			//gets it's old endurance
 	int f2_endurance = f_2->get_endurance();			//gets it's old endurance

 	int increase_body = (rand() % 4);					//determine what body part of the winner is increased
 														//0 == brain
 														//1 == arm
 														//2 == leg
 														//3 == skin


	f_1->set_fights();									//incrementing the fights variable
	f_2->set_fights();									//incrementing the fights variable

	fights++;											//incrementing the global variable


	if(f_1->get_smart() > f_2->get_smart())				//a smarter noid goes first
	{
		status_strike = 0;
	}
	else
	{
		status_strike = 1;
	}


	//loop instantly breaks when one of the noids is found dead

 	while(status_strike == 0)												//f_1 gets first strike
 	{
		f_2->set_endurance(f_2->get_endurance() - f_1->get_strength());


		//this is the the process of checking to see if one is dead or not
		if(f_1->get_endurance() <= 0)
		{
			f_1->set_life(0);
			break;
		}

		if(f_2->get_endurance() <= 0)
		{
			f_2->set_life(0);
			break;
		}


		f_1->set_endurance(f_1->get_endurance() - f_2->get_strength());


		//this is the the process of checking to see if one is dead or not
		if(f_1->get_endurance() <= 0)
		{
			f_1->set_life(0);
			break;
		}

		if(f_2->get_endurance() <= 0)
		{
			f_2->set_life(0);
			break;
		}
	}




 	while(status_strike == 1)												//f_2 gets first strike
 	{
		f_1->set_endurance(f_1->get_endurance() - f_2->get_strength());


		//this is the the process of checking to see if one is dead or not
		if(f_1->get_endurance() <= 0)
		{
			f_1->set_life(0);
			break;
		}

		if(f_2->get_endurance() <= 0)
		{
			f_2->set_life(0);
			break;
		}


		f_2->set_endurance(f_2->get_endurance() - f_1->get_strength());


		//this is the the process of checking to see if one is dead or not
		if(f_1->get_endurance() <= 0)
		{
			f_1->set_life(0);
			break;
		}

		if(f_2->get_endurance() <= 0)
		{
			f_2->set_life(0);
			break;
		}
	}



  	//when you win a fight, one of your random body parts, gets a random increase

  	if(f_1->get_life() == 1)												//f_1 was the winner
  	{
  		//increasing the brain
  		if(increase_body == 0)
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_1->body.get_brain_gx_h() != 0)
  				f_1->body.set_brain_gx_a((f_1->body.get_brain_gx_a() + (rand() % 10)));

  			if(f_1->body.get_brain_gy_h() != 0)
  				f_1->body.set_brain_gy_a((f_1->body.get_brain_gy_a() + (rand() % 10)));


		//increasing the arm
  		else if(increase_body == 1)
  		{
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_1->body.get_arm_gx_h() != 0)
  				f_1->body.set_arm_gx_a((f_1->body.get_arm_gx_a() + (rand() % 10)));

  			if(f_1->body.get_arm_gy_h() != 0)
  				f_1->body.set_arm_gy_a((f_1->body.get_arm_gy_a() + (rand() % 10)));
  		}


		//increasing the leg
  		else if(increase_body == 2)
  		{
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_1->body.get_leg_gx_h() != 0)
  				f_1->body.set_leg_gx_a((f_1->body.get_leg_gx_a() + (rand() % 10)));

  			if(f_1->body.get_leg_gy_h() != 0)
  				f_1->body.set_leg_gy_a((f_1->body.get_leg_gy_a() + (rand() % 10)));
  		}


		//increasing the skin
  		else if(increase_body == 3)
  		{
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_1->body.get_skin_gx_h() != 0)
  				f_1->body.set_skin_gx_a((f_1->body.get_skin_gx_a() + (rand() % 10)));

  			if(f_1->body.get_skin_gy_h() != 0)
  				f_1->body.set_skin_gy_a((f_1->body.get_skin_gy_a() + (rand() % 10)));
  		}
  	}





  	if(f_2->get_life() == 1)												//f_2 was the winner
 	{
  		//increasing the brain
  		if(increase_body == 0)
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_2->body.get_brain_gx_h() != 0)
  				f_2->body.set_brain_gx_a((f_2->body.get_brain_gx_a() + (rand() % 10)));

  			if(f_2->body.get_brain_gy_h() != 0)
  				f_2->body.set_brain_gy_a((f_2->body.get_brain_gy_a() + (rand() % 10)));


		//increasing the arm
  		else if(increase_body == 1)
  		{
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_2->body.get_arm_gx_h() != 0)
  				f_2->body.set_arm_gx_a((f_2->body.get_arm_gx_a() + (rand() % 10)));

  			if(f_2->body.get_arm_gy_h() != 0)
  				f_2->body.set_arm_gy_a((f_2->body.get_arm_gy_a() + (rand() % 10)));
  		}


		//increasing the leg
  		else if(increase_body == 2)
  		{
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_2->body.get_leg_gx_h() != 0)
  				f_2->body.set_leg_gx_a((f_2->body.get_leg_gx_a() + (rand() % 10)));

  			if(f_2->body.get_leg_gy_h() != 0)
  				f_2->body.set_leg_gy_a((f_2->body.get_leg_gy_a() + (rand() % 10)));
  		}


		//increasing the skin
  		else if(increase_body == 3)
  		{
			//it's basically saying that if it has the body part [gene wise], then increase the "amount" of it

  			if(f_2->body.get_skin_gx_h() != 0)
  				f_2->body.set_skin_gx_a((f_2->body.get_skin_gx_a() + (rand() % 10)));

  			if(f_2->body.get_skin_gy_h() != 0)
  				f_2->body.set_skin_gy_a((f_2->body.get_skin_gy_a() + (rand() % 10)));
  		}
  	}


	//resetting it's stats w/ new info
 	f_1->d_parts((f_1 + 0));
 	f_2->d_parts((f_2 + 0));

 	f_1->d_stats(0, f_1);
 	f_2->d_stats(0, f_2);
 }




/*-----------------------------------------------------*
 * function		: humanoids::reaper()			   	   *
 * purpose		: find a dead noid for breed()		   *
 * accepts		: humanoids *   				       *
 * returns		: int                                  *
 * comment		: if return R_REAPER, no dead bdies    *
 *-----------------------------------------------------*/
 int humanoids::reaper(humanoids *noids)
 {
 	int name = R_REAPER;						//name of dead noid [R_REAPER value means no dead noids]
 	int x = 0;									//for loop

	//the instant it finds a dead noid, the loop terminates, and it returns the name of the dead noid

 	for(x = 0; x < HUMANOIDS; x++)
 	{
 		if((noids + x)->get_life() == 0)
 		{
 			name = x;
 			return(name);
 		}
 	}

	return(R_REAPER);							//no dead noids, so technically, a R_REAPER should be returned
 }



/*-----------------------------------------------------*
 * function		: humanoids::print()			   	   *
 * purpose		: printf noid info					   *
 * accepts		: int  							       *
 * returns		: void                                 *
 * comment		: none								   *
 *-----------------------------------------------------*/
 void humanoids::print(int choice)
 {
 	;
 }


/*-----------------------------------------------------*
 * function		: humanoids::almanac()			   	   *
 * purpose		: shows stats of the simulation		   *
 * accepts		: humanoids *    					   *
 * returns		: void                                 *
 * comment		: none								   *
 *-----------------------------------------------------*/
 void humanoids::almanac(humanoids *noid)
 {
	int male = 0;                               //keeps track of genders of noids
	int female = 0;								//keeps track of genders of noids

	int alive = 0;                              //keeps track of current alive/dead
	int dead = 0;								//keeps track of current alive/dead

	int x = 0;									//for loop
	int y = 0;									//cnt for dead_name array

	int dead_name[HUMANOIDS];					//keeps track of the names of the dead noids



	//checking for amount of males/females
	for(x = 0; x < HUMANOIDS; x++)
	{
		if(((noid + x)->get_sex() == 0) && ((noid + x)->get_life() == 1))			//it's a female
			female++;

		if(((noid + x)->get_sex() == 1) && ((noid + x)->get_life() == 1))			//it's a male
			male++;
	}


	//checking for amount of alive/dead
	for(x = 0; x < HUMANOIDS; x++)
	{
		if((noid + x)->get_life() == 0)			//it's dead
			dead++;

		if((noid + x)->get_life() == 1)			//it's alive
			alive++;
	}


	//checking for the names of the dead noids
	for(x = 0; x < HUMANOIDS; x++)
	{
		if((noid + x)->get_life() == 0)
		{
			dead_name[y] = x;
			y++;
		}
	}


	puts("\n\n");

	printf("male\t:\t%d\n", male);
	printf("female\t:\t%d\n\n", female);

	printf("alive\t:\t%d\n", alive);
	printf("dead\t:\t%d\n\n", dead);

	printf("year\t:\t%d\n\n", year);

	printf("fights\t:\t%d\n", fights);
	printf("breeds\t:\t%d\n", breeds);

	puts("\n\n");
 }



/*-----------------------------------------------------*
 * function		: humanoids::physics()			   	   *
 * purpose		: ties all functions toghether   	   *
 * accepts		: int, humanoids * 					   *
 * returns		: void                                 *
 * comment		: none								   *
 *-----------------------------------------------------*/
 void humanoids::physics(int name, humanoids *noids)
 {
	int chance = 0;												//used in the process of determining fights
	int x = 0;													//for loop
	int dead_body = R_REAPER;									//name of the dead body, the way it is now, ! body

	//moving the bug [depends on agility]
 	for(x = 0; x < (noids + name)->get_agility(); x++)
 	{
 		(noids + name)->move(name, noids);
 	}



	for(x = 0; x < HUMANOIDS; x++)
	{
		//making sure they're not dead bodies, and it doesn't compare itself
		if((x != name) && ((noids + name)->get_life() == 1) && ((noids + x)->get_life() == 1))
		{
			//checks to see if the bug being compared to is near it

			//huge ass conditional statement
		 	if((((noids + name)->get_location() + UL) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() + UC) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() + UR) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() - ML) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() + MR) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() - LL) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() - LC) == (noids + x)->get_location()) ||
		 	   (((noids + name)->get_location() - LR) == (noids + x)->get_location()))

			//the code that goes w/ the statement
		 	{
				//both the same sex, might fight [depending on sex really]
				if((noids + name)->get_sex() == (noids + x)->get_sex())
				{
                	//they're both male
                	if((noids + name)->get_sex() == 1)
                	{
						chance = (rand() % M_FIGHT);

						if(chance < FIGHT)
							(noids + name)->fight((noids + name), (noids + x));
                	}


                	//they're both female
                	if((noids + name)->get_sex() == 0)
                	{
						chance = (rand() % F_FIGHT);

						if(chance < FIGHT)
							(noids + name)->fight((noids + name), (noids + x));
                	}
				}


				//different sex, will mate if enough room in matrix
		        if((noids + name)->get_sex() != (noids + x)->get_sex())
		        {
					dead_body = (noids + name)->reaper(noids);

					//a dead body was found
					if(dead_body != R_REAPER)
					{
						(noids + name)->breed((noids + name), (noids + x), (noids + dead_body));

						printf("\n[%d]\n", dead_body);
						dead_body = R_REAPER;									//resetting it
					}
		        }

		  	}               //end of big conditional if [is the bug being compared near to it]

		}					//end of big if [bug doesn't compare itself]

	}						//end of for loop [used to target noid to compare to]

 }							//end of function






 void main()
 {
	humanoids nam[HUMANOIDS];					//how many people
	int scancode = 0;							//in conjunction to see if user pressed esc
	int x = 0;									//for loop


    srand((unsigned int) time(NULL));						//reseeding the rand()


	for(x = 0; x < HUMANOIDS; x++)
	{
	 	(nam + 0)->randomize(x, nam);			//giving random values for the noids
	}


	//the gateway to the back end
	while(scancode != 1)						//loops here until scancode == 1 [esc has been pressed]
	{
		for(x = 0; x < HUMANOIDS; x++)
		{
			(nam + 0)->physics(x, nam);
		}

		(nam + 0)->almanac(nam);				//getting matrix info
		year++;									//incrementing the year
        scancode = check_esc();					//checks if the user pressed esc
    }
 }






/*-----------------------------------------------------*
 * function		: check_esc()						   *
 * purpose		: check if esc was hit			       *
 * accepts		: void                                 *
 * returns		: char                                 *
 * comment		: has to do something with scancodes   *
 *-----------------------------------------------------*/
 char check_esc(void)
 {
	unsigned char sc;

	_asm
	{
		in ax,60h
     	mov sc,al
   	}

	return sc;
 }
