// ----------------------------------------------------------------------
   void
   LocalizationProcessor::
   init_proc_type( void )
      throw()
   {
      if ( startup_anchor_frac_ > 0 && startup_anchor_frac_ > *random_ )
      {
         DEBUG( logger(), "set " << owner().label() << " as anchor on startup" );
         set_proc_type( anchor );
      }
	//  if( owner().is_special_node())
	//	  set_proc_type( server);

      switch ( proc_type() )
      {
         case anchor:
         {
            confidence_ = 1;
			double position_error= owner().world().simulation_controller().environment().optional_double_param("anchor_pos_err",-1);
			if(position_error>0.0){
				/*shawn::UniformRandomVariable* urv = new shawn::UniformRandomVariable();
				urv->set_upper_bound(2*position_error);
				urv->set_upper_bound_inclusive(false);
				urv->set_lower_bound_inclusive(false);
				urv->init();
				double dx = (*urv)-position_error;
				double dy = (*urv) - position_error;
				double dz =(*urv) - position_error;
				*/

				shawn::UniformRandomVariable urv;
				urv.set_upper_bound(2*position_error);
				urv.set_upper_bound_inclusive(false);
				urv.set_lower_bound_inclusive(false);
				urv.init();
				double dx = (urv)-position_error;
				double dy = (urv) - position_error;
				double dz =(urv) - position_error;

				Vec tmp=owner().real_position();
				if(tmp.z()==0)
					dz=0;
				Vec pos(tmp.x()+dx, tmp.y()+dy,tmp.z()+dz);
				owner_w().set_est_position(pos);
			}
			else
				owner_w().set_est_position( owner().real_position() );
         }

         case unknown:
         {
            confidence_ = 0.1;
         }
		 case server:
		 {
		 }
      }
   }
Beispiel #2
0
LISP_OBJ_PTR make_lambda(ENVIRONMENT_PTR env, LISP_OBJ_PTR args) {
  // this code is a bit wet, we should combine with the define function
  LISP_OBJ_PTR fun, params;
  params = car(args);
  fun = alloc_obj();
  form(fun) = PROCEDURE_FORM;
  proc_type(fun) = DERIVED;
  proc_env(fun) = env;
  proc_reqparams(fun) = params;
  proc_optparams(fun) = nil_ptr;
  proc_restparams(fun) = nil_ptr;
  proc_body(fun) = cdr(args);

  return fun;
}
Beispiel #3
0
/*
20060313, add recast parse
expr_cast -> expr_unary
	| '(' type ')' expr_cast
*/
static struct finsh_node* proc_cast_expr(struct finsh_parser* self)
{
	enum finsh_token_type token;
	enum finsh_type type;
	struct finsh_node* cast;

	next_token(token, &(self->token));
	if (token == finsh_token_type_left_paren)
	{
		type = proc_type(self);
		match_token(token, &(self->token), finsh_token_type_right_paren);

		cast = proc_cast_expr(self);
		if (cast != NULL)
		{
			cast->data_type = type;
			return cast;
		}
	}

	finsh_token_replay(&(self->token));
	return proc_unary_expr(self);
}
Beispiel #4
0
/*
process for function and variable declaration.
decl_variable -> type declaration_list ';'
declarator_list -> declarator_list ',' declarator
	| declarator
declarator -> identifier
	| identifier ASSIGN expr_assign
*/
static struct finsh_node* proc_variable_decl(struct finsh_parser* self)
{
	enum finsh_token_type token;
	enum finsh_type type;
	char id[FINSH_NAME_MAX + 1];

	struct finsh_node *node;
	struct finsh_node *end;
	struct finsh_node *assign;

    node = NULL;
	end  = NULL;

	/* get type */
	type = proc_type(self);

	/*process id.*/
	if (proc_identifier(self, id) == 0)
	{
		/* if add variable failed */
		if (finsh_var_insert(id, type) < 0)
		{
			finsh_error_set(FINSH_ERROR_VARIABLE_EXIST);
		}
	}

