#include <iostream>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include "game.h"

using namespace std;

void showHelp()
	{
	cout << " -n    pas de Pré apprentissage" << endl;
	cout << " -s    ne pas afficher d'output dans la console" << endl;
	cout << " -h    afficher cette aide " << endl;
	}

int main(int argc, char *argv[])
	{
	Game G;
	int i,prelearn=1;
	bool showoutput=1;
	for (i=1;i<argc;i++)
		{
		if(!strcmp("-n",argv[i])) prelearn=0;
		if(!strcmp("-s",argv[i])) showoutput=0;
		if(!strcmp("-h",argv[i])) 
			{
			showHelp();
			return 1;
			}
		}
	G.toggleShow(showoutput);
	if(prelearn)
		{
		cout << "Learn ....\n";
		G.preLearn();
		G.preTest();
		cout << "Learn OK ...\n";
		cout << "press a key !\n";
		cin >> i;
		}
	
	cout << "Start interface\n";
	
	if(fork()==0)
		{
		chdir("InterfaceCpp");
		execv("iface",argv);
		}
	else
		{	
		G.Run();
		exit(0);
		}
	return 0;
	}
