Exemplo n.º 1
0
Arquivo: auto_ai.c Projeto: shouya/bar
static void newgame(void) {
  game_ctrl.automove_interval = 10;
  clear_blockmap(impl.bm);
  soft_reset_sb(impl.sb, shift_queue(impl.queue), impl.bm, 3);
  lines_killed = 0;
  beg_time = util_getticks();
  impl.ai = ai_calc(impl.bm, impl.sb, 0, 0);
}
Exemplo n.º 2
0
Arquivo: queue.c Projeto: artfly/shell
	pid_t get (int index, queue_t q) {
		if (index < 1 || q->last <= index) {
			printf("shell : no such job \n");
			return -1;
		}
		pid_t pid = q->jobs[index];
		shift_queue (index, q);
		return pid;
	}
static bool check_for_space(queue_t* q, uint8_t size)
{
    if (q->rear + 1 >= q->start + q->size)
	{
		// no place at the end anymore!

		if (q->front > q->start)
			shift_queue(q, q->start - q->front);
		else
			return 0;
	}

	return 1;
}
Exemplo n.º 4
0
Arquivo: auto_ai.c Projeto: shouya/bar
static void do_auto_move(void) {
  move_sb(impl.sb, 0, 1);
  if (check_sb(impl.bm, impl.sb) != 0) {
    move_sb(impl.sb, 0, -1);
    lines_killed += check_bm_lines(impl.bm, 0, 0);
    if (steady_sb(impl.bm, impl.sb, shift_queue(impl.queue), 3) != 0) {
/*    if (steady_sb(impl.bm, impl.sb, 6, 3) != 0) {*/
      /*printf("game over, you may press C-n to start a new game.\n");*/
      printf("this AI cleared lines: %d, spend: %.2fs\n", lines_killed,
             (util_getticks()-beg_time)/1000.0f);
      game_ctrl.automove_interval = -1;
      clear_blockmap(impl.bm);
      reset_shapebuf(impl.sb, -1);
      newgame();
    } else {
      impl.ai = ai_calc(impl.bm, impl.sb, 0, 0);
    }
  }
}