Example #1
0
Coordinate PetersClient::make_a_move(Board& board)
{
	std::cout << "huhuhu" << std::endl;
	if (all_empty(board))
		return Coordinate(9,9);
	std::cout <<"dddddhuhuhu" << std::endl;
	auto res = choose(board, last_move(last, board, m_color));

	std::cout <<  "-----------> " <<res.x << ", " <<res. y << std::endl;
	
	last = board;

	return res;
}
Example #2
0
void move_add(Move **move_list, const Position *cur_pos, const int speed, const int teta, const int distance, const int newSeq, pthread_cond_t *cond)
{
  Move *new_move = calloc(1, sizeof(Move));
  bzero(new_move, sizeof(Move));
  const Position *p;

  if (newSeq == 1)
    p = cur_pos;
  else
    p = &last_move(*move_list)->goal;

  new_move->speed = speed;
  new_move->goal.x = p->x - sin(teta * M_PI / 180) * distance;
  new_move->goal.y = p->y + cos(teta * M_PI / 180) * distance;
  new_move->type = POSITION;

  if (speed < 0)
    new_move->goal.t = (teta + 180)%360;
  else
    new_move->goal.t = teta;

  LOG_DEBUG("MV : %d, %d, %d\n", speed, (int) new_move->goal.x, (int) new_move->goal.y);

  if (newSeq == 1)
  {
    Move *old_list = *move_list;
    *move_list = new_move;

    pthread_cond_signal(cond);
    move_free(old_list);
  }
  else
  {
    // Append new move at the end
    while (*move_list != NULL)
    {
      move_list = &((*move_list)->next_move);
    }
    *move_list = new_move;
    pthread_cond_signal(cond);
  }
}