/*
    Living Realms is a primate evolution simulator.
    Copyright (C) 2011  Sterling Pickens

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __LIFE_H__
#define __LIFE_H__

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <sys/time.h>
#include <stdint.h>
#include <sys/types.h>
#include <string.h>
#include "Globals.h"
#include "DEM.h"
//#include "Random.h"

extern struct Species ***life;
extern struct Stats *stats;
extern struct Stats_T stats_t;
extern struct image_attr *ia;
extern struct Thread_I *Actions_t_info;
extern char *life_speed_up_X;
extern char *life_speed_up_Y;
extern pthread_barrier_t Barrier1;
extern pthread_barrier_t Barrier2;
extern pthread_barrier_t Barrier3;
extern pthread_mutex_t Mutex1;
extern pthread_mutex_t Mutex2;
extern pthread_mutex_t Mutex3;
extern pthread_mutex_t Region_Mutexes[HEIGHT/5];
extern unsigned char Region_Handled[HEIGHT/5];
extern int Stats_Handled;
extern double Year_Runtime;
extern double Backup_Freq_Runtime;
extern uint32_t Backup_Freq;
extern int No_Exit;
extern uint32_t Thread_Step;
extern struct timeval Year_Starttime,Year_Endtime;
extern unsigned char **Alive;
extern unsigned char **Fought;
extern unsigned char **Mated;
//extern unsigned char Region_Offsets[5];

//void KILL_Tribe(uint32_t y, uint32_t x);
//int Tribe_Migrate(uint32_t src_y, uint32_t src_x, uint32_t *dest, uint64_t *rseed);
//int Fight_Tribe(struct Species *one, struct Species *two, uint64_t *rseed);
//void Tribe_Interactions(uint32_t src_y, uint32_t src_x, uint32_t tid, uint64_t *rseed);
//void FM_Reset(uint32_t start, uint32_t end);
//int Tribe_Move_To_Water(uint32_t src_y, uint32_t src_x, uint32_t *dest, uint64_t *rseed);
//int Tribe_Water_Migrate(uint32_t src_y, uint32_t src_x, uint32_t *dest, uint64_t *rseed);
//int Moved_To_Land(uint32_t src_y, uint32_t src_x, uint64_t *rseed);
//int Tribe_Borders_Water(uint32_t src_y, uint32_t src_x);
void Allocate_Life_Array(void);
//void Gen_Tribe_Color(struct Species *one, unsigned char *rgb);
void Add_First_Life(struct Species *one);
//int Is_Same_Species(struct Species *one, struct Species *two);
//void Create_Life(struct Species *one, struct Species *two, struct Species *three, uint64_t *rseed);
//float Location_Temp(uint32_t src_y, uint32_t src_x);
//int Climate_Fatal(struct Species *one, uint32_t src_y, uint32_t src_x);
void *Tribe_Actions(void *tid);
//void Drawl_Image(void);

#endif