示例#1
0
Granary::Granary()
{
   setType(B_GRANARY);
   setMaxWorkers(5);
   setWorkers(0);

   _size = 3;
   setPicture(PicLoader::instance().get_picture( ResourceGroup::commerce, 140));
   _fgPictures.resize(6);  // 1 upper level + 4 windows + animation
   int maxQty = 2400;
   _goodStore.setMaxQty(maxQty);
   _goodStore.setMaxQty(G_WHEAT, maxQty);
   _goodStore.setMaxQty(G_MEAT, maxQty);
   _goodStore.setMaxQty(G_FISH, maxQty);
   _goodStore.setMaxQty(G_FRUIT, maxQty);
   _goodStore.setMaxQty(G_VEGETABLE, maxQty);

   _goodStore.setCurrentQty(G_WHEAT, 300);

   _animation.load(ResourceGroup::commerce, 146, 7);
   // do the animation in reverse
   _animation.load(ResourceGroup::commerce, 151, 6);
   PicLoader& ldr = PicLoader::instance();

   _fgPictures[0] = &ldr.get_picture( ResourceGroup::commerce, 141);
   _fgPictures[5] = _animation.getCurrentPicture();
   computePictures();
}
示例#2
0
Well::Well() : ServiceBuilding( Service::well, constants::building::B_WELL, Size(1) )
{
  _fireIncrement = 0;
  _damageIncrement = 0;

  setWorkers( 0 );
}
示例#3
0
MissionPost::MissionPost()
{
 setType(B_MISSION_POST);
  _size = 2;
  setMaxWorkers(20);
  setWorkers(0);  
  setPicture(PicLoader::instance().get_picture("transport", 93));
}
示例#4
0
GovernorsHouse::GovernorsHouse()
{
  setType(B_GOVERNOR_HOUSE);
  _size = 3;
  setMaxWorkers(5);
  setWorkers(0);    
  setPicture(PicLoader::instance().get_picture(rcHousingGroup, 46));
}
示例#5
0
GovernorsVilla::GovernorsVilla()
{
  setType(B_GOVERNOR_VILLA);
  _size = 4;
  setMaxWorkers(10);
  setWorkers(0);    
  setPicture(PicLoader::instance().get_picture(rcHousingGroup, 47));
}
示例#6
0
GovernorsPalace::GovernorsPalace()
{
  setType(B_GOVERNOR_PALACE);
  _size = 5;
  setMaxWorkers(15);
  setWorkers(0);  
  setPicture(PicLoader::instance().get_picture(rcHousingGroup, 48));
}
示例#7
0
Academy::Academy()
{
  setType(B_MILITARY_ACADEMY);
  _size = 3;
  setMaxWorkers( 20 );
  setWorkers( 0 );
  setPicture(PicLoader::instance().get_picture( ResourceGroup::security, 18));
}
示例#8
0
Barracks::Barracks()
{
  setType(B_BARRACKS);
  _size = 3;
  setMaxWorkers(5);
  setWorkers(0);  
  setPicture(PicLoader::instance().get_picture(ResourceGroup::security, 17));
}
TimberLogger::TimberLogger() : Factory(G_NONE, G_TIMBER, B_TIMBER_YARD, Size(2) )
{
  _setProductRate( 9.6f );
  setPicture( Picture::load(ResourceGroup::commerce, 72) );

  _getAnimation().load( ResourceGroup::commerce, 73, 10);
  _fgPictures.resize(2);
  setWorkers( 0 );
}
示例#10
0
ServiceBuilding::ServiceBuilding(const ServiceType &service)
{
   _service = service;
   setMaxWorkers(5);
   setWorkers(0);
   _serviceTimer = 0;
   _serviceDelay = 80;
   _serviceRange = 30;
}
BuildingEngineer::BuildingEngineer() : ServiceBuilding( Service::S_ENGINEER, B_ENGINEER_POST, Size(1) )
{
  setWorkers( 0 );
  setPicture( Picture::load( ResourceGroup::buildingEngineer, 56 ) );

  _getAnimation().load( ResourceGroup::buildingEngineer, 57, 10 );
  _getAnimation().setFrameDelay( 4 );
  _getAnimation().setOffset( Point( 10, 42 ) );
  _fgPictures.resize(1);
}
示例#12
0
ServiceBuilding::ServiceBuilding(const ServiceType service,
                                 const BuildingType type, const Size& size)
                                 : WorkingBuilding( type, size ), _d( new Impl )
{
   _service = service;
   setMaxWorkers(5);
   setWorkers(0);
   setServiceDelay( 80 );
   _serviceTimer = 0;
   _serviceRange = 30;
}
示例#13
0
IronMine::IronMine() : Factory(G_NONE, G_IRON, B_IRON_MINE, Size(2) )
{
  _setProductRate( 9.6f );
  setWorkers( 0 );

  setPicture( Picture::load(ResourceGroup::commerce, 54) );

  _getAnimation().load( ResourceGroup::commerce, 55, 6 );
  _getAnimation().setFrameDelay( 5 );
  _fgPictures.resize(2);
}
示例#14
0
FactoryClay::FactoryClay() : Factory(G_NONE, G_CLAY, B_CLAY_PIT, Size(2) )
{
  _setProductRate( 9.6f );
  _picture = &Picture::load( ResourceGroup::commerce, 61 );

  _animation.load( ResourceGroup::commerce, 62, 10);
  _animation.setFrameDelay( 3 );
  _fgPictures.resize(2);

  setMaxWorkers( 10 );
  setWorkers( 0 );
}
示例#15
0
Factory::Factory( const GoodType inType, const GoodType outType,
                  const BuildingType type, const Size& size )
