diff --git a/.gitignore b/.gitignore index 5a1127b6cd7c8d7afa4d5e803f9816cb94073b53..4436df870f59c287c5115b5b955bfb2da0cccc8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ a.out obj/* -test.c -stackchess +*.o +*.aux +*.log +*.out +*.toc +*.gz + diff --git a/build/stackchess b/build/stackchess new file mode 100755 index 0000000000000000000000000000000000000000..41d0e37c0640ec688ecf6f1be1fd9412a4f73de8 Binary files /dev/null and b/build/stackchess differ diff --git a/build/stackchess32.exe b/build/stackchess32.exe index 06577d265ac6bed6b2dfeff027bb811f22227fa8..76beaa29247670b8f8e22c6a0cf887b257288d3b 100755 Binary files a/build/stackchess32.exe and b/build/stackchess32.exe differ diff --git a/build/stackchess64.exe b/build/stackchess64.exe index 7ff28b94e8791ea5c3ea6bbfa837fc111a5a3f7a..2d47a2239f62e4c7cca6788c2c4da2a4b7b59b27 100755 Binary files a/build/stackchess64.exe and b/build/stackchess64.exe differ diff --git a/doc/latex/rapport.pdf b/doc/latex/rapport.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ebd5a578d1bcca11bd76ef05d160b80eaa3a47dc Binary files /dev/null and b/doc/latex/rapport.pdf differ diff --git a/doc/latex/rapport.tex b/doc/latex/rapport.tex new file mode 100644 index 0000000000000000000000000000000000000000..87e7cc401eab3af06920b9f16400e04d8411264d --- /dev/null +++ b/doc/latex/rapport.tex @@ -0,0 +1,30 @@ +\documentclass[french]{article} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{lmodern} +\usepackage[french]{babel} +\selectlanguage{french} +\usepackage{amsmath} +\usepackage{float} +\usepackage{amssymb} +\usepackage{hyperref} +\usepackage{xcolor} +\usepackage{graphicx} +\hypersetup{ + colorlinks, + linkcolor={red!50!black}, + citecolor={blue!50!black}, + urlcolor={blue!80!black} +} +\author{Loïc DUBARD} +\title{Projet de programmation Impérative :\\ Stackchess} + +\begin{document} +\maketitle +\tableofcontents +\clearpage +\section*{Introduction} +\section{Démarche générale} +\subsection{Présentation des structures de données principales utilisées ainsi que les différentes opérations implémentées sur ces structures} +\subsubsection*{Pile} +\end{document} \ No newline at end of file diff --git a/obj/affichage.o b/obj/affichage.o index 4fa5a7f21021d8e68665c675ceef988810e6831c..faa65d65fa41cdf03b03ea603f33d8c677ea8f34 100644 Binary files a/obj/affichage.o and b/obj/affichage.o differ diff --git a/obj/main.o b/obj/main.o index 002e6f66c9d75b1012b84d6576ad88725219043c..b16deefae9bb0e12a5cdf3a41140ef1300ed0a19 100644 Binary files a/obj/main.o and b/obj/main.o differ diff --git a/obj/tableau.o b/obj/tableau.o index a303e322e21034761410d5d7cdbeaba6fddc9570..2df463fe8f6cd0239cacfd353d94a196f00558ad 100644 Binary files a/obj/tableau.o and b/obj/tableau.o differ diff --git a/src/affichage.c b/src/affichage.c index b4d4bd9872f6653f8f37e7fed8c976d1a7a4a47b..7b315106da10561cb9bcf7e94183103b4674bcab 100644 --- a/src/affichage.c +++ b/src/affichage.c @@ -16,7 +16,7 @@ void affiche_pile_a_cote(pile **tableau,char *sel,int x,int y,int N, int ligne,i { int k; if (ligne == N-1) printf(" %s:",sel); - noeud* tmp=tableau[x][y].sommet; + pile tmp=tableau[x][y]; for (k=0 ; k<nb ; k++){ if (ligne==N-nb+k){ if (ligne != N-1) printf(" "); @@ -58,14 +58,14 @@ void affichetableau_pile_cote(pile **tableau, int N,char *sel) if ((i+j)%2 == 1){ if (est_vide(tableau[i][j])) printf(NOIR " " RESET); - else if (tableau[i][j].sommet->chaine[1] == 'N') + else if (tableau[i][j]->chaine[1] == 'N') printf(PNOIRE NOIR "%c " RESET, *sommet(tableau[i][j])); else printf(PBLANCHE NOIR"%c " RESET, *sommet(tableau[i][j])); } else { if (est_vide(tableau[i][j])) printf(BLANC " " RESET); - else if (tableau[i][j].sommet->chaine[1] == 'N') + else if (tableau[i][j]->chaine[1] == 'N') printf(PNOIRE BLANC"%c " RESET, *sommet(tableau[i][j])); else printf(PBLANCHE BLANC"%c " RESET, *sommet(tableau[i][j])); diff --git a/src/deplacement.c b/src/deplacement.c index f5ba5a3d87bd6d548b5bdada0dfd546c4be351ca..25c24ba86aade921bfc618ec16a954d47ac8da95 100644 --- a/src/deplacement.c +++ b/src/deplacement.c @@ -48,7 +48,7 @@ void case_destination(pile **tableau,int N,int i_src,int j_src, int *i_dest,int if (dest[1] != '\0'){ determiner_indices(dest,N,i_dest,j_dest); if (*i_dest>=0 && *i_dest<N && *j_dest>=0 && *j_dest<N && nb>nb_de_pion(tableau[*i_dest][*j_dest],"BN"[(*tour+1)%2])){ - noeud* tmp=tableau[i_src][j_src].sommet; + pile tmp=tableau[i_src][j_src]; int valide,i; for (i=0 ; i<nb ; i++){ diff --git a/src/tableau.c b/src/tableau.c index 3e7f46905b4d03dc96bd288a79d636295fa2a4cb..9751f913d520c492d2efea4f9c2cef329e2528b9 100644 --- a/src/tableau.c +++ b/src/tableau.c @@ -13,39 +13,39 @@ pile **initialisation(int N) for (i=0 ; i<N ; i++){ tableau[i] =(pile*)malloc(N*sizeof(pile)); for (j=0 ; j<N ; j++) - tableau[i][j].sommet = NULL; + tableau[i][j] = NULL; } return tableau; } int est_vide(pile p) { - return p.sommet == NULL; + return p == NULL; } char *sommet(pile p) { - if (!est_vide(p)) return p.sommet->chaine; + if (!est_vide(p)) return p->chaine; else return "\0"; } void empiler(pile *p, char *elt) { - noeud* nouveau; - nouveau = (noeud*) malloc(sizeof(noeud)); + pile nouveau; + nouveau = (pile) malloc(sizeof(struct _noeud)); nouveau->chaine = elt; - nouveau->next = p->sommet; - p->sommet = nouveau; + nouveau->next = *p; + *p = nouveau; } char *depiler(pile *p) { if (! est_vide(*p)){ char *elt; - elt = p->sommet->chaine; - noeud* tmp = p->sommet; - p->sommet = p->sommet->next; + elt = (*p)->chaine; + pile tmp = *p; + *p = (*p)->next; free(tmp); return elt; } @@ -54,7 +54,7 @@ char *depiler(pile *p) void reset(pile *p) { - while (p->sommet) + while (! est_vide(*p)) /*termine lorsque p n'a plus de sommet à dépiler (car p est de longueur finie)*/ depiler(p); } @@ -99,11 +99,10 @@ void debut_partie(pile **tableau, int N) int longueur_pile(pile p) { int i=0; - noeud* tmp=p.sommet; - while (tmp != NULL){ + while (p != NULL){ /*termine quand on arrive au bout de la pile qui est de longueur finie*/ i++; - tmp=tmp->next; + p=p->next; } return i; } @@ -118,11 +117,10 @@ void determiner_indices(char *sel,int N,int *i,int *j) int nb_de_pion(pile p,char couleur) { int i=0; - noeud* tmp=p.sommet; - while (tmp != NULL){ + while (p != NULL){ /*termine car la pile est de longueur finie*/ - if (tmp->chaine[1]==couleur) i++; - tmp=tmp->next; + if (p->chaine[1]==couleur) i++; + p=p->next; } return i; } @@ -131,8 +129,8 @@ int nb_de_cavaliers(pile p,char couleur,int nb) { int i,k=0; for (i=0 ; i<nb ; i++){ - if (p.sommet->chaine[0] == 'C' && p.sommet->chaine[1]==couleur) k++; - p.sommet=p.sommet->next; + if (p->chaine[0] == 'C' && p->chaine[1]==couleur) k++; + p=p->next; } return k; } @@ -158,12 +156,12 @@ int partie_finie(pile ** tableau,int N,int tour) printf("On a un cas d'égalité !"); return 1; } - noeud* tmp; + pile tmp; if (k+l==4){ /*le cas il reste à chacun un fou et une tour*/ for (i=0 ; i<N ; i++){ for (j=0 ; j<N ; j++){ - tmp=tableau[i][j].sommet; + tmp=tableau[i][j]; while (tmp != NULL){ if (tmp->chaine[0]=='T'){ if (tmp->chaine[1]=='B') toursb+=1; diff --git a/src/tableau.h b/src/tableau.h index e2c0c965b85abe7e404b7f357544cf9e99cb4925..03768e2d2fa3f94d447e1b91883a5968638a6ea5 100644 --- a/src/tableau.h +++ b/src/tableau.h @@ -7,15 +7,10 @@ #include<string.h> /*tableau.h*/ -typedef struct _noeud noeud; +typedef struct _noeud * pile; struct _noeud{ char *chaine; - noeud* next; -}; - -typedef struct _pile pile; -struct _pile{ - noeud* sommet; + pile next; }; /*