⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memoption.c

📁 1999年卡耐基梅陇大学的2D仿真源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    {"good_shot_goalie_react_buffer", (void *)&CP_good_shot_goalie_react_buffer, V_INT},    {"better_shot_cyc_diff",        (void *)&CP_better_shot_cyc_diff,            V_INT},    //{"breakaway_shot_distance",     (void *)&CP_breakaway_shot_distance, V_FLOAT},        {"formation",                   (void *)&FP_initial_formation,  V_STRING},    {"formation_when_losing",       (void *)&FP_formation_when_losing,  V_STRING},    {"formation_when_losing_lots",  (void *)&FP_formation_when_losing_lots,  V_STRING},    {"formation_when_winning",      (void *)&FP_formation_when_winning,  V_STRING},    {"formation_when_tied",         (void *)&FP_formation_when_tied,  V_STRING},        {"home_change",                 (void *)&FP_initial_hc_method,  V_STRING},    {"mark_change",                 (void *)&FP_initial_mc_method,  V_STRING},    {"player_1_pos",                (void *)&FP_initial_player_1_pos,  V_INT},    {"player_2_pos",                (void *)&FP_initial_player_2_pos,  V_INT},    {"player_3_pos",                (void *)&FP_initial_player_3_pos,  V_INT},    {"player_4_pos",                (void *)&FP_initial_player_4_pos,  V_INT},    {"player_5_pos",                (void *)&FP_initial_player_5_pos,  V_INT},    {"player_6_pos",                (void *)&FP_initial_player_6_pos,  V_INT},    {"player_7_pos",                (void *)&FP_initial_player_7_pos,  V_INT},    {"player_8_pos",                (void *)&FP_initial_player_8_pos,  V_INT},    {"player_9_pos",                (void *)&FP_initial_player_9_pos,  V_INT},    {"player_10_pos",               (void *)&FP_initial_player_10_pos, V_INT},    {"player_11_pos",               (void *)&FP_initial_player_11_pos, V_INT},    {"goalie_number",               (void *)&FP_goalie_number        , V_INT},    {"version",        		(void *)&SP_version,          V_FLOAT},    {"team_size",        		(void *)&SP_team_size,          V_INT},    {"half",        		(void *)&SP_half,          V_INT},    {"host",             		(void *)&SP_host,               V_STRING},    {"goal_width",   		(void *)&SP_goal_width,         V_FLOAT},    {"player_size",   		(void *)&SP_player_size,	V_FLOAT},    {"player_decay",   	        (void *)&SP_player_decay,    	V_FLOAT},    {"player_rand",   		(void *)&SP_player_rand,	V_FLOAT},    {"player_weight",   	        (void *)&SP_player_weight,	V_FLOAT},    {"player_speed_max",            (void *)&SP_player_speed_max,	V_FLOAT},    {"stamina_max",   		(void *)&SP_stamina_max,	V_FLOAT},    {"stamina_inc_max",   	        (void *)&SP_stamina_inc,	V_FLOAT},    {"recover_dec_thr",   	        (void *)&SP_recover_dec_thr,	V_FLOAT},    {"recover_min",   		(void *)&SP_recover_min, 	V_FLOAT},    {"recover_dec",   		(void *)&SP_recover_dec, 	V_FLOAT},    {"effort_dec_thr",   	        (void *)&SP_effort_dec_thr,	V_FLOAT},    {"effort_min",   		(void *)&SP_effort_min, 	V_FLOAT},    {"effort_dec",   		(void *)&SP_effort_dec, 	V_FLOAT},    {"effort_inc_thr",   	        (void *)&SP_effort_inc_thr,	V_FLOAT},    {"effort_inc",   		(void *)&SP_effort_inc,	        V_FLOAT},    {"ball_size",   		(void *)&SP_ball_size,		V_FLOAT},    {"ball_decay",   		(void *)&SP_ball_decay, 	V_FLOAT},    {"ball_rand",   		(void *)&SP_ball_rand,		V_FLOAT},    {"ball_weight",   		(void *)&SP_ball_weight,	V_FLOAT},    {"ball_speed_max",   	        (void *)&SP_ball_speed_max,	V_FLOAT},    {"dash_power_rate",   	        (void *)&SP_dash_power_rate,	V_FLOAT},    {"kick_power_rate",   	        (void *)&SP_kick_power_rate,	V_FLOAT},    {"kickable_margin",   	        (void *)&SP_kickable_margin,	V_FLOAT},    {"catch_probability",   	(void *)&SP_catch_prob, 	V_FLOAT},    {"catchable_area_l",            (void *)&SP_catch_area_l,	V_FLOAT},    {"catchable_area_w",            (void *)&SP_catch_area_w,	V_FLOAT},    {"maxpower",   		        (void *)&SP_max_power,		V_FLOAT},    {"minpower",   		        (void *)&SP_min_power,		V_FLOAT},    {"maxmoment",   		(void *)&SP_max_moment,		V_FLOAT},    {"minmoment",   		(void *)&SP_min_moment,		V_FLOAT},    {"maxneckang",		(void *)&SP_max_neck_angle,		V_FLOAT},    {"minneckang",		(void *)&SP_min_neck_angle,		V_FLOAT},    {"maxneckmoment",		(void *)&SP_max_neck_moment,		V_FLOAT},    {"minneckmoment",		(void *)&SP_min_neck_moment,		V_FLOAT},    {"visible_angle",   	        (void *)&SP_visible_angle,	V_FLOAT},    {"visible_distance",            (void *)&SP_visible_dist,	V_FLOAT},    {"audio_cut_dist",   	        (void *)&SP_audio_cut_dist,	V_FLOAT},    {"quantize_step",   	        (void *)&SP_dist_qstep, 	V_FLOAT},    {"quantize_step_l",   	        (void *)&SP_land_qstep, 	V_FLOAT},    {"ckick_margin",   	        (void *)&SP_ckmargin,   	V_FLOAT},    {"wind_dir",   		        (void *)&SP_wind_dir,   	V_FLOAT},    {"wind_force",   		(void *)&SP_wind_force,  	V_FLOAT},    {"wind_rand",   		(void *)&SP_wind_rand,  	V_FLOAT},    {"wind_none",   		(void *)&SP_wind_none,  	V_ONOFF},    {"wind_random",   		(void *)&SP_wind_random,	V_ONOFF},    {"half_time",   		(void *)&SP_half_time,  	V_INT},    {"port",   			(void *)&SP_port,       	V_INT},    {"coach_port",   		(void *)&SP_coach_port,  	V_INT},    {"olcoach_port",	        (void *)&SP_olcoach_port,	V_INT},    {"simulator_step",   	        (void *)&SP_simulator_step,	V_INT},    {"send_step",   		(void *)&SP_send_step,  	V_INT},    {"recv_step",   		(void *)&SP_recv_step,  	V_INT},    {"say_msg_size",   	        (void *)&SP_say_msg_size,	V_INT},    {"hear_max",   		        (void *)&SP_hear_max,   	V_INT},    {"hear_inc",   		        (void *)&SP_hear_inc,   	V_INT},    {"hear_decay",   		(void *)&SP_hear_decay,  	V_INT},    {"catch_ban_cycle",             (void *)&SP_catch_ban_cycle,	V_INT},    {"coach",   			(void *)&SP_coach_mode,  	V_ONOFF},    {"coach_w_referee",   	        (void *)&SP_coach_w_referee_mode,V_ONOFF},    {"say_coach_cnt_max",               (void *)&SP_say_coach_cnt_max,V_INT},    {"say_coach_msg_size",          (void *)&SP_say_coach_msg_size,V_INT},    {"send_vi_step",                (void *)&SP_send_vi_step, V_INT},    {"look_step",                       (void *)&SP_look_step,V_INT},    {"use_offside",   		(void *)&SP_use_offside,	V_ONOFF},    {"forbid_kick_off_offside",     (void *)&SP_forbid_kickoff_offside, V_ONOFF},    {"log_file",		        (void *)&SP_logfile,		V_STRING},    {"record",			(void *)&SP_recfile,		V_STRING},    {"record_log",		        (void *)&SP_rec_log,		V_ONOFF},    {"record_version",	        (void *)&SP_rec_ver,		V_INT},    {"send_log",	        (void *)&SP_send_log,		V_ONOFF},    {"replay",			(void *)&SP_replay,		V_STRING},    {"verbose",                     (void *)&SP_verbose,		V_ONOFF},    {"offside_active_area_size",    (void *)&SP_offside_area,	V_FLOAT},    {"inertia_moment",      	(void *)&SP_inertia_moment,     V_FLOAT},    {"sense_body_step",      	(void *)&SP_sense_body_step,     V_INT},    {"offside_kick_margin",     (void *)&SP_offside_kick_margin,   V_FLOAT},    {"record_messages",         (void *)&SP_record_messages,     V_ONOFF},        {"\0",				NULL, 			       	0}  } ;  /* skip command name */  argv++ ; argc-- ;  /* first, search option '-file' */  int i ;  FILE *fp ;  for(i = 0 ; i < argc ; i++) {    if (!strcmp(*(argv + i),"-file")) {      if ((fp = fopen(*(argv+i+1),"r")) == NULL) {	cerr << "cat't open config file " << *(argv+i+1) << endl ;	break ;      }			      char buf[100] ;      while(fgets(buf,100,fp) != NULL) {				/* ignore remark line */	if (buf[0] == '#' || buf[0] == '\n')	  continue ;				/* replace from ':' to ' ' */	char *t = buf ;	while(*t != NULLCHAR) {	  if (*t == ':') *t = ' ' ;	  t++ ;	}	int n, p ;	char com[256] ;	char onoff[16] ;	n = sscanf(buf,"%s", com) ;	if (n < 1) {	  cerr << "Illegal line : " << buf ;	  continue ;	}	for (p = 0 ; opt[p].vptr != NULL ; p++) {	  if (strcmp(com, opt[p].optname))	    continue ;	  /* match */	  switch(opt[p].vsize) {	  case V_INT:	    n = sscanf(buf, "%s %d", com, (int *)opt[p].vptr) ;	    break ;	  case V_STRING:	    n = sscanf(buf, "%s %s", com, (char *)opt[p].vptr) ;	    break ;	  case V_FLOAT:	    n = sscanf(buf, "%s %f", com, (float *)opt[p].vptr) ;	    break ;	  case V_BOOL:	    n = 2 ;	    *((Bool *)opt[p].vptr) = TRUE ;	    break ;	  case V_ONOFF:	    n = sscanf(buf, "%s %s", com, onoff) ;	    if (n == 1) {	      n = 2;	      *((Bool *)opt[p].vptr) = TRUE;	    } else	      *((Bool *)opt[p].vptr) = (!strcmp(onoff, "on")) ? TRUE :FALSE;	    break ;	  }	  if (n < 2)	    cerr << "Illegal line (" << com << ") " << endl ;	  break ;	}					if (opt[p].vptr == NULL)	  cerr << "Illegal line (" << com << ") " << endl ;      }      fclose(fp) ;      /* break ; */   // Without this, more than one file can be read    }  }  /* next, analyze command line option */  int p ;  while (argc) {    if (!strcmp(*argv, "-file")) {      argv += 2 ;      argc -= 2 ;      continue ;    }			    for (p = 0 ; opt[p].vptr != NULL ; p++) {      if (strcmp(*argv + 1, opt[p].optname))	continue ;      /* match */      argv++ ;      argc-- ;      switch(opt[p].vsize) {      case V_INT:	*((int *)opt[p].vptr) = atoi(*argv) ;	break ;      case V_STRING:	strcpy((char *)opt[p].vptr, *argv) ;	break ;      case V_FLOAT:	*((float *)opt[p].vptr) = atof(*argv) ;	break ;      case V_BOOL:	*((Bool *)opt[p].vptr) = TRUE ;	argv-- ;	argc++ ;	break ;      case V_ONOFF:	if (argc > 0 && (*argv)[0] != '-') {	  	  *((Bool *)opt[p].vptr) = (!strcmp(*argv, "on")) ? TRUE : FALSE ;	} else {	  /* if there's nothing specified, then we set it to true */	  *((Bool *)opt[p].vptr) = TRUE;	  argv-- ;	  argc++ ;	}	break ;      }      break ;    }    if (opt[p].vptr == NULL)      cerr << "Unrecognized Option : " << *argv << endl ;    argv++ ;    argc-- ;  }  SP_half_time = SP_half_time * 1000 / SP_simulator_step ;  SP_kickable_area = SP_kickable_margin + SP_ball_size + SP_player_size ;}/* explode the line into argc and argv */void OptionInfo::GetOptions(char* line) {  const int MAXOPT = 100;  char* argv[MAXOPT];  int argc = 1; /* executable name */  char* pc;  advance_past_space(&line);  while (*line != 0) {    pc = line;    get_token(&line);    argv[argc] = new char[line-pc+1];    strncpy(argv[argc], pc, line-pc);    argv[argc][line-pc] = 0; /* null terminate */    argc++;    advance_past_space(&line);  }  argv[argc] = NULL;  GetOptions(argc, argv);  for (int i = 1; i<argc; i++)    delete [] argv[i];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -