Пример #1
0
 /// 初期化処理
 void initialize()
 {
   // 動力学の世界を初期化します
   initialize_world();
   // 物体を生成し、世界に放り込みます
   initialize_bodies();
 }
Пример #2
0
static void
clear_program_state_action (Widget w, XtPointer client_data,
			    XtPointer call_data)
{
  long clear_op = (long) client_data;

  switch (clear_op)
    {
    case CLEAR_REGS:
      write_output (message_out, "Registers cleared\n\n");
      initialize_registers ();
      break;

    case CLEAR_MEM_REGS:
      write_output (message_out, "Memory and registers cleared\n\n");
      initialize_world (load_exception_handler ? exception_file_name : NULL);
      write_startup_message ();
      break;

    case CLEAR_CONSOLE:
      write_output (message_out, "Console display cleared\n\n");
      clear_console_display ();
      break;

    default:
      fatal_error("Unknown action: %d\n", clear_op);
    }

  redisplay_text ();
  redisplay_data ();
}
Пример #3
0
static void
reload_action (Widget w, XtPointer client_data, XtPointer call_data)
{
  if (program_file_name == NULL)
    return;

  write_output (message_out, "Memory and registers cleared\n\n");
  initialize_world (load_exception_handler ? exception_file_name : NULL);
  write_startup_message ();
  read_file (program_file_name);
}
// I guess sir is describing the project.
EventQueue - priority queue // ordered by time.

// I was just thinking whether can I do this project in python. shit I think.
main() {

    initialize_world();
    while(!done) {
        Event e = EventQueue.next();
        now = e.time;
        e.handle(); // Sir want to focus on this guy.
        // Reasonable in size and reasonable in ..
    }
}
Пример #5
0
Файл: gsw.c Проект: Stray/CBofN
int main(int argc, char **argv)
{
  extern int plot_mag;
  extern int plot_inverse;
  int t, i, j;

  get_options(argc, argv, options, help_string);

  plot_inverse = invert;
    plot_mag = mag;
  plot_init(width, height, 4, term);
  plot_set_all(0);

  srandom(seed);
  initialize_world();
  /* Make the sub sample size sane. */
  if(samp <= 0) samp = MIN(width, height);

  /* For each time step... */
  for(t = 0; t < steps; t++) {
    plants = herbs = carns = 0;

    /* For evey cell. */
    for(i = 0; i < height; i++)
      for(j = 0; j < width; j++) {
        world[i][j].mark = 0;
        if(t % pfreq == 0) plot_point(i, j, world[i][j].type);

        /* Count the life forms in the subsample grid. */
        if(i < samp && j < samp) {
          if(world[i][j].type == PLANT) plants++;
          else if(world[i][j].type == HERB) herbs++;
          else if(world[i][j].type == CARN) carns++;
        }
      }

    /* Do not allow extinctions, if appropriate. */
    if(noext) {
      if(herbs == 0) {
        i = random_range(0, height);
        j = random_range(0, width);
        world[i][j].type = HERB;
        world[i][j].energy = Eh;
        herbs = 1;
      }
      if(carns == 0) {
        i = random_range(0, height);
        j = random_range(0, width);
        world[i][j].type = CARN;
        world[i][j].energy = Ec;
        carns = 1;
      }
    }

    if(stats) fprintf(stderr, "%d\t%d\t%d\n", plants, herbs, carns);

    update_plants();
    update_herbs();
    update_carns();
  }

  plot_finish();
  exit(0);
}