
//........ Feedback: .........//
//... bisonchess@gmail.com ...//
//............................//

#include <time.h>
#include <string>
#include <windows.h>
#include <cmath>

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

//#define AUTO
#define PST_TXT

/*
Using Auto Generation of eval parameters
1. Uncomment '#define AUTO'
2. Uncomment 'a->MultiplyFile("Parameters.txt");' and run the program
3. Comment 'a->MultiplyFile("Parameters.txt");' after first run of generation
*/

#ifdef AUTO
	//#define MODEL
	#define GEN_USE_LOG		false
#else
	// comment if RELEASE
	#define PERSON_VISIBLE
#endif

#define PUBLIC_RELEASE

#include "bison.h"
#include "move.h"
#include "pst.h"
#include "board.h"
#include "hash.h"
#include "init.h"

#include "material.h"
#include "pawn.h"
#include "eval.h"
#include "endgame.h"
#include "move_gen.h"
#include "move_do.h"
#include "fen.h"
#include "see.h"
#include "sort.h"
#include "trans.h"
#include "searcher.h"
#include "test.h"
#include "root.h"
#include "search.h"
#include "uci.h"

#ifdef AUTO
#include "auto.h"
#endif


int main(void) { 

	Searcher s[1];
	UCI uci[1];
	Board b[1];

	Init();
	b->Clear();
	MaterialInit();
	pawn_info[s->active_person].InitStorm(s->ActivePerson());
	pawn_info[s->active_person].InitShelter(s->ActivePerson());
		
	setvbuf(stdin,  NULL, _IONBF, 0);
	setvbuf(stdout, NULL, _IONBF, 0);

#ifdef AUTO
	Auto a[1];
	Personality p[1];
#ifndef MODEL
	//a->MultiplyFile("Parameters.txt");
	//a->FileToArray(s);
	a->Calculate(s, b);		
#else
	FILE *mminput = fopen("math_mod.txt", "w+");
	char zero_file[] = "Parameters.txt"; // 150
	char stand_file[] = "STANDART.txt";
	int pl, nb, cy, mha, ms_time = 60*1000*12; // minutes
	float mhi;	
	int i, k;
	float f;
	char zf[128];
	strcpy(zf, "PRM9.txt");	
	a->SetModelAdvantage(10);
	a->MathModel(s, b, mminput, zf, stand_file, pl=60, nb=30, cy=1, mha=10, mhi=2.0, ms_time);	
#endif
#endif

	// benchmarks
//#define BENCH
#ifdef BENCH
	uci->OptionsInit();
	uci->ResetSearchOptions(s);
	//s->Benchmark(search_positions);
	s->Benchmark(debug_positions, true);
#endif

	uci->ParseCommand(b, s);
		
	return 0;
}
