Ejemplo n.º 1
0
int process_screen_top_left()
{
    int status;
    uint32_t width = getWidthFB() / 4;
    uint32_t height = getHeightFB() / 2;
    struct pcb_s* child_process;

    child_process = sys_fork();

    if (child_process == 0)
    {
        //On est dans le processus fils.
        game_of_life(0, 0, width - 5, height - 5, 8);

        return EXIT_SUCCESS;
    }
    else
    {
        //On est dans le processus pere.
        game_of_life(width + 5, 0, width - 5, height - 5, 8);

        status = sys_wait(child_process);
    }

    return status;
}
Ejemplo n.º 2
0
void main() {
    int pos_cel_x;
    int pos_cel_y;
    int tableau_cell[N+2][N+2];
    int tableau_voisins[N+2][N+2];
    int nb_generations;
    char nom_fichier[20];

    recup_nom_fichier(nom_fichier);

    FILE *fic_placement = fopen(nom_fichier, "r");

    initialiser_matrice(tableau_cell);

    while(!feof(fic_placement)) {
        fscanf(fic_placement, "%i", &pos_cel_x);
        fscanf(fic_placement, "%i", &pos_cel_y);

        tableau_cell[pos_cel_x][pos_cel_y] = 1;
    }

    afficher_matrice(tableau_cell, 1);

    printf("Nombre de generations : ");
    scanf("%i", &nb_generations);

    game_of_life(tableau_cell, tableau_voisins, nb_generations);

    fclose(fic_placement);
}
Ejemplo n.º 3
0
void timer_0_isr() {
    printf("timer_0_isr\r\n");
    game_of_life();

    uint32_t tmp = old_img_addr;
    old_img_addr = new_img_addr;
    new_img_addr = tmp;
    refresh = 1;
}
Ejemplo n.º 4
0
int process_screen_bottom_left()
{
    uint32_t width = getWidthFB() / 2;
    uint32_t height = getHeightFB() / 2;

    game_of_life(0, height + 5, width - 5, height - 5, 16);

    return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
int process_screen_right()
{
    uint32_t width = getWidthFB() / 2;
    uint32_t height = getHeightFB();

    game_of_life(width + 5, 0, width - 5, height, 16);

    return EXIT_SUCCESS;
}
Ejemplo n.º 6
0
int 
main (int argc, char* argv[])
{
  /*
   * Set verifyp to 1 if you want to turn on verification.
   */
  const int verifyp = DO_VERIFY;
  const int argc_min = 3;
  const int argc_max = 4;

  int gens_max = 0;
  char* inboard = NULL;
  char* outboard = NULL;
  char* checkboard = NULL;
  char* final_board = NULL;
  int nrows = 0;
  int ncols = 0;
  FILE* input = NULL;
  FILE* output = NULL;
  int err = 0;

  /* Parse command-line arguments */
  if (argc < argc_min || argc > argc_max)
    {
      fprintf (stderr, "*** Wrong number of command-line arguments; "
	       "got %d, need at least %d and no more than %d ***\n", 
	       argc - 1, argc_min - 1, argc_max - 1);
      print_usage (argv[0]);
      exit (EXIT_FAILURE);
    }
  
  err = to_int (&gens_max, argv[1]);
  if (err != 0)
    {
      fprintf (stderr, "*** <num_generations> argument \'%s\' "
	       "must be a nonnegative integer! ***\n", argv[1]);
      print_usage (argv[0]);
      exit (EXIT_FAILURE);
    }

  /* Open input and output files */ 
  input = fopen (argv[2], "r");
  if (input == NULL)
    {
      fprintf (stderr, "*** Failed to open input file \'%s\' for reading! ***\n", argv[2]);
      print_usage (argv[0]);
      exit (EXIT_FAILURE);
    }

  if (argc < argc_max || 0 == strcmp (argv[3], "-"))
    output = stdout;
  else
    {
      output = fopen (argv[3], "w");
      if (output == NULL)
	{
	  fprintf (stderr, "*** Failed to open output file \'%s\' for writing! ***\n", argv[3]);
	  print_usage (argv[0]);
	  exit (EXIT_FAILURE);
	}
    }

  /* Load the initial board state from the input file */
  inboard = load_board (input, &nrows, &ncols);
  fclose (input);

  /* Create a second board for ping-ponging */
  outboard = make_board (nrows, ncols);

  /* If we want to verify the result, then make a third board and copy
     the initial state into it */
  if (verifyp)
    {
      checkboard = make_board (nrows, ncols);
      copy_board (checkboard, inboard, nrows, ncols);
    }

  /* 
   * Evolve board gens_max ticks, and time the evolution.  You will
   * parallelize the game_of_life() function for this assignment.
   */
  copy_board (outboard, inboard, nrows, ncols);
  final_board = game_of_life (outboard, inboard, nrows, ncols, gens_max);

  /* Print (or save, depending on command-line argument <outfilename>)
     the final board */
  save_board (output, final_board, nrows, ncols);
  if (output != stdout && output != stderr)
    fclose (output);

  if (verifyp)
    {
      /* Make sure that outboard has the final state, so we can verify
	 it.  Since we ping-pong between inboard and outboard, it
	 could be either that inboard == final_board or that outboard
	 == final_board */
      copy_board (outboard, final_board, nrows, ncols);

      /* Ping-pong between checkboard (contains the initial state) and
	 inboard */
      final_board = sequential_game_of_life (inboard, checkboard, nrows, ncols, gens_max);

      if (boards_equalp (final_board, outboard, nrows, ncols))
	printf ("Verification successful\n");
      else
	{
	  fprintf (stderr, "*** Verification failed! ***\n");
	  exit (EXIT_FAILURE);
	}
    }

  /* Clean up */
  if (inboard != NULL)
    free (inboard);
  if (outboard != NULL)
    free (outboard);
  if (checkboard != NULL)
    free (checkboard);

  return 0;
}
Ejemplo n.º 7
0
Archivo: LIFE.C Proyecto: xhbang/C100
void  main(void)
{
     read_in();
     game_of_life();
}