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


C++ Evaluator::getNoEval方法代码示例

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


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

示例1: received

void MyDomain::received(char* str)
{
    static double Tottime=0;
    static long TotNoEval=0;

	//printf("\n %s", str);
    if (strncmp(str, "quit", 4)==0) {
	l.exit();
	return;
    }

    if (strncmp(str, "pos ", 4)!=0) return;

    b.setState(str+4);
    if (verbose) {
	printf("\n\n==========================================\n");
	printf(str+4);
    }

    int state = b.validState();
    if ((state != Board::valid1) && 
	(state != Board::valid2)) {
	printf("%s\n", Board::stateDescription(state));
	switch(state) {
	    case Board::timeout1:
	    case Board::timeout2:
	    case Board::win1:
	    case Board::win2:
        printf("\nTotal run time for player ");
	    printf("%s ", (myColor == Board::color1) ? "O":"X");
        printf(" =  %lf\n", (Tottime/1000));
        printf("Absolute evaluations = %ld\n ", TotNoEval);
        printf("Evaluations per sec = %lf \n", (TotNoEval*1000/Tottime));
		l.exit();
	    default:
		break;
	}
	return;
    }

    if (b.actColor() & myColor) {
	struct timeval t1, t2;

	gettimeofday(&t1,0);
	Move m = b.bestMove();
	gettimeofday(&t2,0);

	int msecsPassed =
	    (1000* t2.tv_sec + t2.tv_usec / 1000) -
	    (1000* t1.tv_sec + t1.tv_usec / 1000);

	printf("%s ", (myColor == Board::color1) ? "O":"X");
	if (m.type == Move::none) {
	    printf(" can not draw any move ?! Sorry.\n");
	    return;
	}
	printf("draws '%s' (after %d.%03d secs)...\n",
	       m.name(), msecsPassed/1000, msecsPassed%1000);
    Tottime += msecsPassed;

	b.playMove(m, msecsPassed);
	sendBoard();

	if (changeEval)
	    ev.changeEvaluation();
    
    // Sum up evaluations
    TotNoEval += ev.getNoEval();

	/* stop player at win position */
	int state = b.validState();
	if ((state != Board::valid1) && 
	    (state != Board::valid2)) {
	    printf("%s\n", Board::stateDescription(state));
	    switch(state) {
		case Board::timeout1:
		case Board::timeout2:
		case Board::win1:
		case Board::win2:
        printf("\nTotal run time for player ");
	    printf("%s ", (myColor == Board::color1) ? "O":"X");
        printf(" =  %lf\n", (Tottime/1000));
        printf("Absolute evaluations = %ld\n ", TotNoEval);
        printf("Evaluations per sec = %lf \n", (TotNoEval*1000/Tottime));
		    l.exit();
		default:
		    break;
	    }
	}

		maxMoves--;
		if (maxMoves == 0) 
		{
			//printf("\n %s", str);
		    printf("Terminating because given number of moves drawn.\n");
		    broadcast("quit\n");
		    l.exit();
		}
    }    
}
开发者ID:Aryabhatta,项目名称:SuperMuc,代码行数:100,代码来源:player.cpp

示例2: received

void MyDomain::received(char* str)
{
    static double Tottime=0;
    long TotNoEval=0;

    if (strncmp(str, "quit", 4)==0) {
	l.exit();
	return;
    }

    if (strncmp(str, "pos ", 4)!=0) return;

    b.setState(str+4);
    if (verbose) {
	printf("\n\n==========================================\n");
	printf(str+4);
    }

    int state = b.validState();
    int len;
    int NumTask, i;
    MPI_Status stat;
    MPI_Comm_size( MPI_COMM_WORLD, &NumTask);

    // Sum up evaluations
    TotNoEval =  ev.getNoEval();

    if ((state != Board::valid1) && 
	(state != Board::valid2)) {
	printf("%s\n", Board::stateDescription(state));

	switch(state) 
    {
	    case Board::timeout1:
	    case Board::timeout2:
	    case Board::win1:
	    case Board::win2:
    
            char boardLayout[500];
            // Send Exit Signal to slave through EXIT board
            len = sprintf(boardLayout, "exit%s\n",b.getState());
            for( i = 1; i< NumTask; i++)
            {
                MPI_Send( boardLayout, 500, MPI_CHAR, i, 10, MPI_COMM_WORLD );
                long NoEval;
                MPI_Recv(&NoEval, 1, MPI_LONG, i, 10, MPI_COMM_WORLD, &stat);
                printf("\n Evaluations for Rank: %d Evals: %ld", i, NoEval);
                TotNoEval += NoEval;
            }

        	printf("\nTotal run time for player ");
	    	printf("%s ", (myColor == Board::color1) ? "O":"X");
        	printf(" =  %lf\n", (Tottime/1000));
	        printf("Evaluations per sec = %lf \n", (TotNoEval*1000/Tottime));
            printf("Total Evaluations= %ld\n", TotNoEval);
		    l.exit();
	    default:
		break;
	}
	return;
    }

    if (b.actColor() & myColor) {
	struct timeval t1, t2;

	gettimeofday(&t1,0);
	Move m = b.bestMove();
	gettimeofday(&t2,0);

	int msecsPassed =
	    (1000* t2.tv_sec + t2.tv_usec / 1000) -
	    (1000* t1.tv_sec + t1.tv_usec / 1000);

	printf("%s ", (myColor == Board::color1) ? "O":"X");
	if (m.type == Move::none) {
	    printf(" can not draw any move ?! Sorry.\n");
	    return;
	}
	printf("draws '%s' (after %d.%03d secs)...\n",
	       m.name(), msecsPassed/1000, msecsPassed%1000);
	    Tottime += msecsPassed;

	printf("\nMoving board for Move:%s \n ", m.name());
	b.playMove(m, msecsPassed);
	sendBoard();

	if (changeEval)
	    ev.changeEvaluation();
    
    // Sum up evaluations
    TotNoEval =  ev.getNoEval();

	/* stop player at win position */
	int state = b.validState();
	if ((state != Board::valid1) && 
	    (state != Board::valid2)) {
	    printf("%s\n", Board::stateDescription(state));
	    switch(state) {
		case Board::timeout1:
		case Board::timeout2:
//.........这里部分代码省略.........
开发者ID:Aryabhatta,项目名称:SuperMuc,代码行数:101,代码来源:player.cpp


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