コード例 #1
0
ファイル: FlightTable.cpp プロジェクト: CnZoom/XcSoarPull
void
IGCFileVisitor::Visit(const TCHAR *path, const TCHAR *filename)
{
  FileLineReaderA reader(path);
  if (reader.error()) {
    _ftprintf(stderr, _T("Failed to open %s\n"), path);
    return;
  }

  IGCExtensions extensions;
  extensions.clear();

  FlightCheck flight(filename);
  char *line;
  while ((line = reader.ReadLine()) != NULL) {
    unsigned day, month, year;

    IGCFix fix;
    if (IGCParseFix(line, extensions, fix))
      flight.fix(fix);
    else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
      /* damn you, Y2K bug! */
      if (year > 80)
        year += 1900;
      else
        year += 2000;

      flight.date(year, month, day);
    }
  }

  flight.finish();
}
コード例 #2
0
void EMOPSO::execute(){
  fireOnBeforeStartNotify("starting");
  initialize();
  for(gen=0;gen<gmax;gen++){
    archive->updatematrix=true;
    archive->hierarchicalClustering();

//	printf("\nSOLUTIONS\n");
//	for (int i=0; i < nclusters; i++) {
//		 printf("%i\t",archive.nsolutionsbyswarm[i]);
//	}
//	printf("\n\n");
//
//	printf("\nProximity Matrix index\n");
//	for (int i=0; i < nclusters; i++) {
//		 for (int j=0; j < archive.nsolutionsbyswarm[i]; j++) {
//			printf("%i\t",archive.proximitymatrixindex[i][j]);
//		 }
//		 printf("\n\n");
//	}



	flight();
    fireOnGenerationDoneNotify(gen);
    //archive.printSolutions();
  }
  setSolution(this->output());
  fireOnAfterStopNotify("done");
}
コード例 #3
0
ファイル: FlightTable.cpp プロジェクト: Andy-1954/XCSoar
void
IGCFileVisitor::Visit(Path path, Path filename)
{
  Error error;
  FileLineReaderA reader(path, error);
  if (reader.error()) {
    fprintf(stderr, "%s\n", error.GetMessage());
    return;
  }

  IGCExtensions extensions;
  extensions.clear();

  FlightCheck flight(filename.c_str());
  char *line;
  while ((line = reader.ReadLine()) != NULL) {
    unsigned day, month, year;

    IGCFix fix;
    if (IGCParseFix(line, extensions, fix))
      flight.fix(fix);
    else if (sscanf(line, "HFDTE%02u%02u%02u", &day, &month, &year)) {
      /* damn you, Y2K bug! */
      if (year > 80)
        year += 1900;
      else
        year += 2000;

      flight.date(year, month, day);
    }
  }

  flight.finish();
}
コード例 #4
0
ファイル: MKFRIEND.C プロジェクト: Ced2911/umk3
//******************************************************************************
//******************************************************************************
void f_jade(void) 
{
	kill_and_stop_scrolling();
	get_char_ani(ANIM_TABLE2,ANIM_F1_FRIEND);
	animate_a0_frames(4,3);
	process_sleep(0x10);
	CREATE(PID_FX,friend_ender);

	current_proc->a10=(ADDRESS)current_proc->pa9;
	current_proc->a10-=4;			// 1 LONG
	current_proc->a11=(ADDRESS)current_proc->pa9;
	
	/* pogo_bounce */
	while (1)
	{
		(ADDRESS)current_proc->pa9=current_proc->a11;
		do_next_a9_frame(current_proc->pa8);
		flight(current_proc->pa8,SCX(0x0),-SCY(0xa0000),SCY(0x9000),NEVER_ANI,-1);
		tsound(0xc);

		(ADDRESS)current_proc->pa9=current_proc->a10;
		do_next_a9_frame(current_proc->pa8);
		process_sleep(1);											
	}
}
コード例 #5
0
ファイル: TaxiHandler.cpp プロジェクト: Artea/mangos-svn
void WorldSession::SendDoFlight( uint16 MountId, uint32 path )
{
    GetPlayer( )->Mount( MountId, true );
    FlightPathMovementGenerator *flight(new FlightPathMovementGenerator(*_player, path));
    Path &pathnodes(flight->GetPath());
    assert( pathnodes.Size() > 0 );

    uint32 traveltime = uint32(pathnodes.GetTotalLength( ) * 32);
    WorldPacket data( SMSG_MONSTER_MOVE, (8+4+4+4+4+1+4+4+4+pathnodes.Size()*4*3) );
    data.append(GetPlayer()->GetPackGUID());
    data << GetPlayer( )->GetPositionX( )
        << GetPlayer( )->GetPositionY( )
        << GetPlayer( )->GetPositionZ( );
    data << GetPlayer( )->GetOrientation( );
    data << uint8( 0 );
    data << uint32( 0x00000300 );
    data << uint32( traveltime );
    data << uint32( pathnodes.Size( ) );
    data.append( (char*)pathnodes.GetNodes( ), pathnodes.Size( ) * 4 * 3 );

    //WPAssert( data.size() == 37 + pathnodes.Size( ) * 4 * 3 );
    GetPlayer()->SendMessageToSet(&data, true);
}
コード例 #6
0
ファイル: SubOrbitalFlight.cpp プロジェクト: Loran425/krpc
int main() {
  krpc::Client conn = krpc::connect("Sub-orbital flight");
  krpc::services::KRPC krpc(&conn);
  krpc::services::SpaceCenter space_center(&conn);

  auto vessel = space_center.active_vessel();

  vessel.auto_pilot().target_pitch_and_heading(90, 90);
  vessel.auto_pilot().engage();
  vessel.control().set_throttle(1);
  std::this_thread::sleep_for(std::chrono::seconds(1));

  std::cout << "Launch!" << std::endl;
  vessel.control().activate_next_stage();

  typedef krpc::services::KRPC::Expression Expr;

  {
    auto solid_fuel = vessel.resources().amount_call("SolidFuel");
    auto expr = Expr::less_than(
      conn, Expr::call(conn, solid_fuel), Expr::constant_float(conn, 0.1));
    auto event = krpc.add_event(expr);
    event.acquire();
    event.wait();
    event.release();
  }

  std::cout << "Booster separation" << std::endl;
  vessel.control().activate_next_stage();

  {
    auto mean_altitude = vessel.flight().mean_altitude_call();
    auto expr = Expr::greater_than(
      conn, Expr::call(conn, mean_altitude), Expr::constant_double(conn, 10000));
    auto event = krpc.add_event(expr);
    event.acquire();
    event.wait();
    event.release();
  }

  std::cout << "Gravity turn" << std::endl;
  vessel.auto_pilot().target_pitch_and_heading(60, 90);

  {
    auto apoapsis_altitude = vessel.orbit().apoapsis_altitude_call();
    auto expr = Expr::greater_than(
      conn, Expr::call(conn, apoapsis_altitude), Expr::constant_double(conn, 100000));
    auto event = krpc.add_event(expr);
    event.acquire();
    event.wait();
    event.release();
  }

  std::cout << "Launch stage separation" << std::endl;
  vessel.control().set_throttle(0);
  std::this_thread::sleep_for(std::chrono::seconds(1));
  vessel.control().activate_next_stage();
  vessel.auto_pilot().disengage();

  {
    auto srf_altitude = vessel.flight().surface_altitude_call();
    auto expr = Expr::less_than(
      conn, Expr::call(conn, srf_altitude), Expr::constant_double(conn, 1000));
    auto event = krpc.add_event(expr);
    event.acquire();
    event.wait();
    event.release();
  }

  vessel.control().activate_next_stage();

  while (vessel.flight(vessel.orbit().body().reference_frame()).vertical_speed() < -0.1) {
    std::cout << "Altitude = " << vessel.flight().surface_altitude() << " meters" << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(1));
  }
  std::cout << "Landed!" << std::endl;
}
コード例 #7
0
ファイル: t-PSOGlobalBest.cpp プロジェクト: hunanhd/vns
int main (int __argc, char *__argv[])
{
  peo :: init( __argc, __argv );
  if (getNodeRank()==1)
    std::cout<<"\n\nTest : PSO Global Best\n\n";
  rng.reseed (10);
  RingTopology topologyMig;
  eoGenContinue < Indi > genContPara (10);
  eoCombinedContinue <Indi> continuatorPara (genContPara);
  eoCheckPoint<Indi> checkpoint(continuatorPara);
  peoEvalFunc<Indi, double, const Indi& > plainEval(f);
  peoPopEval< Indi > eval(plainEval);
  eoUniformGenerator < double >uGen (0, 1.);
  eoInitFixedLength < Indi > random (2, uGen);
  eoUniformGenerator < double >sGen (-1., 1.);
  eoVelocityInitFixedLength < Indi > veloRandom (2, sGen);
  eoFirstIsBestInit < Indi > localInit;
  eoRealVectorBounds bndsFlight(2,0,1.);
  eoStandardFlight < Indi > flight(bndsFlight);
  eoPop < Indi > pop;
  pop.append (10, random);
  eoLinearTopology<Indi> topology(2);
  eoRealVectorBounds bnds(2,-1.,1.);
  eoStandardVelocity < Indi > velocity (topology,1,0.5,2.,bnds);
  eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop);
  eoPeriodicContinue< Indi > mig_cont( 2 );
  peoPSOSelect<Indi> mig_selec(topology);
  peoGlobalBestVelocity<Indi> mig_replac (2.,velocity);
  eoContinuator<Indi> cont(mig_cont, pop);
  eoSelector <Indi, eoPop<Indi> > mig_select (mig_selec,1,pop);
  eoReplace <Indi, eoPop<Indi> > mig_replace (mig_replac,pop);
  eoGenContinue < Indi > genContPara2 (10);
  eoCombinedContinue <Indi> continuatorPara2 (genContPara2);
  eoCheckPoint<Indi> checkpoint2(continuatorPara2);
  peoEvalFunc<Indi, double, const Indi& > plainEval2(f);
  peoPopEval< Indi > eval2(plainEval2);
  eoUniformGenerator < double >uGen2 (0, 1.);
  eoInitFixedLength < Indi > random2 (2, uGen2);
  eoUniformGenerator < double >sGen2 (-1., 1.);
  eoVelocityInitFixedLength < Indi > veloRandom2 (2, sGen2);
  eoFirstIsBestInit < Indi > localInit2;
  eoRealVectorBounds bndsFlight2(2,0,1.);
  eoStandardFlight < Indi > flight2(bndsFlight2);
  eoPop < Indi > pop2;
  pop2.append (10, random2);
  eoLinearTopology<Indi> topology2(2);
  eoRealVectorBounds bnds2(2,-1.,1.);
  eoStandardVelocity < Indi > velocity2 (topology2,1,0.5,2.,bnds2);
  eoInitializer <Indi> init2(eval2,veloRandom2,localInit2,topology2,pop2);
  eoPeriodicContinue< Indi > mig_cont2( 2 );
  peoPSOSelect<Indi> mig_selec2(topology2);
  peoGlobalBestVelocity<Indi> mig_replac2 (2.,velocity2);
  eoContinuator<Indi> cont2(mig_cont2,pop2);
  eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_selec2,1,pop2);
  eoReplace <Indi, eoPop<Indi> > mig_replace2 (mig_replac2,pop2);
  peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
  checkpoint.add( mig );
  peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
  checkpoint2.add( mig2 );
  eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight);
  peoWrapper parallelPSO( psa, pop);
  eval.setOwner(parallelPSO);
  mig.setOwner(parallelPSO);
  eoSyncEasyPSO <Indi> psa2(init2,checkpoint2,eval2, velocity2, flight2);
  peoWrapper parallelPSO2( psa2, pop2);
  eval2.setOwner(parallelPSO2);
  mig2.setOwner(parallelPSO2);
  peo :: run();
  peo :: finalize();
  if (getNodeRank()==1)
    {
      pop.sort();
      pop2.sort();
      std::cout << "Final population :\n" << pop << std::endl;
      std::cout << "Final population :\n" << pop2	 << std::endl;
    }
}
コード例 #8
0
ファイル: BKF.C プロジェクト: rsabishek/Airline-Manager
void main(){
int gdriver = EGA, gmode = EGAHI, errorcode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
bk(); travel(); gravitas();
tvar=0;
m1c=m2c=adc=chdc=0;
signup_traction();

while(ch!=27)
{
if(kbhit())
{
ch=getch();
if(ch==77) {way(1);}
if(ch==75) {way(0);}
if(ch==80) {menu1();setcolor(6);settextstyle(2,0,4);
outtextxy(68,180,"<-");break;}
}}
flag1:
city();
m1c=0;
while(ch!=27)
{
gravitas();
if(kbhit())
{
ch=getch();

if(ch==80 && m1c<=15)                         //i city
{menu1();city();++m1c;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==72 && m1c>=1 && m1c<=15)
{menu1();city();m1c--;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==80 && m1c>=16 && m1c<=33)                 //2 city
{menu1();city2();m1c++;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==72 && m1c>=16 && m1c<=33)
{menu1();city2();m1c--;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==80 && m1c>=34 && m1c<=51)                 //3 city
{menu1();city3();m1c++;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==72 && m1c>=34 && m1c<=51)
{menu1();city3();m1c--;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==80 && m1c>=52 && m1c<56)                //4 city
{menu1();city4();m1c++;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==72 && m1c>=52 && m1c<=56)
{menu1();city4();m1c--;ibar();tarrow(m1c);mcounter(m1c);}

if(ch==13)
{from=m1c; bk(); travel(); mcounter(m1c);from=m1c;if(tvar)tmcounter(m2c);break;}

if(ch==77) { bk();travel();menu2();tcity();mcounter(m1c);from=m1c;menu2();break;}
}}

//flag2:
m2c=0;
while(ch!=27)
{
gravitas();
if(kbhit())
{
ch=getch();

if(ch==80 && m2c<=15)                         //i city
{menu2();tcity();++m2c;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==72 && m2c>=1 && m2c<=15)
{menu2();tcity();m2c--;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==80 && m2c>=16 && m2c<=33)                 //2 city
{menu2();tcity2();m2c++;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==72 && m2c>=16 && m2c<=33)
{menu2();tcity2();m2c--;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==80 && m2c>=34 && m2c<=51)                 //3 city
{menu2();tcity3();m2c++;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==72 && m2c>=34 && m2c<=51)
{menu2();tcity3();m2c--;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==80 && m2c>=52 && m2c<56)                //4 city
{menu2();tcity4();m2c++;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==72 && m2c>=52 && m2c<=56)
{menu2();tcity4();m2c--;tbar();arrow(m2c);tmcounter(m2c);}

if(ch==13)
{to=m2c; bk(); travel(); tvar=1;tmcounter(m2c);to=m2c;mcounter(m1c);break;}

if(ch==75)
{bk();travel(); to =m2c; tvar=1; tmcounter(m2c);to=m2c;menu1(); //goto flag1;
break;}

}
}

while(ch!=27)
{
gravitas();
if(kbhit())
{
ch=getch();
if(ch==80 && adc<10)
{admenu();adult();  adc++; adarrow(adc); adcounter(adc);}
if(ch==72 && adc>0)
{admenu();adult(); adc--; adarrow(adc);adcounter(adc);}
if(ch==77)
{adno=adc;chmenu();bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);break;}
if(ch==13)
{adno=adc;bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);break;}
}}

