Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
void PlayBot()
{
	printf("\n\nAt Any Time In The Game If You Want To See The Grid Indexing In Which You Have To Make A Move\n\n");
	printf("During Enter A Move Command...Just Press 0 And Press Enter \n\n");
	BOARD *board=new BOARD;
	SetStart(board);
	printf("The Starting Board\n\n");
	PrintBoard(board);
	char Inp[200];
	int Side;
	printf("\nChoose Your Side...\n\n0. For Black\n1. For White\n");
	scanf("%d",&Side);
	if(Side==0)
	{
		MOVE *list1=new MOVE;
		GenMoves(board,list1);
		vector<int>BestMove1=SearchPos(board,8);
		MakeMove(board,BestMove1);
		PrintBoard(board);
	}
	while(1)
	{
		printf("\n\nEnter Your Move\n");
		getchar();
		scanf("%[^\n]",&Inp);
		if(Inp[0]=='0')
		{
			PrintIndex();
			continue;
		}
		else if(Inp[0]=='1')
		{
			printf("\nYour Possible MoveList is\n");
			MOVE *YourMoveList=new MOVE;
			GenMoves(board,YourMoveList);
			PrintMoveList(YourMoveList);
		}
		vector<int>Move=ParseMove(Inp);
		if(MoveExists(board,Move))
			MakeMove(board,Move);
		else
		{
			MOVE *User=new MOVE;
			GenMoves(board,User);
			if(User->Count==0)
			{
				printf("Sorry You Lost\n\n");
				break;
			}
			else
				printf("Invalid Move...Enter Again\n\n");
			continue;
		}
		PrintBoard(board);
		printf("-----------------------------------Bot's Turn----------------------------------\n");
		MOVE *Bot=new MOVE;
		GenMoves(board,Bot);
		if(Bot->Count==0)
		{
			printf("--------------------------Congratulations You Win--------------------------\n");
			break;
		}
		vector<int>BestMove=SearchPos(board,8);
		MakeMove(board,BestMove);
		PrintBoard(board);
	}
	StartGame();	
}