/*  Copyright by Juergen Dollinger 1995 */
#include <stdio.h>
#include <stdlib.h>
/* Anfangsbedingungen fuer gas2.immi erzeugen */

int main(int argc, char *argv[]) {
   int max_size = atoi(argv[1]);
   /* argument is the size of the automaton */
   int x, y;

   printf("0\n"); /* time. */
	if(argc>2)srand((unsigned int)atoi(argv[2]));
   for (x = 0; x < max_size; x++)
      for (y = 0; y < max_size; y++) {
         /* Write cell location and color. */
         printf("[%d, %d] = 0, ", x, y);

         if (y%2 == 0) 
            printf("1, ");  /* Write "which" field values. */
         else
            printf("0, ");  /* Write "which" field value. */

         /* Wall or particle? */
         if (0 == x)
            printf("1,,,,,,,");
			else if( x==1 && y==1 )
            printf("1,,,,,,,");
         else {
            /* Particle(s)! */
            int n=0, ne=0, se=0, s=0, sw=0, nw=0;

            /* Chance that a particle is placed. */
            int fill;

            /* Type of particle to place. */
            int particle = 2;
            if (x < max_size/3 || x > 2*max_size/3 || 
                y < max_size/3 || y > 2*max_size/3) particle = 1;

            fill = rand()%100;
            if (fill < 70) n = particle;
            fill = rand()%100;
            if (fill < 70) ne = particle;
            fill = rand()%100;
            if (fill < 70) se = particle;
            fill = rand()%100;
            if (fill < 70) s = particle;
            fill = rand()%100;
            if (fill < 70) sw = particle;
            fill = rand()%100;
            if (fill < 70) nw = particle;

            printf("0, %d, %d, %d, %d, %d, %d, ",
                        n, ne, se, s, sw, nw
            );
         }
         printf("%ld", rand()%2);

         printf("\n");
      }

   return 0;
}