while(ch!=27)
{
gravitas();
if(kbhit())
{
ch=getch();
if(ch==80 && chdc<10)
{chmenu();child(); chdc++; charrow(chdc); chcounter(chdc);}
if(ch==72 && chdc>0)
{chmenu();child(); chdc--; charrow(chdc);chcounter(chdc);}
if(ch==77)
{chno=chdc;chmenu();bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc); break;}
if(ch==13)
{chno=chdc;bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc); break;}
}}

while(ch!=27)
{ gravitas();
if(kbhit())
{
ch=getch();
if(ch==80 && inc<10)
{inmenu();infant(); inc++; inarrow(inc); incounter(inc);}
if(ch==72 && inc>0)
{inmenu();infant(); inc--; inarrow(inc);incounter(inc);}
if(ch==77)
{inno=inc;inmenu();bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc);incounter(inc); break;}
if(ch==13)
{inno=chdc;bk(); travel();tmcounter(m2c);mcounter(m1c);adcounter(adc);chcounter(chdc);incounter(inc); break;}
}}

while(ch!=27)
{
gravitas();
if(kbhit())
{
ch=getch();
if(ch==77) {ecob(1);suit=1;}
if(ch==75) {ecob(0);suit=0;}
if(ch==13) {break;}
}
}

setcolor(1);settextstyle(2,0,4);
ch=0;
while(ch!=13)
{
if(kbhit())
{da+=8;
ch=getch();
if(isalnum(ch) && da<=95)
{sprintf(dater,"%c",ch);
outtextxy(da,272,dater);}

if(ch==8 && da>=45 && da<=180)
{da=da-8;
setfillstyle(1,15);  bar(da,272,da+8,285);
da=da-8;}
}}

if(suit==0)flight(to);
if(suit==1)bflight(to);
traction();
secure();
money_transfer();

getch();
closegraph();}