예제 #1
0
파일: perft.c 프로젝트: peterwankman/vice
void PerftTest(int depth, S_BOARD *pos) {
	S_MOVELIST list[1];
	int move;
	int MoveNum = 0;
	int start = GetTimeMs();
	long cumnodes, oldnodes;

	ASSERT(CheckBoard(pos));

	PrintBoard(pos);
	printf("\nStarting Test To Depth:%d\n", depth);
	leafNodes = 0;
	
	GenerateAllMoves(pos, list);

	for(MoveNum = 0; MoveNum < list->count; ++MoveNum) {
		move = list->moves[MoveNum].move;
		if(!MakeMove(pos, move))
			continue;

		cumnodes = leafNodes;
		Perft(depth - 1, pos);
		TakeMove(pos);
		oldnodes = leafNodes - cumnodes;
		printf("move %d : %s : %ld\n", MoveNum + 1, PrMove(move), oldnodes);
	}

	printf("\nTest Complete : %ld nodes visited in %dms\n", leafNodes, GetTimeMs() - start);
}
예제 #2
0
파일: movegen.c 프로젝트: peterwankman/vice
int MoveExists(S_BOARD *pos, const int move) {
	int MoveNum = 0;
	
	S_MOVELIST list[1];
	GenerateAllMoves(pos, list);
	
	for(MoveNum = 0; MoveNum < list->count; ++MoveNum) {
		if(!MakeMove(pos, list->moves[MoveNum].move)) {
			continue;
		}
		TakeMove(pos);
		if(list->moves[MoveNum].move == move) {
			return TRUE;
		}
	}
	return FALSE;
}
예제 #3
0
파일: perft.c 프로젝트: emilfo/Chess_c
U64 Perft(int depth, S_BOARD *pos) {
	ASSERT(checkBoard(pos));
 
 	S_MOVELIST list[1];
    GenerateAllMoves(pos, list);

    if(depth == 0) {
    	return 1;
    }

    U64 nodes = ZERO64;
    int i;
    for (i = 0; i < list->count; i++) {
    	if (MakeMove(pos, list->moves[i].move)) {
      	  nodes += Perft(depth - 1, pos);
      	  TakeMove(pos);
    	}
    }
    
    return nodes;
}
예제 #4
0
파일: perft.c 프로젝트: peterwankman/vice
void Perft(int depth, S_BOARD *pos) {
	S_MOVELIST list[1];
	int MoveNum = 0;

	ASSERT(CheckBoard(pos));

	if(depth == 0) {
		leafNodes++;
		return;
	}

	GenerateAllMoves(pos, list);

	for(MoveNum = 0; MoveNum < list->count; ++MoveNum) {
		if(!MakeMove(pos, list->moves[MoveNum].move)) {
			continue;
		}

		Perft(depth - 1, pos);
		TakeMove(pos);
	}

	return;
}
예제 #5
0
파일: pvtable.c 프로젝트: peterwankman/vice
int GetPvLine(const int depth, S_BOARD *pos) {
    int move = ProbePvMove(pos);
    int count = 0;

    ASSERT(depth < MAXDEPTH);

    while(move != NOMOVE && count < depth) {
        ASSERT(count < MAXDEPTH);

        if(MoveExists(pos, move)) {
            MakeMove(pos, move);
            pos->PvArray[count++] = move;
        } else {
            break;
        }
        move = ProbePvMove(pos);
    }

    while(pos->ply > 0) {
        TakeMove(pos);
    }

    return count;
}