当前位置: 首页>>代码示例>>C++>>正文


C++ Generator::allcrosses方法代码示例

本文整理汇总了C++中Generator::allcrosses方法的典型用法代码示例。如果您正苦于以下问题:C++ Generator::allcrosses方法的具体用法?C++ Generator::allcrosses怎么用?C++ Generator::allcrosses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Generator的用法示例。


在下文中一共展示了Generator::allcrosses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
    G.loaddawg("sowpods.dawg"); 
    G.loadworths("mavenworths");
    G.loadsyn2("fakesyn2");
   
    cout << "Lexicon loaded." << endl;

	ifstream countfile("sowpods-counts.txt");

    while(!countfile.eof()) {
        string w;
        int c;
        countfile >> c;
        countfile >> w;
        if (!countfile.eof()) {
            playability[w] = c;
        }
    }

	cout << "Playability crap loaded." << endl;

    ifstream twlfile("twl.raw");
                                                                                
    while(!twlfile.eof()) {
        string w;
        twlfile >> w;
        twl[w] = true;
    }

	cout << "TWL loaded." << endl;
                                                                                
    srand(time(NULL));

	puzzlenumber = 1;
  
	for (int i = 0; i < 1000; i++)
	{
		B.init();
		S.init();
		S.refill(R[0]);
		S.refill(R[1]);

		for (int j = 0; j < 10; j++)
		{
			G.setboard(B);
			G.allcrosses();
			G.setrack(R[j % 2]);
			G.setrecordall(true);
			G.findstaticbest(true);

			Move M = sim(R[j % 2]);

			if (M.action == Place)
			{
				B.makemove(M);
				R[j % 2] -= M;
				S.refill(R[j % 2]);
			}
			else if (M.action == Exchange)
			{
				S.exch(M, R[j % 2]);
			}

			puzzlenumber++;
		}
	}			
}
开发者ID:cdhowie,项目名称:Quackle,代码行数:67,代码来源:autosimmer.c

示例2: sim

Move sim(Rack &currR) {
	// cout << B << endl;
	// cout << "Rack: " << currR << endl;

	int num = 20;
	int n = 1000;

	movelist.clear();

	// cout << "G.movelist.size(): " << G.movelist.size() << endl;

    for (int i = 0; i < G.movelist.size(); i++) {
        int insertpos = 0;
        bool insert = false;
        for (int j = num - 1; j >= 0; j--) {
           if (j < movelist.size()) {
               if (G.movelist[i].equity > movelist[j].equity) {
                   insertpos = j;
                   insert = true;
               }
           }
        }

        if (insert) {
            vector<Move>::iterator it = movelist.begin();
            for (int j = 0; j < insertpos; j++) {
                it++;
            }
            movelist.insert(it, 1, G.movelist[i]);
        }
        else {
            movelist.push_back(G.movelist[i]);
        }
    }

	vector<string> mainwords;
	for (int i = 0; i < num; i++)
	{
		string word;
		if (movelist[i].action == Pass)
		{
			word = "pss";
		}
		else if (movelist[i].action == Exchange)
		{
			word = "xch";
		}
		else if (movelist[i].action == Place)
		{
			vector<string> words = spitwords(movelist[i], B);
			word = words[words.size() - 1];
		}

		mainwords.push_back(word); 
	}

    Bag origS;
    for (int i = 0; i < 15; i++) {
        for (int j = 0; j < 15; j++) {
            string c = "";
            if (isalpha(B.letters[i][j])) {
                if (isupper(B.letters[i][j])) {
                    c += B.letters[i][j];
                }
                else {
                    c = "?";
                }
            }
            Rack dummy;
            origS.fill(dummy, c);
        }
    }

	sums.clear();
	ns.clear();
    for (int i = 0; i < num; i++) {
        sums.push_back(0);
        ns.push_back(0);
    }

    for (int k = 0; k < n; k++) 
	{
        for (int i = 0; i < num; i++) 
		{
            Board orig = B;
            G.setboard(B);
            G.allcrosses();
            G.setrecordall(false);
            Move M[3];
            Rack sR[2];
            Bag simBag = origS;

            simBag.fill(sR[0], currR.tiles);
            simBag.refill(sR[1]);

            for (int j = 0; j < 3; j++) {
                if (j > 0) {
                    G.setrack(sR[j % 2]);

                    bool canexch = false;
//.........这里部分代码省略.........
开发者ID:cdhowie,项目名称:Quackle,代码行数:101,代码来源:autosimmer.c


注:本文中的Generator::allcrosses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。