예제 #1
0
void BinnedCorr2<D1,D2>::process11(const Cell<D1,C>& c1, const Cell<D2,C>& c2)
{
    if (c1.getW() == 0. || c2.getW() == 0.) return;

    const double dsq = MetricHelper<M>::DistSq(c1.getPos(),c2.getPos());
    const double s1ps2 = c1.getAllSize()+c2.getAllSize();

    if (MetricHelper<M>::TooSmallDist(c1.getPos(), c2.getPos(), s1ps2, dsq, _minsep, _minsepsq))
        return;
    if (MetricHelper<M>::TooLargeDist(c1.getPos(), c2.getPos(), s1ps2, dsq, _maxsep, _maxsepsq))
        return;

    // See if need to split:
    bool split1=false, split2=false;
    CalcSplitSq(split1,split2,c1,c2,dsq,s1ps2,_bsq);

    if (split1) {
        if (split2) {
            if (!c1.getLeft()) {
                std::cerr<<"minsep = "<<_minsep<<", maxsep = "<<_maxsep<<std::endl;
                std::cerr<<"minsepsq = "<<_minsepsq<<", maxsepsq = "<<_maxsepsq<<std::endl;
                std::cerr<<"c1.Size = "<<c1.getSize()<<", c2.Size = "<<c2.getSize()<<std::endl;
                std::cerr<<"c1.SizeSq = "<<c1.getSizeSq()<<
                    ", c2.SizeSq = "<<c2.getSizeSq()<<std::endl;
                std::cerr<<"c1.N = "<<c1.getN()<<", c2.N = "<<c2.getN()<<std::endl;
                std::cerr<<"c1.Pos = "<<c1.getPos();
                std::cerr<<", c2.Pos = "<<c2.getPos()<<std::endl;
                std::cerr<<"dsq = "<<dsq<<", s1ps2 = "<<s1ps2<<std::endl;
            }
            Assert(c1.getLeft());
            Assert(c1.getRight());
            Assert(c2.getLeft());
            Assert(c2.getRight());
            process11<C,M>(*c1.getLeft(),*c2.getLeft());
            process11<C,M>(*c1.getLeft(),*c2.getRight());
            process11<C,M>(*c1.getRight(),*c2.getLeft());
            process11<C,M>(*c1.getRight(),*c2.getRight());
        } else {
            Assert(c1.getLeft());
            Assert(c1.getRight());
            process11<C,M>(*c1.getLeft(),c2);
            process11<C,M>(*c1.getRight(),c2);
        }
    } else {
        if (split2) {
            Assert(c2.getLeft());
            Assert(c2.getRight());
            process11<C,M>(c1,*c2.getLeft());
            process11<C,M>(c1,*c2.getRight());
        } else if (dsq >= _minsepsq && dsq < _maxsepsq) {
            XAssert(NoSplit(c1,c2,sqrt(dsq),_b));
            directProcess11<C,M>(c1,c2,dsq);
        }
    }
}
예제 #2
0
AnimalCardFactory::AnimalCardFactory() {
	deck = make_shared<Deck<shared_ptr<AnimalCard>>>();

	//Creation de 15 cartes Action Cards (3 de chaque animal)
	for (int i=0; i<3; i++) {
		//Creation et addition de 15 cartes d'action dans le deck.
		shared_ptr<AnimalCard>b = make_shared<BearAction>(BearAction());
		shared_ptr<AnimalCard>d = make_shared<DeerAction>(DeerAction());
		shared_ptr<AnimalCard>h = make_shared<HareAction>(HareAction());
		shared_ptr<AnimalCard>m = make_shared<MooseAction>(MooseAction());
		shared_ptr<AnimalCard>w = make_shared<WolfAction>(WolfAction());
		deck->push_back(b);deck->push_back(d);deck->push_back(h);deck->push_back(m);deck->push_back(w);
	}

	//String utiliser pour la lecture des fichiers
	string line;

	// On fait la creation des cartes a partir de fichiers textes ayant les combinaisons des cartes predefinies
	// Toutes les animaux sont representes egalement dans les combinaisons predefinies
	//5 no split cards
	ifstream fileNoSplit("Data/comb_nosplit.txt");
	while(getline(fileNoSplit, line)) {//error here
		char ** cardChars = splitCardMaker(line);
		shared_ptr<AnimalCard> noSplit = make_shared<NoSplit>(NoSplit(cardChars));
		deck->push_back(noSplit);
	}
	fileNoSplit.close();

	//10 split two cards
	ifstream fileSplit2("Data/comb_split2.txt");
	while(getline(fileSplit2, line)) {//error here
		char ** cardChars = splitCardMaker(line);
		shared_ptr<AnimalCard> split2 = make_shared<SplitTwo>(SplitTwo(cardChars));
		deck->push_back(split2);
	}
	fileSplit2.close();

	//20 split three cards
	ifstream fileSplit3("Data/comb_split3.txt");
	while (getline(fileSplit3, line)) { //error here
		char ** cardChars = splitCardMaker(line);
		shared_ptr<AnimalCard> split3 = make_shared<SplitThree>(SplitThree(cardChars));
		deck->push_back(split3);
	}
	fileSplit3.close();

	//15 split four cards
	ifstream fileSplit4("Data/comb_split4.txt");
	while (getline(fileSplit4, line)) { //error here
		char ** cardChars = splitCardMaker(line);
		shared_ptr<AnimalCard> split4 = make_shared<SplitFour>(SplitFour(cardChars));
		deck->push_back(split4);
	}
	fileSplit4.close();

	//Joker
	shared_ptr<AnimalCard> j = make_shared<Joker>();
	deck->push_back(j);

	//Le shuffle du deck
	unsigned long seed = std::chrono::system_clock::now().time_since_epoch().count();
	auto engine = std::default_random_engine{seed};
	shuffle(deck->begin(), deck->end(), engine);
}