/* Maze generator for POV-Ray, with Tarjan's sets method Copyright (C) 2005 Pierre Schwartz (khayyam) -> khayyam_zozo@hotmail.com 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include typedef enum{false, true}bool; unsigned long hauteur=0, largeur=0; bool ***murs; // 0: horizontal, 1: vertical bool ***done; // > 0:horizontal, 1:vertical bool possible(int departx, int departy, int arriveex, int arriveey, int code) { if ((departx==arriveex) && (departy==arriveey)) return true; else { // en haut if (code!= 2) { if ((murs[departx][departy][0]==0) && (departy-1>=0)) if (possible(departx, departy-1, arriveex, arriveey, 1)) return true; } // en bas if (code!=1) { if ((murs[departx][departy+1][0]==0) && (departy+1=0)) if (possible(departx-1, departy, arriveex, arriveey, 4)) return true; } return false; } } int main(int argc, char **argv) { if (argc != 3) {printf("manque d'arguments\n"); return 1; } largeur = atol(argv[1]); hauteur = atol(argv[2]); if ((largeur < 3) || (hauteur < 3)) {printf("arguments invalides\n"); return 1; } int i,j,k; murs = (bool***)malloc((largeur+1)*sizeof(bool**)); done = (bool***)malloc((largeur+1)*sizeof(bool**)); for (i=0; i, <%2.1f,1,%2.1f>}\n",i-.1,j-.1, i+1.1,j+.1); } for (i=0; i, <%2.1f,1,%2.1f>}\n",i-.1,j+.1,i+.1,j+1.1); } fprintf(fichier, "pigment{Red}\n"); fprintf(fichier,"}}\n"); fclose(fichier); for (i=0; i