: WorkingBuilding( type, size ), _d( new Impl )
{
   setMaxWorkers(10);
   setWorkers(8);

   _d->productionRate = 4.8f;
   _d->progress = 0.0f;
   _inGoodType = inType;
   _outGoodType = outType;
   _goodStore.setMaxQty(1000);  // quite unlimited
   _goodStore.setMaxQty(_inGoodType, 200);
   _goodStore.setMaxQty(_outGoodType, 200);
}
示例#16
0
Market::Market() : ServiceBuilding(S_MARKET, B_MARKET, Size(2) ),
  _d( new Impl )
{
  setMaxWorkers(5);
  setWorkers(5);

  setPicture( Picture::load( ResourceGroup::commerce, 1) );
  _fgPictures.resize(1);  // animation

  _d->goodStore.setMaxQty(5000);
  _d->goodStore.setMaxQty(G_WHEAT, 400);
  _d->goodStore.setMaxQty(G_POTTERY, 300);
  _d->goodStore.setCurrentQty(G_WHEAT, 200);

  _animation.load( ResourceGroup::commerce, 2, 10 );
  _animation.setFrameDelay( 4 );
}
示例#17
0
Market::Market() : ServiceBuilding(S_MARKET)
{
   setType(B_MARKET);
   setMaxWorkers(5);
   setWorkers(0);

   _marketBuyer = NULL;
   _buyerDelay = 10;
   _size = 2;
   // _name = _("Marche");
   setPicture(PicLoader::instance().get_picture("commerce", 1));
   _fgPictures.resize(1);  // animation

   _goodStore.setMaxQty(5000);
   _goodStore.setMaxQty(G_WHEAT, 400);
   _goodStore.setMaxQty(G_POTTERY, 300);
   _goodStore.setCurrentQty(G_WHEAT, 200);

   AnimLoader animLoader(PicLoader::instance());
   animLoader.fill_animation(_animation, "commerce", 2, 10);
}
示例#18
0
Senate::Senate() : ServiceBuilding( Service::S_SENATE, B_SENATE, Size(5) ), _d( new Impl )
{
  setWorkers( 0 );
  setPicture( Picture::load( ResourceGroup::govt, 4) );
  _d->taxInLastMonth = 0;
}
MissionPost::MissionPost() : WorkingBuilding(B_MISSION_POST, Size(2) )
{
  setMaxWorkers(20);
  setWorkers(0);  
  setPicture( Picture::load( ResourceGroup::transport, 93));
}
示例#20
0
MissionPost::MissionPost() : WorkingBuilding(B_MISSION_POST, Size(2) )
{
  setMaxWorkers(20);
  setWorkers(0);  
  setPicture(PicLoader::instance().get_picture("transport", 93));
}
示例#21
0
GovernorsHouse::GovernorsHouse() : WorkingBuilding( B_GOVERNOR_HOUSE, Size(3) )
{
  setMaxWorkers(5);
  setWorkers(0);    
  setPicture(Picture::load( ResourceGroup::housing, 46));
}
示例#22
0
GovernorsVilla::GovernorsVilla() : WorkingBuilding(B_GOVERNOR_VILLA, Size(4) )
{
  setMaxWorkers(10);
  setWorkers(0);    
  setPicture(Picture::load( ResourceGroup::housing, 47));
}
示例#23
0
GovernorsPalace::GovernorsPalace() : WorkingBuilding(B_GOVERNOR_PALACE, Size( 5 ) )
{
  setMaxWorkers(15);
  setWorkers(0);  
  setPicture(Picture::load(ResourceGroup::housing, 48));
}
示例#24
0
void Compute(graph<vertex>& GA, commandLine P) {
  t1.start();
  long start = P.getOptionLongValue("-r",0);
  if(GA.V[start].getOutDegree() == 0) { 
    cout << "starting vertex has degree 0" << endl;
    return;
  }
  const int procs = P.getOptionIntValue("-p",0);
  if(procs > 0) setWorkers(procs);
  const double t = P.getOptionDoubleValue("-t",3);
  const double epsilon = P.getOptionDoubleValue("-e",0.000000001);
  const uintE N = P.getOptionIntValue("-N",1);
  const intE n = GA.n;
  const double constant = exp(t)*epsilon/(2*(double)N);
  double* psis = newA(double,N);
  double* fact = newA(double,N);
  fact[0] = 1;
  for(long k=1;k<N;k++) fact[k] = k*fact[k-1];
  double* tm = newA(double,N);
  {parallel_for(long m=0;m<N;m++) tm[m]  = pow(t,m);}
  {parallel_for(long k=0;k<N;k++) {
    psis[k] = 0;
    for(long m=0;m<N-k;m++)
      psis[k] += fact[k]*tm[m]/(double)fact[m+k];
    }}

  sparseAdditiveSet<float> x = sparseAdditiveSet<float>(10000,1,0.0);
  sparseAdditiveSet<float> r = sparseAdditiveSet<float>(2,1,0.0);
  x.insert(make_pair(start,0.0));
  r.insert(make_pair(start,1.0));
  vertexSubset Frontier(n,start);

  long j = 0, totalPushes = 0;
  while(Frontier.numNonzeros() > 0){
    totalPushes += Frontier.numNonzeros();
    uintT* Degrees = newA(uintT,Frontier.numNonzeros());
    {parallel_for(long i=0;i<Frontier.numNonzeros();i++) Degrees[i] = GA.V[Frontier.s[i]].getOutDegree();}
    long totalDegree = sequence::plusReduce(Degrees,Frontier.numNonzeros());
    free(Degrees);
    if(j+1 < N) {
      long rCount = r.count();
      //make bigger hash table initialized to 0.0's
      sparseAdditiveSet<float> new_r = sparseAdditiveSet<float>(max(100L,min((long)n,totalDegree+rCount)),LOAD_FACTOR,0.0); 
      vertexMap(Frontier,Local_Update(x,r));
      vertexSubset output = edgeMap(GA, Frontier, HK_F<vertex>(x,r,new_r,GA.V,t/(double)(j+1)));
      r.del(); 
      r = new_r;
      if(x.m < ((uintT) 1 << log2RoundUp((uintT)(LOAD_FACTOR*min((long)n,rCount+output.numNonzeros()))))) {
	sparseAdditiveSet<float> new_x = sparseAdditiveSet<float>(LOAD_FACTOR*min((long)n,rCount+output.numNonzeros()),LOAD_FACTOR,0.0); //make bigger hash table
	new_x.copy(x);
	x.del();
	x = new_x;
      }
      output.del();

      //compute active set (faster in practice to just scan over r)
      _seq<ACLpair> vals = r.entries(activeF<vertex>(GA.V,constant/psis[j+1]));
      uintE* Active = newA(uintE,vals.n);
      parallel_for(long i=0;i<vals.n;i++) Active[i] = vals.A[i].first;
      Frontier.del(); vals.del();
      Frontier = vertexSubset(n,vals.n,Active);
      j++;
    } else { //last iteration
示例#25
0
Academy::Academy() : WorkingBuilding( B_MILITARY_ACADEMY, Size(3) )
{
  setMaxWorkers( 20 );
  setWorkers( 0 );
  setPicture(PicLoader::instance().get_picture( ResourceGroup::security, 18));
}
Barracks::Barracks() : WorkingBuilding( B_BARRACKS, Size( 3 ) )
{
  setMaxWorkers(5);
  setWorkers(0);  
  setPicture( Picture::load( ResourceGroup::security, 17) );
}
示例#27
0
Barracks::Barracks() : WorkingBuilding( B_BARRACKS, Size( 3 ) )
{
  setMaxWorkers(5);
  setWorkers(0);  
  setPicture(PicLoader::instance().get_picture(ResourceGroup::security, 17));
}