	next_token(token, &(self->token));
	switch ( token )
	{
	case finsh_token_type_comma:/*',', it's a variable_list declaration.*/
		if (proc_identifier(self, id) == 0)
		{
			/* if add variable failed */
			if (finsh_var_insert(id, type) < 0)
			{
				finsh_error_set(FINSH_ERROR_VARIABLE_EXIST);
			}
		}

		next_token(token, &(self->token));
		if ( token == finsh_token_type_assign )
		{
			/* get the right side of assign expression */
			assign = proc_assign_expr(self);

			if (assign != NULL)
			{
				struct finsh_node* idnode;

				idnode = finsh_node_new_id(id);
				end = make_sys_node(FINSH_NODE_SYS_ASSIGN, idnode, assign);
				node = end;

				next_token(token, &(self->token));
			}
		}

		while ( token == finsh_token_type_comma )
		{
			if (proc_identifier(self, id) == 0)
			{
				/* if add variable failed */
				if (finsh_var_insert(id, type) < 0)
				{
					finsh_error_set(FINSH_ERROR_VARIABLE_EXIST);
				}
			}

			next_token(token, &(self->token));
			if ( token == finsh_token_type_assign )
			{
				/* get the right side of assign expression */
				assign = proc_assign_expr(self);

				if (assign != NULL)
				{
					struct finsh_node* idnode;

					idnode = finsh_node_new_id(id);

					/* make assign expression node */
					if (node != NULL)
					{
						finsh_node_sibling(end) = make_sys_node(FINSH_NODE_SYS_ASSIGN, idnode, assign);
						end = finsh_node_sibling(end);
					}
					else
					{
						end = make_sys_node(FINSH_NODE_SYS_ASSIGN, idnode, assign);
						node = end;
					}

					next_token(token, &(self->token));
				}
			}
		}

		check_token(token, &(self->token), finsh_token_type_semicolon);
		return node;

	case finsh_token_type_assign:/*'=', it's a variable with assign declaration.*/
	{
		struct finsh_node *idnode;

		assign = proc_assign_expr(self);
		if (assign != NULL)
		{
			idnode = finsh_node_new_id(id);

			/* make assign expression node */
			end = make_sys_node(FINSH_NODE_SYS_ASSIGN, idnode, assign);
			node = end;

			next_token(token, &(self->token));
		}

		while ( token == finsh_token_type_comma )
		{
			if (proc_identifier(self, id) == 0)
			{
				/* if add variable failed */
				if (finsh_var_insert(id, type) < 0)
				{
					finsh_error_set(FINSH_ERROR_VARIABLE_EXIST);
				}
			}

			next_token(token, &(self->token));
			if (token == finsh_token_type_assign)
			{
				/* get the right side of assign expression */
				assign = proc_assign_expr(self);

				if (assign != NULL)
				{
					idnode = finsh_node_new_id(id);

					/* make assign expression node */
					if (node != NULL)
					{
						finsh_node_sibling(end) = make_sys_node(FINSH_NODE_SYS_ASSIGN, idnode, assign);
						end = finsh_node_sibling(end);
					}
					else
					{
						end = make_sys_node(FINSH_NODE_SYS_ASSIGN, idnode, assign);
						node = end;
					}

					next_token(token, &(self->token));
				}
			}
		}

		check_token(token, &(self->token), finsh_token_type_semicolon);
		return node;
	}

	case finsh_token_type_semicolon:/*';', it's a variable declaration.*/
		return node;

	default:
		finsh_error_set(FINSH_ERROR_EXPECT_TYPE);

		return NULL;
	}
}
Beispiel #5
0
std::ostringstream& action_state_t::debug_str( std::ostringstream& s )
{
    s << std::showbase;
    std::streamsize ss = s.precision();

    s << action -> player -> name() << " " << action -> name() << " " << target -> name() << ":";

    s << std::hex;

    s << " snapshot_flags=";
    if ( action -> snapshot_flags > 0 )
    {
        s << "{ " << flags_to_str( action -> snapshot_flags ) << " }";;
    }
    else
    {
        s << action -> snapshot_flags;
    }
    s << " update_flags=";
    if ( action -> update_flags > 0 )
    {
        s << "{ " << flags_to_str( action -> update_flags ) << " }";
    }
    else
    {
        s << action -> update_flags;
    }

    s << " result=" << util::result_type_string( result );
    s << " type=" << util::amount_type_string( result_type );

    s << " proc_type=" << util::proc_type_string( proc_type() );
    s << " exec_proc_type=" << util::proc_type2_string( execute_proc_type2() );
    s << " impact_proc_type=" << util::proc_type2_string( impact_proc_type2() );

    s << std::dec;

    s << " n_targets=" << n_targets;
    s << " chain_target=" << chain_target;
    s << " original_x=" << original_x;
    s << " original_y=" << original_y;

    s << " raw_amount=" << result_raw;
    s << " total_amount=" << result_total;
    s << " mitigated_amount=" << result_mitigated;
    s << " absorbed_amount=" << result_absorbed;
    s << " actual_amount=" << result_amount;
    s << " only_blocked_damage=" << blocked_amount;
    s << " self_absorbed_damage=" << self_absorb_amount;
    s << " ap=" << attack_power;
    s << " sp=" << spell_power;

    s.precision( 4 );

    s << " haste=" << haste;
    s << " crit=" << crit;
    s << " tgt_crit=" << target_crit;
    s << " versatility=" << versatility;
    s << " da_mul=" << da_multiplier;
    s << " ta_mul=" << ta_multiplier;
    s << " per_mul=" << persistent_multiplier;
    s << " tgt_da_mul=" << target_da_multiplier;
    s << " tgt_ta_mul=" << target_ta_multiplier;
    s << " resolve=" << resolve;

    s << " tgt_mitg_da_mul=" << target_mitigation_da_multiplier;
    s << " tgt_mitg_ta_mul=" << target_mitigation_ta_multiplier;
    s << " target_armor=" << target_armor;

    s.precision( ss );

    return s;
}
Beispiel #6
0
LISP_OBJ_PTR define(ENVIRONMENT_PTR env, LISP_OBJ_PTR args) {
  char *var;
  LISP_OBJ_PTR to_def = car(args);
  LISP_OBJ_PTR val;
  LISP_OBJ_PTR fun, params, req_params, opt_params, rest_params;
  ENVIRONMENT_PTR fun_env;

  BOOLEAN optional = FALSE, rest = FALSE;
  switch(form(to_def)) {
  case SYMBOL_FORM:
    var = symbol_value(to_def);
    val = cadr(args);
    enter_symbol(env, var, val);
    return to_def;
  case CONS_FORM:
    var = symbol_value(car(to_def));
    val = cdr(args);
    params = cdr(to_def);
    req_params = params;
    opt_params = nil_ptr;
    rest_params = nil_ptr;
    // edge case
    if (is_pair(params) && !strcmp(symbol_value(car(params)), "&optional")) {
      req_params = nil_ptr;
      optional = TRUE;
      // giving this a try
      opt_params = cdr(params);
      cdr(params) = nil_ptr;
      params = opt_params;
    }
    else if (is_pair(params) && !strcmp(symbol_value(car(params)), "&rest")) {
      req_params = nil_ptr;
      rest = TRUE;
      rest_params = cadr(params);
    }
    while (params != nil_ptr && !optional && !rest) {
      if (is_pair(cdr(params)) && !strcmp(symbol_value(cadr(params)), "&optional")) {
        optional = TRUE;
        opt_params = cddr(params);
        cdr(params) = nil_ptr;
        params = opt_params;
        break;
      } else if (is_pair(cdr(params)) && !strcmp(symbol_value(cadr(params)), "&rest")) {
        rest = TRUE;
        rest_params = caddr(params);
        cdr(params) = nil_ptr;
        params = rest_params;
        break;
      }
      params = cdr(params);
    }
    while (optional && params != nil_ptr && !rest) {
      if (is_pair(cdr(params)) && !strcmp(symbol_value(cadr(params)), "&rest")) {
        rest = TRUE;
        rest_params = caddr(params);
        cdr(params) = nil_ptr;
        params = rest_params;
        break;
      }
      params = cdr(params);
    }
    fun = alloc_obj();
    form(fun) = PROCEDURE_FORM;
    proc_type(fun) = DERIVED;
    proc_env(fun) = env;
    proc_reqparams(fun) = req_params;
    proc_optparams(fun) = opt_params;
    proc_restparams(fun) = rest_params;
    proc_body(fun) = val;
    enter_symbol(env, var, fun);
    return car(to_def);
  }
}