• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ POS函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中POS函数的典型用法代码示例。如果您正苦于以下问题:C++ POS函数的具体用法?C++ POS怎么用?C++ POS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了POS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: POS

bool chain::evaluating_chain(int black_live_eye_arr[], int white_live_eye_arr[])
{
	this->live = 0;
	list<stone*> try_position;
	int forbid = 0;
	int forbiden[5] = {-1,-1,-1,-1,-1};
	int S[BOARD_SIZE*BOARD_SIZE];
	for (int i = 0; i < BOARD_SIZE*BOARD_SIZE; i++) S[i] = 0;
	for (std::list<stone*>::iterator itor = this->stones.begin(); itor != this->stones.end(); ++itor)
	{
		for (int i = 0; i < 4; i++)
		{
			int row = (*itor)->row + deltai[i];
			int col = (*itor)->col + deltaj[i];
			int index = POS(row,col);
			stone* curr = chain_block->block_board->main_board[index];
			if (chain_block->block_board->on_board(row, col))
			{
				if (curr->color == EMPTY)
					{
						if (S[index] != 0) continue;
						S[index] = 1;
						curr->color = OTHER_COLOR(chain_block->color);
						if (curr->eat_this_chain(this))
						{
							try_position.push_back(curr);
							std::list<stone*>::iterator itor2 = try_position.begin();
							while (itor2 != try_position.end())
							{
								
								if (chain_block->color == BLACK){
									black_live_eye_arr[POS((*itor2)->row, (*itor2)->col)] = 1;	//try_position不是白棋的真眼
								}
								else{
									white_live_eye_arr[POS((*itor2)->row, (*itor2)->col)] = 1;	//try_position不是黑棋的真眼
								}
								(*itor2)->color = EMPTY;
								try_position.erase(itor2++);
							}
							this->live = 0;
							return 1;
						}
						else if (curr->can_live(this))
						{
							try_position.push_back(curr);
						}
						else //Neither to eat this chain nor to live
						{
							curr->color = EMPTY;
							S[index] = 2;
						}
				}
			}
		}
	}
	int count = 0;
	for (int i = 0; i < BOARD_SIZE*BOARD_SIZE; i++){
		if (S[i] == 2) count++;
	}
	if (count < 2)
	{
		//S[i]周围不能是live eye
		for (int i = 0; i < BOARD_SIZE*BOARD_SIZE; i++){
			if (S[i] == 2) {
				if (chain_block->color == BLACK){
					black_live_eye_arr[i] = 1;	//try_position不是白棋的真眼
				}
				else{
					white_live_eye_arr[i] = 1;	//try_position不是黑棋的真眼
				}
				queue<int> q;
				q.push(i);
				not_live_eye_bfs(this, OTHER_COLOR(this->chain_block->color), q, black_live_eye_arr, white_live_eye_arr);
			}
		}
		std::list<stone*>::iterator itor2 = try_position.begin();
		while (itor2 != try_position.end())
		{

			if (chain_block->color == BLACK){
				black_live_eye_arr[POS((*itor2)->row, (*itor2)->col)] = 1;	//try_position不是白棋的真眼
			}
			else{
				white_live_eye_arr[POS((*itor2)->row, (*itor2)->col)] = 1;	//try_position不是黑棋的真眼
			}
			(*itor2)->color = EMPTY;
			try_position.erase(itor2++);
		}
		this->live = 0;
	}
	else 
	{
		for (int i = 0; i < BOARD_SIZE*BOARD_SIZE; i++){
			if (S[i] == 2) {
				if (chain_block->color == BLACK){
					if (black_live_eye_arr[i] != 1) black_live_eye_arr[i] = 2;	//可能是白棋的真眼
				}
				else{
					if (white_live_eye_arr[i] != 1) white_live_eye_arr[i] = 2;	//可能是黑棋的真眼
				}
//.........这里部分代码省略.........
开发者ID:yixinx,项目名称:Go-Game,代码行数:101,代码来源:new_evaluation.cpp


示例2: play_move

/* Play at (i, j) for color. No legality check is done here. We need
 * to properly update the board array, the next_stone array, and the
 * ko point.
 */
static void
play_move(int i, int j, int color)
{
  int pos = POS(i, j);
  int captured_stones = 0;
  int k;

  /* Reset the ko point. */
  ko_i = -1;
  ko_j = -1;

  /* Nothing more happens if the move was a pass. */
  if (pass_move(i, j))
    return;

  /* If the move is a suicide we only need to remove the adjacent
   * friendly stones.
   */
  if (suicide(i, j, color)) {
    for (k = 0; k < 4; k++) {
      int ai = i + deltai[k];
      int aj = j + deltaj[k];
      if (on_board(ai, aj)
	  && get_board(ai, aj) == color)
	remove_string(ai, aj);
    }
    return;
  }

  /* Not suicide. Remove captured opponent strings. */
  for (k = 0; k < 4; k++) {
    int ai = i + deltai[k];
    int aj = j + deltaj[k];
    if (on_board(ai, aj)
	&& get_board(ai, aj) == OTHER_COLOR(color)
	&& !has_additional_liberty(ai, aj, i, j))
      captured_stones += remove_string(ai, aj);
  }

  /* Put down the new stone. Initially build a single stone string by
   * setting next_stone[pos] pointing to itself.
   */
  board[pos] = color;
  next_stone[pos] = pos;

  /* If we have friendly neighbor strings we need to link the strings
   * together.
   */
  for (k = 0; k < 4; k++) {
    int ai = i + deltai[k];
    int aj = j + deltaj[k];
    int pos2 = POS(ai, aj);
    /* Make sure that the stones are not already linked together. This
     * may happen if the same string neighbors the new stone in more
     * than one direction.
     */
    if (on_board(ai, aj) && board[pos2] == color && !same_string(pos, pos2)) {
      /* The strings are linked together simply by swapping the the
       * next_stone pointers.
       */
      int tmp = next_stone[pos2];
      next_stone[pos2] = next_stone[pos];
      next_stone[pos] = tmp;
    }
  }

  /* If we have captured exactly one stone and the new string is a
   * single stone it may have been a ko capture.
   */
  if (captured_stones == 1 && next_stone[pos] == pos) {
    int ai, aj;
    /* Check whether the new string has exactly one liberty. If so it
     * would be an illegal ko capture to play there immediately. We
     * know that there must be a liberty immediately adjacent to the
     * new stone since we captured one stone.
     */
    for (k = 0; k < 4; k++) {
      ai = i + deltai[k];
      aj = j + deltaj[k];
      if (on_board(ai, aj) && get_board(ai, aj) == EMPTY)
	break;
    }
    
    if (!has_additional_liberty(i, j, ai, aj)) {
      ko_i = ai;
      ko_j = aj;
    }
  }
}
开发者ID:5tivi,项目名称:julia,代码行数:93,代码来源:go_benchmark.c


示例3: pegue_palitos

int pegue_palitos(struct jogad jogador[] , int num, int rodadas, int total_palitos )
{

    int i;
    int palitos;
    
    do { // pegar a quantidade de palitos do jogador humano
	
	// posicao inicial das mensagens
	i=18;
	JANELA2();
	
	POS (i++,5);
	printf ("Você possui [%d] palitos, há [%2d] palitos em jogo", jogador[0].tpalitos, total_palitos);
	
	POS (i++,5);
	printf ("Jogador, digite quantos palitos quer jogar, para sair [-1]: "); 
	
	// muda palitos antes do condicional,
	// isto previne sair do programa quando palitos == -1
	scanf("%d", &palitos);

	// caso se escolha -1, isto eh sair do jogo
	if ( palitos == -1) { 
	    tela_saida(); 	//mostra tela de saída
	    exit(0); 		//saí do jogo
	}	
	
	if ( (palitos < 0) || ( palitos > jogador[0].tpalitos) ) {
	    STATUS();
	    printf("Quantidade inválida de palitos");
	
	}
	;;

	if ((rodadas == 1) && (palitos == 0)) {
	    STATUS();
	    printf("Na primeira rodada a quantidade de palitos deve ser maior que 0");
	    palitos= -1; // para não sair no laço pois continue não funcionou
	}
	;;
	
    } while ( (palitos < 0) || ( palitos > jogador[0].tpalitos) );
    ;;
    
    jogador[0].palitos = palitos;    
    
    for (i = 1; i < num + 1; i++) {
	
	// gera um numero de palitos a jogar por numeros aleatorios 
	// inteligencia=0.
	jogador[i].palitos = aleatorio(jogador[i].tpalitos);
	
	
	if ((rodadas == 1) && (jogador[i].palitos == 0)) 
	    i--; // decrementa i para permanecer no mesmo jogador
	;;

    }
    ;;
    
    palitos = 0;
        
    for (i = 0; i <= num ; i++) 
	palitos += jogador[i].palitos; //total de palitos
    ;;    

    return(palitos);
    
}
开发者ID:iuridiniz,项目名称:ufrn-porrinha-fight,代码行数:70,代码来源:palitos.c


示例4: POS

//-----------------------------------------------------------------------------------------------
void CRenderCamera::GetPos ( tVect3& vOutPos )const
{
    vOutPos = POS(m_TM);
}
开发者ID:Pawel91,项目名称:Thot,代码行数:5,代码来源:RenderCamera.cpp


示例5: compute_surroundings


//.........这里部分代码省略.........
              && sd[i] < sd[dpos]
              && square_dist(i, dpos) < sd[dpos]) {
            for (j = i + 1; j < BOARDMAX; j++)
	      if (ON_BOARD(j) && mn[j] && j != dpos
                  && sd[j] < sd[dpos]
                  && square_dist(j, dpos) < sd[dpos]
                  && square_dist(i, j) < sd[dpos]) {
	        mn[dpos] = 0;
                found_some = 1;
                break;
              }
            if (mn[dpos] == 0)
              break;
          }
      }
  } while (found_some);

  /* prepare corner array */

  for (dpos = BOARDMIN; dpos < BOARDMAX; dpos++)
    if (ON_BOARD(dpos) && mn[dpos])
      corner[corners++] = dpos;

  /* compute gravity center of the goal */

  for (dpos = BOARDMIN; dpos < BOARDMAX; dpos++)
    if (ON_BOARD(dpos) && mf[dpos]) {
      gi += I(dpos);
      gj += J(dpos);
      stones++;
    }
  gi /= stones;
  gj /= stones;
  gg = POS(gi, gj);

  /* sort the corner array */

  gg_sort(corner, corners, sizeof(int), compare_angles);

  /* if apos is not NO_MOVE, mark it. */

  if (apos != NO_MOVE) {
    ASSERT_ON_BOARD1(apos);
    mn[apos] = 1;
  }
  
  if (showboard == 1) {
    show_surround_map(mf, mn);
  }

  /* find top row of surrounding polyhedron */
  
  top_row = -1;
  for (m = 0; m < board_size; m++) {
    if (top_row != -1)
      break;
    for (n = 0; n < board_size; n++)
      if (mn[POS(m, n)]) {
	left_corner[0] = POS(m, n);
	top_row = m;
	break;
      }
  }

  /* find bottom row */
  
开发者ID:epichub,项目名称:neatzsche,代码行数:66,代码来源:surround.c


示例6: FUNC


//.........这里部分代码省略.........

    pixel  *left          = left_array + 1;
    pixel  *top           = top_array  + 1;
    pixel  *filtered_left = filtered_left_array + 1;
    pixel  *filtered_top  = filtered_top_array  + 1;
    int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb - 1, y_tb + size_in_tbs_v);
    int cand_left        = lc->na.cand_left;
    int cand_up_left     = lc->na.cand_up_left;
    int cand_up          = lc->na.cand_up;
    int cand_up_right    = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb + size_in_tbs_h, y_tb - 1);

    int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->sps->height) -
                           (y0 + size_in_luma_v)) >> vshift;
    int top_right_size   = (FFMIN(x0 + 2 * size_in_luma_h, s->sps->width) -
                           (x0 + size_in_luma_h)) >> hshift;

    if (s->pps->constrained_intra_pred_flag == 1) {
        int size_in_luma_pu_v = PU(size_in_luma_v);
        int size_in_luma_pu_h = PU(size_in_luma_h);
        int on_pu_edge_x    = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1));
        int on_pu_edge_y    = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1));
        if (!size_in_luma_pu_h)
            size_in_luma_pu_h++;
        if (cand_bottom_left == 1 && on_pu_edge_x) {
            int x_left_pu   = PU(x0 - 1);
            int y_bottom_pu = PU(y0 + size_in_luma_v);
            int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_bottom_pu);
            cand_bottom_left = 0;
            for (i = 0; i < max; i += 2)
                cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
        }
        if (cand_left == 1 && on_pu_edge_x) {
            int x_left_pu   = PU(x0 - 1);
            int y_left_pu   = PU(y0);
            int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_left_pu);
            cand_left = 0;
            for (i = 0; i < max; i += 2)
                cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
        }
        if (cand_up_left == 1) {
            int x_left_pu   = PU(x0 - 1);
            int y_top_pu    = PU(y0 - 1);
            cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA;
        }
        if (cand_up == 1 && on_pu_edge_y) {
            int x_top_pu    = PU(x0);
            int y_top_pu    = PU(y0 - 1);
            int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_top_pu);
            cand_up = 0;
            for (i = 0; i < max; i += 2)
                cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
        }
        if (cand_up_right == 1 && on_pu_edge_y) {
            int y_top_pu    = PU(y0 - 1);
            int x_right_pu  = PU(x0 + size_in_luma_h);
            int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_right_pu);
            cand_up_right = 0;
            for (i = 0; i < max; i += 2)
                cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
        }
        memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel));
        memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel));
        top[-1] = 128;
    }
    if (cand_up_left) {
        left[-1] = POS(-1, -1);
        top[-1]  = left[-1];
    }
    if (cand_up)
        memcpy(top, src - stride, size * sizeof(pixel));
    if (cand_up_right) {
        memcpy(top + size, src - stride + size, size * sizeof(pixel));
        EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),
               size - top_right_size);
    }
    if (cand_left)
        for (i = 0; i < size; i++)
            left[i] = POS(-1, i);
    if (cand_bottom_left) {
        for (i = size; i < size + bottom_left_size; i++)
            left[i] = POS(-1, i);
        EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),
               size - bottom_left_size);
    }

    if (s->pps->constrained_intra_pred_flag == 1) {
        if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
            int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ?
                                    2 * size : (s->sps->width - x0) >> hshift;
            int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ?
                                    2 * size : (s->sps->height - y0) >> vshift;
            int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
            if (!cand_up_right) {
                size_max_x = x0 + ((size) << hshift) < s->sps->width ?
                                                    size : (s->sps->width - x0) >> hshift;
            }
            if (!cand_bottom_left) {
                size_max_y = y0 + (( size) << vshift) < s->sps->height ?
                                                     size : (s->sps->height - y0) >> vshift;
            }
开发者ID:alexliyu,项目名称:MeetSDK,代码行数:101,代码来源:hevcpred_template.c


示例7: if

/**
 * Create the adjacency list for each position on the board. An example of the 
 * board for size of 15 is shown below. The edges are created for a position in
 * a clockwise manner.
 *     *---*---*---*---*
 *     |0  |1  |2  |3  |
 *     *---*---*---*---*
 *     |4  |5  |6  |7  |
 *     *---*---*---*---*
 *     |8  |9  |10 |11 |
 *     *---*---*---*---*
 *     |12 |13 |14 |15 |
 *     *---*---*---*---*
 * @param row
 * @param col
 */
void GemPuzzleState::MakeEdges(int row, int col,vector<int>& list) {
    if (row == 0) {
        if (col == 0) {
            list.push_back(POS((row), (col + 1), _dim));
            list.push_back(POS((row + 1), (col), _dim));
        } else if (col == _dim - 1) {
            list.push_back(POS((row + 1), (col), _dim));
            list.push_back(POS((row), (col - 1), _dim));
        } else {
            list.push_back(POS(row, (col + 1), _dim));
            list.push_back(POS((row + 1), col, _dim));
            list.push_back(POS(row, (col - 1), _dim));
        }
    } else if (row == _dim - 1) {
        if (col == 0) {
            list.push_back(POS((row-1), (col), _dim));
            list.push_back(POS((row), (col+1), _dim));
        } else if (col == _dim - 1) {
            list.push_back(POS((row), (col-1), _dim));
            list.push_back(POS((row-1), (col), _dim));
        } else {
            list.push_back(POS((row), (col-1), _dim));
            list.push_back(POS((row-1), (col), _dim));
            list.push_back(POS((row), (col+1), _dim));
        }
    } else {
        if (col == 0) {
            list.push_back(POS((row-1), (col), _dim));
            list.push_back(POS((row), (col+1), _dim));
            list.push_back(POS((row+1), (col), _dim));
        } else if (col == _dim - 1) {
            list.push_back(POS((row+1), (col), _dim));
            list.push_back(POS((row), (col-1), _dim));
            list.push_back(POS((row-1), (col), _dim));
        } else {
            list.push_back(POS((row-1), (col), _dim));
            list.push_back(POS((row), (col+1), _dim));
            list.push_back(POS((row+1), (col), _dim));
            list.push_back(POS((row), (col-1), _dim));
        }
    }
}
开发者ID:mirsoleimani,项目名称:paralleluct,代码行数:58,代码来源:GemPuzzleState.cpp


示例8: set_hchar

static inline void set_hchar(struct part *p, int x, int y, unsigned c)
{
	xpand_lines(p, y);
	xpand_line(p, y, x);
	POS(x, y) = c;
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:6,代码来源:html_r.c


示例9: aftermath_genmove


//.........这里部分代码省略.........
	    }
	    else if (d > 0 && board[pos] == color) {
	      distance[pos] = d + 1;
	      if (closest_own == NO_MOVE)
		closest_own = pos;
	    }
	    else if (board[pos] == EMPTY) {
	      distance[pos] = d + 1;
	      something_found = 1;
	    }
	    break;
	  }
	}
      }
    }
    d++;
  } while (something_found);

  if (under_control) {
    for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
      if (!ON_BOARD(pos))
	continue;
      else if (distance[pos] == -1)
	under_control[pos] = 0;
      else
	under_control[pos] = 1;
    }
  }
  
  if (debug & DEBUG_AFTERMATH) {
    int m, n;
    for (m = 0; m < board_size; m++) {
      for (n = 0; n < board_size; n++) {
	pos = POS(m, n);
	if (distance[pos] > 0)
	  fprintf(stderr, "%2d", distance[pos]);
	else if (distance[pos] == 0) {
	  if (board[pos] == WHITE)
	    gprintf(" o");
	  else if (board[pos] == BLACK)
	    gprintf(" x");
	  else
	    gprintf(" ?");
	}
	else {
	  if (board[pos] == WHITE)
	    gprintf(" O");
	  else if (board[pos] == BLACK)
	    gprintf(" X");
	  else
	    gprintf(" .");
	}
      }
      gprintf("\n");
    }
  
    gprintf("Closest opponent %1m", closest_opponent);
    if (closest_opponent != NO_MOVE)
      gprintf(", distance %d\n", distance[closest_opponent]);
    else
      gprintf("\n");

    gprintf("Closest own %1m", closest_own);
    if (closest_own != NO_MOVE)
      gprintf(", distance %d\n", distance[closest_own]);
    else
开发者ID:epichub,项目名称:neatzsche,代码行数:67,代码来源:aftermath.c


示例10: weibo_user_create_json

pweibo_user weibo_user_create_json(json_t* pJson)
{
    if (!pJson) {
        PERR("could not parse json!\n");
        return NULL; 
    }

    void *iter = json_object_iter(pJson);
    pweibo_user pUser = weibo_user_init();

    while (iter) {
        const char* key = json_object_iter_key(iter);
        //DEBUG("%s\n", key);
        json_t *value = json_object_iter_value(iter);
        if(!value) {
            iter = json_object_iter_next(pJson, iter);
            continue;
        }
        //DEBUG("%d\n", value->type);

        if (0 == strcmp("id", key)) {
            pUser->m_szID = g_string_new("");
            g_string_printf(pUser->m_szID, "%"JSON_INTEGER_FORMAT, json_integer_value(value));
        } else if (0 == strcmp("screen_name", key)) {
            pUser->m_szScreenName = g_string_new(json_string_value(value));
        } else if (0 == strcmp("name", key)) {
            pUser->m_szName = g_string_new(json_string_value(value));
        } else if (0 == strcmp("province", key)) {
            pUser->m_nProvince = json_integer_value(value);
        } else if (0 == strcmp("city", key)) {
            pUser->m_nCity = json_integer_value(value);
        } else if (0 == strcmp("location", key)) {
            pUser->m_szLocation = g_string_new(json_string_value(value));
        } else if (0 == strcmp("description", key)) {
            pUser->m_szDescription = g_string_new(json_string_value(value));
        } else if (0 == strcmp("url", key)) {
            pUser->m_szUrl = g_string_new(json_string_value(value));
        } else if (0 == strcmp("profile_image_url", key)) {
            pUser->m_szProfileImageUrl = g_string_new(json_string_value(value));
        } else if (0 == strcmp("domain", key)) {
            pUser->m_szDomain = g_string_new(json_string_value(value));
        } else if (0 == strcmp("gender", key)) {
            pUser->m_szGender = g_string_new(json_string_value(value));
        } else if (0 == strcmp("followers_count", key)) {
            pUser->m_nFollowersCount = json_integer_value(value);
        } else if (0 == strcmp("friends_count", key)) {
            pUser->m_nFriendsCount = json_integer_value(value);
        } else if (0 == strcmp("statuses_count", key)) {
            pUser->m_nStatusesCount = json_integer_value(value);
        } else if (0 == strcmp("favourites_count", key)) {
            pUser->m_nFavouritesCount = json_integer_value(value);
        } else if (0 == strcmp("created_at", key)) {
            pUser->m_szCreatedAt = g_string_new(json_string_value(value));
        } else if (0 == strcmp("following", key)) {
            pUser->m_bFollowing = json_is_true(value) ? TRUE : FALSE;
        } else if (0 == strcmp("allow_all_act_msg", key)) {
            pUser->m_bAllowAllActMsg = json_is_true(value) ? TRUE : FALSE;
        } else if (0 == strcmp("geo_enabled", key)) {
            pUser->m_bGeoEnabled = json_is_true(value) ? TRUE : FALSE;
        } else if (0 == strcmp("verified", key)) {
            pUser->m_bVerified = json_is_true(value) ? TRUE : FALSE;
        } else if (0 == strcmp("status", key)) {
            PERR("%s-->%d\n", key, value->type);
            POS();
            pUser->m_pFeed = weibo_feed_create_json(value);
            PERR("%d\n", pUser->m_pFeed);
            PERR("%s\n", ((pweibo_feed)(pUser->m_pFeed))->m_szID->str);
        }

        iter = json_object_iter_next(pJson, iter);
    }
    json_decref(pJson);

    return pUser;
}
开发者ID:ThinkmanWang,项目名称:think-project,代码行数:75,代码来源:weibo_user.c


示例11: showchar

static void 
showchar(int i, int j, int empty, int xo)
{
  struct dragon_data *d;  /* dragon data at (i, j) */
  struct dragon_data2 *d2;
  int x;
  ASSERT_ON_BOARD2(i, j);
  x = BOARD(i, j);
  d = &(dragon[POS(i, j)]);
  d2 = &(dragon2[d->id]);

  if (x == EMPTY) {
    if (xo != 2)
      fprintf(stderr, " %c", empty);
    else {
      int empty_color;
      char empty_char;
      
      if (black_eye[POS(i, j)].color == BLACK) {
	if (white_eye[POS(i, j)].color == WHITE)
	  empty_color = domain_colors[3];
	else
	  empty_color = domain_colors[1];

	if (black_eye[POS(i, j)].marginal)
	  empty_char = '!';
	else
	  empty_char = 'x';
      }
      else if (white_eye[POS(i, j)].color == WHITE) {
	empty_color = domain_colors[2];
	if (white_eye[POS(i, j)].marginal)
	  empty_char = '!';
	else
	  empty_char = 'o';
      }
      else {
	empty_color = domain_colors[0];
	empty_char = '.';
      }

      write_color_char(empty_color, empty_char);
    }
  }
  else {
    int w;

    if (xo == 0 || ! ON_BOARD1(d->origin)) {
      fprintf(stderr, " %c", BOARD(i, j) == BLACK ? 'X' : 'O');
      return;
    }

    /* Figure out ascii character for this dragon. This is the
     * dragon number allocated to the origin of this worm. */

    w = dragon_num[d->origin];
    if (!w) {
      /* Not yet allocated - allocate next one. */
      /* Count upwards for black, downwards for white to reduce confusion. */
      if (BOARD(i, j) == BLACK)
	w = dragon_num[d->origin] = next_black++;
      else
	w = dragon_num[d->origin] = next_white--; 
    }

    w = w%26 + (BOARD(i, j) == BLACK ? 'A' : 'a');
    
    /* Now draw it. */
    if (xo == 1)
      write_color_char(colors[BOARD(i, j)][d->crude_status], w);
    else if (xo == 2) {
      if (BOARD(i, j) == BLACK)
	write_color_char(domain_colors[1], 'X');
      else
	write_color_char(domain_colors[2], 'O');
    }
    else if (xo == 3)
      write_color_char(colors[BOARD(i, j)][d2->owl_status], w);
    else if (xo == 4)
      write_color_char(colors[BOARD(i, j)][d->status], w);
  }
}
开发者ID:Daimas,项目名称:elygo-bots,代码行数:82,代码来源:showbord.c


示例12: play_solo

void
play_solo(Gameinfo *gameinfo, int moves)
{
  SGFTree sgftree;
  int passes = 0; /* num. consecutive passes */
  float move_value;
  double t1, t2;
  int save_moves = moves;

  struct stats_data totalstats;
  int total_owl_count = 0;

  /* It tends not to be very imaginative in the opening,
   * so we scatter a few stones randomly to start with.
   * We add two random numbers to reduce the probability
   * of playing stones near the edge.
   */
  
  int n = 6 + 2*gg_rand()%5;
  int i, j;

  komi = 5.5;

  sgftree_clear(&sgftree);
  sgftreeCreateHeaderNode(&sgftree, board_size, komi, handicap);
  sgf_write_header(sgftree.root, 1, get_random_seed(), 5.5, handicap,
                   get_level(), chinese_rules);
 
  /* Generate some random moves. */
  if (board_size > 6) {
    do {
      do {
	i = (gg_rand() % 4) + (gg_rand() % (board_size - 4));
	j = (gg_rand() % 4) + (gg_rand() % (board_size - 4));
      } while (!is_allowed_move(POS(i, j), gameinfo->to_move));

      gnugo_play_move(POS(i, j), gameinfo->to_move);
      sgftreeAddPlay(&sgftree, gameinfo->to_move, i, j);
      sgftreeAddComment(&sgftree, "random move");
      gameinfo->to_move = OTHER_COLOR(gameinfo->to_move);
    } while (--n > 0);
  }
  
  t1 = gg_cputime();
  memset(&totalstats, '\0', sizeof(totalstats));
  while (passes < 2 && --moves >= 0) {
    int move;
    reset_owl_node_counter();
    move = genmove(gameinfo->to_move, &move_value, NULL);

    gnugo_play_move(move, gameinfo->to_move);
    sgffile_add_debuginfo(sgftree.lastnode, move_value);
    sgftreeAddPlay(&sgftree, gameinfo->to_move, I(move), J(move));
    sgffile_output(&sgftree);
    gameinfo->to_move = OTHER_COLOR(gameinfo->to_move);

    if (move == PASS_MOVE) {
      passes++;
      printf("%s(%d): Pass\n", gameinfo->to_move == BLACK ? "Black" : "White",
	     movenum);
    }
    else {
      passes = 0;
      gprintf("%s(%d): %1m\n", gameinfo->to_move == BLACK ? "Black" : "White",
	      movenum, move);
    }

    totalstats.nodes                    += stats.nodes;
    totalstats.read_result_entered      += stats.read_result_entered;
    totalstats.read_result_hits         += stats.read_result_hits;
    totalstats.trusted_read_result_hits += stats.trusted_read_result_hits;
    total_owl_count                     += get_owl_node_counter();
  }
  t2 = gg_cputime();
  
  /* Two passes and it's over. (EMPTY == BOTH) */
  who_wins(EMPTY, stdout);

  {
    float score = gnugo_estimate_score(NULL, NULL);
    sgfWriteResult(sgftree.root, score, 1);
  }
  sgffile_output(&sgftree);

  printf("%10d moves played in %0.3f seconds\n", save_moves-moves, t2-t1);
  if (save_moves != moves)
    printf("%10.3f seconds/move\n", (t2-t1)/(save_moves-moves));
  
  printf("%10d nodes\n", totalstats.nodes);
  printf("%10d read results entered\n", totalstats.read_result_entered);
  printf("%10d read result hits\n", totalstats.read_result_hits);
  printf("%10d trusted read result hits\n",
	 totalstats.trusted_read_result_hits);
  printf("%10d owl nodes\n", total_owl_count);
}
开发者ID:Daimas,项目名称:elygo-bots,代码行数:95,代码来源:play_solo.c


示例13: if

bool stone::empty_redistribution()
{
	int except = -1;
	int target;
	if (s_influence > 0){ target = BLACK; }
	else if (s_influence < 0){ target = WHITE; }
	else {
		if (stone_block == NULL) return 1;
		else
		{
			stone_block->empty.remove(this);
			stone_block = NULL;
			return 1;
		}
	}
	//BFS
	int visited[BOARD_SIZE*BOARD_SIZE];
	memset(visited, 0, sizeof(visited));
	queue <int> q;
	q.push(POS(row, col));
	visited[POS(row, col)] = 1;
	while (!q.empty())
	{
		int top;
		int mark = 0;
		top = q.front();
		q.pop();
		for (int k = 0; k < 4; k++)
		{
			if (stone_board->on_board(I(top) + deltai[k], J(top) + deltaj[k]))
			{
				int index = POS(I(top) + deltai[k], J(top) + deltaj[k]);
				if (stone_board->main_board[index]->color == EMPTY)
				{
					if (visited[index] == 0)	{
						visited[index] = 1;
						q.push(index);
					}
				}
				else if (stone_board->main_board[index]->color == OTHER_COLOR(target) && color == EMPTY && mark == 0)
				{
					except = index;
					mark = 1;
					continue;
				}
				else if (stone_board->main_board[index]->color == OTHER_COLOR(target) && color == EMPTY && mark == 1)
				{
					continue;
				}
				else if (stone_board->main_board[index]->color == target && color == EMPTY)
				{
					//IF: check if it is already in
					for (std::list<stone*>::iterator itor2 = stone_board->main_board[index]->stone_block->empty.begin(); itor2 != stone_board->main_board[index]->stone_block->empty.end(); ++itor2)
					{
						if (POS((*itor2)->row, (*itor2)->col) == POS(row, col)){
							return 1;
						}
					}
					//ELSE: delete the orignial term, add to the new list
					if (this->stone_block != NULL)
					{
						for (std::list<stone*>::iterator itor = this->stone_block->empty.begin(); itor != this->stone_block->empty.end(); itor++)
						{
							if (POS((*itor)->row, (*itor)->col) == POS(row, col))
							{
								this->stone_block->empty.erase(itor);
								break;
							}
						}
					}
					stone_board->main_board[index]->stone_block->empty.push_back(this);
					//mark the stone block
					this->stone_block = stone_board->main_board[index]->stone_block;
					return 1;
				}
			}
		}
	}

	if (except == -1)
	{
		return 0;
	}	//Impossible

	//except: the influence is negative, but it's surrounded by blacks
	//It's already in the "except" black block
	for (std::list<stone*>::iterator itor = stone_board->main_board[except]->stone_block->empty.begin(); itor != stone_board->main_board[except]->stone_block->empty.end(); ++itor)
	{
		if (POS((*itor)->row, (*itor)->col) == POS(row, col)){ return 1; }
	}
	//ELSE: delete the orignial term, add to the new list
	this->stone_block->empty.remove(this);

	stone_board->main_board[except]->stone_block->empty.push_back(this);
	//mark the stone block
	this->stone_block = stone_board->main_board[except]->stone_block;
	return 1;
}
开发者ID:yixinx,项目名称:Go-Game,代码行数:98,代码来源:new_evaluation.cpp


示例14: draw_planet

void draw_planet(HDC hDC, planetstruct *planet)
{
	HBRUSH hbrColor, hbrOld;
	gravstruct *gp = &gravs;
	double D;						// a DX variable to work with
	unsigned char cmpt;

	D = POS(X) * POS(X) + POS(Y) * POS(Y) + POS(Z) * POS(Z);
	if (D < COLLIDE)
		D = COLLIDE;
	D = sqrt(D);
	D = D * D * D;
	for (cmpt = X; cmpt < DIMENSIONS; cmpt++) {
		ACC(cmpt) = POS(cmpt) * GRAV / D;
		if (iDamping) {
			if (ACC(cmpt) > MaxA)
				ACC(cmpt) = MaxA;
			else if (ACC(cmpt) < -MaxA)
				ACC(cmpt) = -MaxA;
			VEL(cmpt) = VEL(cmpt) + ACC(cmpt);
			VEL(cmpt) *= DAMP;
		} else {
			// update velocity
			VEL(cmpt) = VEL(cmpt) + ACC(cmpt);
		}
		// update position
		POS(cmpt) = POS(cmpt) + VEL(cmpt);
	}

	gp->x = planet->xi;
	gp->y = planet->yi;

	if (POS(Z) > -ALMOST) {
		planet->xi = (unsigned int)
			((double) gp->width * (HALF + POS(X) / (POS(Z) + DIST)));
		planet->yi = (unsigned int)
			((double) gp->height * (HALF + POS(Y) / (POS(Z) + DIST)));
	}
	else
		planet->xi = planet->yi = -1;	

	// Mask
	hbrOld = (HBRUSH)SelectObject(hDC, (HBRUSH)GetStockObject(BLACK_BRUSH));
	Planet(gp->x, gp->y);

	if (iTrails)
		SetPixel(hDC, gp->x, gp->y, PALETTEINDEX(100));

	// Move
	gp->x = planet->xi;
	gp->y = planet->yi;
	planet->ri = RADIUS;

	if (iColorCycle) {
		if (planet->colors++ > (PALSIZE-21))
			planet->colors = 1;
	}

	// Redraw
	hbrColor = CreateSolidBrush(PALETTEINDEX(planet->colors));
	SelectObject(hDC, hbrColor);
	Planet(gp->x, gp->y);

	SelectObject(hDC, hbrOld);
	DeleteObject(hbrColor);
}
开发者ID:bodhidogma,项目名称:xlock_savers,代码行数:66,代码来源:Gravity.cpp


示例15: set_hchars

static inline void set_hchars(struct part *p, int x, int y, int xl, unsigned c)
{
	xpand_lines(p, y);
	xpand_line(p, y, x+xl-1);
	for (; xl; xl--, x++) POS(x, y) = c;
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:6,代码来源:html_r.c


示例16: while

void XGraphicsOpenGL::DrawPieClip( const XE::VEC2 *pvLines, int numLine, float x, float y, float radius, float angStart, float angEnd, XCOLOR color, int maxSlice )
{
	if( angStart == angEnd )
		return;
	XE::VEC2 *pvList = _vLists;
	float angSlice = 360.0f / (float)maxSlice;		// 
	float ang = 0;
	
	pvList->x = x;	pvList->y = y;	// 파이의 중심점
	pvList++;
	XE::VEC2 vOut;
	XE::VEC2 vo;
	vo.x = x + (sinf(D2R(angStart)) * radius);		// 시작각도 버텍스 하나 만들어줌
	vo.y = y + (-cosf(D2R(angStart)) * radius);
	if( ClippingLine( &vOut, pvLines, numLine, x, y, vo.x, vo.y ) )
		*pvList = vOut;
	else
		*pvList = vo;
	pvList++;
	ang += angSlice;
	const XE::VEC2 *pEnd = &_vLists[ MAX_VERTEX ];
	int num = 0;
	while( ang < angEnd )
	{
		if( ang >= angStart )		// 각도범위에 포함되면 버텍스를 추가
		{
			float rAng = D2R(ang);		// 디그리 각도를 라디안각도로 변환
			vo.x = x + (sinf(rAng) * radius);
			vo.y = y + (-cosf(rAng) * radius);
			if( ClippingLine( &vOut, pvLines, numLine, x, y, vo.x, vo.y ) )
				*pvList = vOut;
			else
				*pvList = vo;
			pvList++;
			num++;		// 삼각형 개수
			if( XBREAK(pvList > pEnd) )		// 버퍼 오버플로우 되지 않도록
				break;
		}
		ang += angSlice;
	}
	// 마지막각도에 버텍스 하나 더 추가
	vo.x = x + (sinf(D2R(angEnd)) * radius);
	vo.y = y + (-cosf(D2R(angEnd)) * radius);
	if( ClippingLine( &vOut, pvLines, numLine, x, y, vo.x, vo.y ) )
		*pvList = vOut;
	else
		*pvList = vo;
	num++;
	
	// gl버텍스버퍼에 옮김
	{
	GLfloat r, g, b, a;
	r = XCOLOR_RGB_R(color) / 255.0f;
	g = XCOLOR_RGB_G(color) / 255.0f;
	b = XCOLOR_RGB_B(color) / 255.0f;
	a = XCOLOR_RGB_A(color) / 255.0f;
	
		GLfloat pos[MAX_VERTEX * 2]={0,};
		GLfloat col[MAX_VERTEX * 4]={0,};
	
//	float ratioX = ((float)GetPhyScreenWidth() / GetScreenWidth()) ;
//	float ratioY = ((float)GetPhyScreenHeight() / GetScreenHeight());
	for( int i = 0; i < num+2; i ++ )	// num은 삼각형개수고 +2를 해야 버텍스 개수다
	{
		POS(i, _vLists[i].x, _vLists[i].y);
		COLOR(i,r,g,b,a);
//		m_aVertex[i].vPos.x = _vLists[i].x * ratioX;
//		m_aVertex[i].vPos.y = _vLists[i].y * ratioY;
//		m_aVertex[i].dwColor = color;
	}
	
	// gl draw
	glPushMatrix();
	glLoadIdentity();
	
	glDisable( GL_TEXTURE_2D );
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);	// 이건 안해줘도 되네.
	glVertexPointer(2, GL_FLOAT, 0, pos);
	glEnableClientState(GL_VERTEX_ARRAY);
	glColorPointer(4, GL_FLOAT, 0, col);
	glEnableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	
	glDrawArrays(GL_TRIANGLE_FAN, 0, num+2);	// num+2: 버텍스개수
	
	glDisableClientState(GL_COLOR_ARRAY);
	glEnable( GL_TEXTURE_2D );
	glPopMatrix();
	}
}
开发者ID:xahgo,项目名称:tama,代码行数:91,代码来源:XGraphicsOpenGL.cpp


示例17: Vector3f

//-----------------------------------------------------------------------------
// 説明: ルート位置ベクトルの取得
// 引数: 
//       frm [in] フレーム番号
// 返り値:
//       ルート位置ベクトル
// その他: 
//-----------------------------------------------------------------------------
Vector3f CMotionData::GetPosition(size_t frm) const
{
	if (!IsRange(frm))
		return Vector3f() = Vector3f::Identity();
	return POS(frm);
}
开发者ID:redheru,项目名称:CodeChunk,代码行数:14,代码来源:MotionData.cpp


示例18: main

int main(int argc, char *argv[])
{
	int i, n;
	
	bool wasRunning = FALSE;
	bool save_cfg = FALSE;
	bool change_settings_ui(menu_e *menu, u1_t key, bool *skip_first, cfg_t *cfg);
	bool show_ip = FALSE;
	bool config_valid, config_key = FALSE;
	bool config_ip = FALSE, config_nm = FALSE, config_gw = FALSE, config_am = FALSE;
	u4_t key;
	menu_e menu;
	int addr_mode;
	int ip[4], nm[4], gw[4], bc[4];
	
	FILE *cfp, *efp;
	char *config_file = ROOT_DIR "/.5370.config";

	cfg_t *cfg = &cfg_buf;
	
	dsp_7seg_init(FALSE);	// panic routine can't use display until bus is setup

	// silently ignores unrecognized arguments
	for (i=1; i<argc; i++) {
		if (strcmp(argv[i], "-bg") == 0) background_mode = TRUE;
		if (strcmp(argv[i], "-ip") == 0) show_ip = TRUE;
		if (strcmp(argv[i], "-no") == 0) menu_action = FALSE;

		if (strcmp(argv[i], "?")==0 || strcmp(argv[i], "-?")==0 || strcmp(argv[i], "--?")==0 || strcmp(argv[i], "-h")==0 ||
			strcmp(argv[i], "h")==0 || strcmp(argv[i], "-help")==0 || strcmp(argv[i], "--h")==0 || strcmp(argv[i], "--help")==0) {
			printf( "-rcl|-recall [name]    load key settings from named profile\n"
					"-hpib-hard    use the original HPIB hardware interface, assuming installed\n"
					"-hpib-sim     simulate the HPIB interface in software (debug mode)\n"
					"-hpib-net     simulate and re-direct transfers over an Ethernet connection\n"
					"-ip           show IP address of Ethernet interface and exit\n"
			);
			xit(0);
		}
	}
	
	lprintf("HP%s v%d.%d\n", INST_STR, FIRMWARE_VER_MAJ, FIRMWARE_VER_MIN);
    lprintf("compiled: %s %s\n", __DATE__, __TIME__);

	sim_args(TRUE, argc, argv);
	hpib_args(TRUE, argc, argv);

	sim_init();
	web_server_init();
	
	if (!menu_action) printf("menu action disabled\n");

reset:
	// To support the action of the 'reset' key most code files have a reset routine that zeros static variables.
	// This is similar to the C runtime idea of zeroing the bss when a program is first run.
	
	if (wasRunning) {
		wasRunning = FALSE;
		net_reset(NET_HPIB);
		net_reset(NET_TELNET);
		web_server_stop();
		skip_first = save_cfg = config_key = config_ip = config_nm = config_gw = config_am = FALSE;
	}

	sim_reset();

	if (!(bus_read(RREG_LDACSR) & DSR_VOK)) {
		lprintf("waiting for 5370 power\n");
		usleep(1000000);
		while (!(bus_read(RREG_LDACSR) & DSR_VOK)) {
			sched_yield();
			usleep(250000);
		}
		lprintf("5370 power on\n");
		usleep(1000000);
	} else {
		lprintf("5370 is powered on\n");
	}
	
	// display firmware version
	dsp_7seg_init(TRUE);
	dsp_7seg_str(DSP_LEFT, INST_STR, DSP_CLEAR);
	dsp_7seg_chr(POS(10), 'v');
	dsp_7seg_num(POS(11), POS_IS_LSD, FIRMWARE_VER_MAJ, DEFAULT_WIDTH, SPACE_FILL);
	dsp_7seg_num(POS(12), POS_IS_MSD, FIRMWARE_VER_MIN, FIELD_WIDTH(0), ZERO_FILL);
	dsp_7seg_dp(POS(12));
	dsp_leds_clr_all();
	delay(2000);

	if ((cfp = fopen(config_file, "r")) == NULL) {
		if (errno != ENOENT) sys_panic(config_file);
		config_valid = FALSE;
	} else {
		while (fgets(lbuf, LBUF, cfp)) {
			if ((sscanf(lbuf, "key 0x%x", &key) == 1) && (key == 0xcafe5370)) config_key = TRUE; else
			if (sscanf(lbuf, "am %d", &addr_mode) == 1) config_am = TRUE; else
			if (sscanf(lbuf, "ip %d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]) == 4) config_ip = TRUE; else
			if (sscanf(lbuf, "nm %d.%d.%d.%d", &nm[0], &nm[1], &nm[2], &nm[3]) == 4) config_nm = TRUE; else
			if (sscanf(lbuf, "gw %d.%d.%d.%d", &gw[0], &gw[1], &gw[2], &gw[3]) == 4) config_gw = TRUE; else
				;
		}
//.........这里部分代码省略.........
开发者ID:jks-prv,项目名称:5370_proc,代码行数:101,代码

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ POSIX_LABEL函数代码示例发布时间:2022-05-30
下一篇:
C++ PORT_ZNew函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap