コード例 #1
0
ファイル: hexiom.c プロジェクト: slowfrog/hexiom
int solve(t_pos *pos) {
  if (check_valid(pos)) {
    return solve_step(pos);
  } else {
    return IMPOSSIBLE;
  }
}
コード例 #2
0
ファイル: main.cpp プロジェクト: ProkopHapala/cpp_arch
void draw(){

	rho = solve_step( 0.3, sqrt((nx*ny)/rho) );

	if(frameCount%10==0){
		printf( " %i %f \n", frameCount, rho/(nx*ny) );
		SDL_DestroyTexture(tempTex);
		setPixelsRGW_array( tempSurf, 0, 0, nx, ny,  ny, psi, 1.0 );
		tempTex   = SDL_CreateTextureFromSurface( render, tempSurf  );
	}
	SDL_RenderCopy( render, tempTex, &SrcR, &DestR );


	SDL_RenderPresent( render );
	SDL_UpdateWindowSurface(window);

}
コード例 #3
0
ファイル: hexiom.c プロジェクト: slowfrog/hexiom
int solve_step(t_pos *pos) {
  int moves[MAX_MOVES * 2];
  int count = find_moves(pos, moves);
  int i, cell_id, value, ret, cur_status;
  //print_moves(count, moves);
  for (i = 0; i < count; ++i) {
    cell_id = moves[2 * i];
    value = moves[2 * i + 1];
    ret = OPEN;
    play_move(pos, cell_id, value);
    cur_status = solved(pos);
    if (cur_status != OPEN) {
      ret = cur_status;
    } else if (solve_step(pos) == SOLVED) {
      ret = SOLVED;
    }
    undo_move(pos, cell_id, value);
    if (ret == SOLVED) {
      return ret;
    }
  }
  return IMPOSSIBLE;
}