/* This file is part of OloNO Copyright (C) 2008 Martin Potier () and David Wagner () This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 3 of the License. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** \file * main.c * Contient la boucle principale du programme */ #include #include #include #include // On inclu nos librairies personnelles : #include "../lib/libDefine.h" #include "../lib/libDisplay.h" #include "../lib/libPlay.h" #include "../lib/libCases.h" #include "../lib/libIA.h" int boucleDeJeu(CASE *plateau[]); // Certains compilos définissent _WIN32, d'autres __WIN32 #ifdef _WIN32 #ifndef __WIN32 #define __WIN32 #endif #endif // Variables globales arguments args; int taillePlateau; // Taille du plateau par défaut; //! Lance le programme /** * Cette fonction est la boucle principale du programme. * Elle permet de rassembler toutes les autres fonctions dans un contenu reflétant * le fonctionnement du programme. Pour comprendre le fonctionnement d'un programme, * lire le main() devrait suffire. */ int main(int argc, char ** argv) { if (argc < 5) return 1; /* On initialise les arguments à leur valeur par défaut */ args.taillePlateau = atoi(argv[1]); args.verbose = (strcmp("grilleOn", argv[2]) == 0) ? 1 : 0; strcpy(args.type, argv[3]); args.couleur = (*argv[4] == 'B' ? 0 : 1); args.Tore = 0; taillePlateau = args.taillePlateau; // erreur("valeur d'un coin:%d\n", valeurLigne(0)+valeurLigne(0)); // erreur("valeur en diagonale d'un coin:%d\n", valeurLigne(1)+valeurLigne(1)); // erreur("idem, mais a la fin:%d\n", valeurLigne(taillePlateau-2)+valeurLigne(taillePlateau-2)); // erreur("valeur d'un pion a coté du joker:%d\n", valeurLigne(taillePlateau/2 - 1)*valeurLigne(taillePlateau/2 + 1)); // ############################################################### // // ### On commence les choses sérieuses ici (cad le main) ######## // // ############################################################### // int i=0; // Variables de boucle. int points[]={0, 0}; // Points obtenus pour les blancs et les noirs char retour; // ######################################################################################### // // # ETAPE 2 : Initialiser le plateau ###################################################### // // ######################################################################################### // // On créé un tableau à la taille demandée par le joueur CASE ** plateau = createPlateau(); // On initialise ce tableau avec la consigne initPlateau(plateau); // ######################################################################################### // // # ETAPE 3 : Boucle de jeux principale ################################################### // // ######################################################################################### // retour = boucleDeJeu(plateau); if (retour) erreur("La boucle de jeu s'est arrêtée à cause d'une erreur\n"); // ######################################################################################### // // # ETAPE 4 : Score ####################################################################### // // ######################################################################################### // affichePlateau(plateau); score(plateau, points); afficherScore(points); // On oublie pas de libérer l'espace mallocé for (i=0; i