コード例 #1
0
void playGame()
{
	Boolean loaded = FALSE;
	Boolean hasInit = FALSE;
	Player player;
	Cell board[BOARD_HEIGHT][BOARD_WIDTH];
	char load[BUFFER_SIZE];
	char *token;
	char *readin;


	playgame_menu();
	initialiseBoard(board);
	printf("Please enter to continue...\n");
	while(getchar() != '\n');
	displayBoard(board, NULL);
	twoCommands_menu();
	while(TRUE)
	{
		if(loaded && hasInit)
		{
			fourCommands_menu();
		}
		else if (loaded)
		{
			threeCommands_menu();
		}


		readin = fgets(load,80,stdin);
		load[strlen(readin) - 1] = '\0';
		token = strtok(readin,DELIMS);
		if(strcmp(token,COMMAND_LOAD) == 0)
		{
			token = strtok(NULL,DELIMS);
			getBoard(board,token);
			loaded = TRUE;
		}
		else if(strcmp(token,COMMAND_INIT) == 0)
		{
			if(!loaded)
			{
				printf("INVALID INPUT.\n");
			}
			else
			{
				getInitialPosition(board,&player,token);
				displayBoard(board,&player);
				hasInit = TRUE;
			}
		}
		else if (strcmp(token,COMMAND_QUIT) == 0)
		{
			int moves = (int) player.moves;  
			printf("Total player moves : %d\n",moves);
			break;
		}
		else {
			getNextMove(board,token,&player);
		}
	}
}
コード例 #2
0
ファイル: Search.cpp プロジェクト: niklasf/Cinnamon
int Search::search(int depth, int alpha, int beta, _TpvLine *pline, int N_PIECE, int *mateIn) {
    ASSERT_RANGE(depth, 0, MAX_PLY);
    INC(cumulativeMovesCount);
    *mateIn = INT_MAX;
    ASSERT_RANGE(side, 0, 1);
    if (!getRunning()) {
        return 0;
    }
    int score = -_INFINITE;
    /* gtb */
    if (gtb && pline->cmove && maxTimeMillsec > 1000 && gtb->isInstalledPieces(N_PIECE) && depth >= gtb->getProbeDepth()) {
        int v = gtb->getDtm<side, false>(chessboard, (uchar) chessboard[RIGHT_CASTLE_IDX], depth);
        if (abs(v) != INT_MAX) {
            *mateIn = v;
            int res = 0;
            if (v == 0) {
                res = 0;
            } else {
                res = _INFINITE - (abs(v));
                if (v < 0) {
                    res = -res;
                }
            }
            ASSERT_RANGE(res, -_INFINITE, _INFINITE);
            ASSERT(mainDepth >= depth);
            return res;
        }
    }
    u64 oldKey = chessboard[ZOBRISTKEY_IDX];
#ifdef DEBUG_MODE
    double betaEfficiencyCount = 0.0;
#endif
    ASSERT(chessboard[KING_BLACK]);
    ASSERT(chessboard[KING_WHITE]);
    ASSERT(chessboard[KING_BLACK + side]);
    int extension = 0;
    int is_incheck_side = inCheck<side>();
    if (!is_incheck_side && depth != mainDepth) {
        if (checkInsufficientMaterial(N_PIECE)) {
            if (inCheck<side ^ 1>()) {
                return _INFINITE - (mainDepth - depth + 1);
            }
            return -lazyEval<side>() * 2;
        }
        if (checkDraw(chessboard[ZOBRISTKEY_IDX])) {
            return -lazyEval<side>() * 2;
        }
    }
    if (is_incheck_side) {
        extension++;
    }
    depth += extension;
    if (depth == 0) {
        return quiescence<side, smp>(alpha, beta, -1, N_PIECE, 0);
    }

    //************* hash ****************
    u64 zobristKeyR = chessboard[ZOBRISTKEY_IDX] ^_random::RANDSIDE[side];

    _TcheckHash checkHashStruct;

    if (checkHash<Hash::HASH_GREATER, smp>(false, alpha, beta, depth, zobristKeyR, checkHashStruct)) {
        return checkHashStruct.res;
    };
    if (checkHash<Hash::HASH_ALWAYS, smp>(false, alpha, beta, depth, zobristKeyR, checkHashStruct)) {
        return checkHashStruct.res;
    };
    ///********** end hash ***************

    if (!(numMoves & 1023)) {
        setRunning(checkTime());
    }
    ++numMoves;
    ///********* null move ***********
    int n_pieces_side;
    _TpvLine line;
    line.cmove = 0;

    if (!is_incheck_side && !nullSearch && depth >= NULLMOVE_DEPTH && (n_pieces_side = getNpiecesNoPawnNoKing<side>()) >= NULLMOVES_MIN_PIECE) {
        nullSearch = true;
        int nullScore = -search<side ^ 1, smp>(depth - (NULLMOVES_R1 + (depth > (NULLMOVES_R2 + (n_pieces_side < NULLMOVES_R3 ? NULLMOVES_R4 : 0)))) - 1, -beta, -beta + 1, &line, N_PIECE, mateIn);
        nullSearch = false;
        if (nullScore >= beta) {
            INC(nNullMoveCut);
            return nullScore;
        }
    }
    ///******* null move end ********
    /**************Futility Pruning****************/
    /**************Futility Pruning razor at pre-pre-frontier*****/
    bool futilPrune = false;
    int futilScore = 0;
    if (depth <= 3 && !is_incheck_side) {
        int matBalance = lazyEval<side>();
        if ((futilScore = matBalance + FUTIL_MARGIN) <= alpha) {
            if (depth == 3 && (matBalance + RAZOR_MARGIN) <= alpha && getNpiecesNoPawnNoKing<side ^ 1>() > 3) {
                INC(nCutRazor);
                depth--;
            } else
                ///**************Futility Pruning at pre-frontier*****
            if (depth == 2 && (futilScore = matBalance + EXT_FUTILY_MARGIN) <= alpha) {
                futilPrune = true;
                score = futilScore;
            } else
                ///**************Futility Pruning at frontier*****
            if (depth == 1) {
                futilPrune = true;
                score = futilScore;
            }
        }
    }
    /************ end Futility Pruning*************/
    incListId();
    ASSERT_RANGE(KING_BLACK + side, 0, 11);
    ASSERT_RANGE(KING_BLACK + (side ^ 1), 0, 11);
    u64 friends = getBitmap<side>();
    u64 enemies = getBitmap<side ^ 1>();
    if (generateCaptures<side>(enemies, friends)) {
        decListId();
        score = _INFINITE - (mainDepth - depth + 1);
        return score;
    }
    generateMoves<side>(friends | enemies);
    int listcount = getListSize();
    if (!listcount) {
        --listId;
        if (is_incheck_side) {
            return -_INFINITE + (mainDepth - depth + 1);
        } else {
            return -lazyEval<side>() * 2;
        }
    }
    _Tmove *best = nullptr;
    if (checkHashStruct.hashFlag[Hash::HASH_GREATER]) {
        sortHashMoves(listId, checkHashStruct.phasheType[Hash::HASH_GREATER]);
    } else if (checkHashStruct.hashFlag[Hash::HASH_ALWAYS]) {
        sortHashMoves(listId, checkHashStruct.phasheType[Hash::HASH_ALWAYS]);
    }
    INC(totGen);
    _Tmove *move;
    bool checkInCheck = false;
    int countMove = 0;
    char hashf = Hash::hashfALPHA;
    while ((move = getNextMove(&gen_list[listId]))) {
        countMove++;
        INC(betaEfficiencyCount);
        if (!makemove(move, true, checkInCheck)) {
            takeback(move, oldKey, true);
            continue;
        }
        checkInCheck = true;
        if (futilPrune && ((move->type & 0x3) != PROMOTION_MOVE_MASK) && futilScore + PIECES_VALUE[move->capturedPiece] <= alpha && !inCheck<side>()) {
            INC(nCutFp);
            takeback(move, oldKey, true);
            continue;
        }
        //Late Move Reduction
        int val = INT_MAX;
        if (countMove > 4 && !is_incheck_side && depth >= 3 && move->capturedPiece == SQUARE_FREE && move->promotionPiece == NO_PROMOTION) {
            currentPly++;
            val = -search<side ^ 1, smp>(depth - 2, -(alpha + 1), -alpha, &line, N_PIECE, mateIn);
            ASSERT(val != INT_MAX);
            currentPly--;
        }
        if (val > alpha) {
            int doMws = (score > -_INFINITE + MAX_PLY);
            int lwb = max(alpha, score);
            int upb = (doMws ? (lwb + 1) : beta);
            currentPly++;
            val = -search<side ^ 1, smp>(depth - 1, -upb, -lwb, &line, move->capturedPiece == SQUARE_FREE ? N_PIECE : N_PIECE - 1, mateIn);
            ASSERT(val != INT_MAX);
            currentPly--;
            if (doMws && (lwb < val) && (val < beta)) {
                currentPly++;
                val = -search<side ^ 1, smp>(depth - 1, -beta, -val + 1, &line, move->capturedPiece == SQUARE_FREE ? N_PIECE : N_PIECE - 1, mateIn);
                currentPly--;
            }
        }
        score = max(score, val);
        takeback(move, oldKey, true);
        move->score = score;
        if (score > alpha) {
            if (score >= beta) {
                decListId();
                ASSERT(move->score == score);
                INC(nCutAB);
                ADD(betaEfficiency, betaEfficiencyCount / (double) listcount * 100.0);
                ASSERT(checkHashStruct.rootHash[Hash::HASH_GREATER]);
                ASSERT(checkHashStruct.rootHash[Hash::HASH_ALWAYS]);
                recordHash<smp>(getRunning(), checkHashStruct.rootHash, depth - extension, Hash::hashfBETA, zobristKeyR, score, move);
                setKillerHeuristic(move->from, move->to, 0x400);
                return score;
            }
            alpha = score;
            hashf = Hash::hashfEXACT;
            best = move;
            move->score = score;    //used in it
            updatePv(pline, &line, move);
        }
    }
    ASSERT(checkHashStruct.rootHash[Hash::HASH_GREATER]);
    ASSERT(checkHashStruct.rootHash[Hash::HASH_ALWAYS]);
    recordHash<smp>(getRunning(), checkHashStruct.rootHash, depth - extension, hashf, zobristKeyR, score, best);
    decListId();
    return score;
}
コード例 #3
0
ファイル: antz.c プロジェクト: rushipatel/ANTZ
int main(void)
{
	unsigned char temp_sqr,temp_dir,temp_diff,temp;
	unsigned int i;
	unsigned char channel=150;
	hardwareInit();
	//FOLD_ARMS;
	/*__delay_ms(50);
	do{
		if(key_UP)
		{
			channel+=10;
			LED_ON;
			__delay_ms(20);
			LED_OFF;
		}
		if(key_DN)
		{
			channel-=10;
			LED_ON;
			__delay_ms(20);
			LED_OFF;
		}
		__delay_ms(300);
		readButtons();
	}	while(!key_GO);
	LED_ON;
	__delay_ms(200);
	LED_OFF;
	CC2500_init();
	CC2500_write_register(CHANNR,channel);
	CC2500_idle_mode();
	CC2500_receive_mode();
	do{
		if(key_UP)
		{
			speed++;
			if(speed>4)
				speed = 4;
			LED_ON;
			__delay_ms(20);
			LED_OFF;
		}
		if(key_DN)
		{
			speed--;
			if(speed<0)
				speed = 0;
			LED_ON;
			__delay_ms(20);
			LED_OFF;
		}
		__delay_ms(300);
		readButtons();
	}while(!key_GO);*/
	LED_ON;
	__delay_ms(150);
	LED_OFF;
	__delay_ms(150);
	LED_ON;
	__delay_ms(150);
	LED_OFF;
	
	#ifdef MACHINE_A
		statusInitA();
	#endif
	#ifdef MACHINE_B
		statusInitB();
	#endif
	assamble_packet();
	CC2500_idle_mode();
	CC2500_clear_rx_fifo();
	CC2500_clear_tx_fifo();
	CC2500_receive_mode();
	__delay_ms(100);
	i = CC2500_read_status_register( RXBYTES);
	i&=0xFF;
	sprintf(outBuf,"\r\n%u\r\n",i);
	putsUART(outBuf);
	if(i)
	{
		CC2500_idle_mode();
		CC2500_clear_rx_fifo();
		CC2500_clear_tx_fifo();
		CC2500_receive_mode();
		while(GDO0==0);
		while(GDO0==1);
		SYSTIM_TMR = 9581;
		__delay_ms(3);
		commCount = 0;
		startSystemTimer();
		noCommCount=0;
		commEnabled = TRUE;
		if(waitDataUpdate())
			my.obzEntrCnt = fellow.obzEntrCnt;
		/*LED_ON;
		__delay_ms(2000);*/
		
	}
	else
	{
		startSystemTimer();
		noCommCount=0;
		commEnabled = TRUE;
	}
	#ifdef MACHINE_A
	while(!key_GO){
		if(noCommCount>100)
		{
			commEnabled = FALSE;
			waitToTick();
			CC2500_init();
			commEnabled = TRUE;
			__delay_ms(40);
			//noCommCount = 0;
		}
	}
	#endif

	if(displayEnabled)
	{
		switch(resetSource())
		{
			case POWER_ON_RESET:
				sprintf(outBuf,"\r\nBattry Voltage : %u",batteryVoltage);
				putsUART(outBuf);
				break;
			
			case EXTERNAL_RESET:
				sprintf(outBuf,"\r\nUser Reset...");
				putsUART(outBuf);
				break;
			
			default:
				sprintf(outBuf,"\r\nUnknown Reset");
				putsUART(outBuf);
				break;
		}
	}
	/*while(TRUE)
	{
		printSensors();
		__delay_ms(500);
	}*/
	
	gridInit();
	#ifdef MACHINE_B
	while(TRUE)
	{
		if(noCommCount>100)
		{
			commEnabled = FALSE;
			waitToTick();
			CC2500_init();
			commEnabled = TRUE;
			__delay_ms(40);
			//noCommCount = 0;
		}
		if(dataUpdated)
		{
			printStatus(&fellow);
			/*rx_buff_temp[0] = rx_buff0;
			rx_buff_temp[1] = rx_buff1;
			rx_buff_temp[2] = rx_buff2;
			rx_buff_temp[3] = rx_buff3;
			rx_buff_temp[4] = rx_buff4;
			rx_buff_temp[5] = rx_buff5;
			sprintf(outBuf,"\r\n\r\n%u,%u,%u,%u,%u,%u",
												rx_buff_temp[0],
												rx_buff_temp[1],
												rx_buff_temp[2],
												rx_buff_temp[3],
												rx_buff_temp[4],
												rx_buff_temp[5]);
			putsUART(outBuf);*/
			dataUpdated = FALSE;
		}		
	}
	//while(!key_GO);
	while(fellow.heading==10&&!key_GO);
	//while(fellow.heading==10);
	#endif
	
	while(TRUE)
	{
		if(noCommCount>100)
		{
			commEnabled = FALSE;
			waitToTick();
			CC2500_init();
			commEnabled = TRUE;
			__delay_ms(40);
			//noCommCount = 0;
		}
		switch(mcState)
		{
			case MC_START:
			{
				cubeSensorsOn();
				waitToTick();
				waitToTick();
				cubeSensorsOff();
				temp_sqr = nextSquare(my.location,my.heading&0x07);
				grid[temp_sqr] |= VISITED;
				if(frontCube)
				{
					myCube[++cubeInd] = temp_sqr;
					mcState=MC_DELIVER;
				}
				else
					mcState=MC_SCAN;
				break;
			}
			case MC_SCAN:
			{
				temp_sqr = scanMap[my.smInd];
				if(my.location==temp_sqr)
				{
					my.smInd++;
					break;
				}
				my.goalSquare = temp_sqr;
				mcNextState = MC_SCAN;
				mcState = MC_GET_M_THR;
				/*temp_dir = nextDirection(my.location,temp_sqr);
				temp_diff = temp_dir - (my.heading&0x07);
					
				if(prState==PR_STR_ACC||prState==PR_STR_DEC)
				{
					if(temp_diff)
						break;
					waitDataUpdate();
					if(commonSquare(temp_sqr))
						break;
					my.heading &= 0x07;
					finalPos += COUNTS_PER_CELL*256;
					if(prState==PR_STR_DEC)
						prState = PR_STR_ACC;
					while(relativeDistance>distance[ORTHO_SENS_DIST]*2);
				}
				else if(prState==PR_FINISHED)
				{
					if(temp_diff)
					{
						commandList[cmlInd++] = getTurnCmd(temp_diff);
						my.heading = temp_dir | NODIR;
					}
					waitDataUpdate();
					if(commonSquare(temp_sqr))
					{
						commandList[cmlInd++] = CMD_STOP;
						getNextMove();
						break;
					}
					my.heading &= 0x07;
					commandList[cmlInd++] = CMD_STRAIGHT | CMD_FORWARD;
					commandList[cmlInd++] = CMD_STOP;
					getNextMove();
				}
				else
					break;
				while(prState!=PR_STR_ACC);
				while(relativeDistance<distance[ORTHO_SENS_DIST]*2);
				my.location = nextSquare(my.location,my.heading);
				grid[my.location] |= ONROUTE;
				my.heading |= NODIR;
				if(scanNeighbours())
				{
					mcState = MC_DELIVER;
				}*/
				my.smInd++;
				if(my.smInd>=17)
				{
					my.smInd = 0;
					#ifdef MACHINE_A
					my.goalSquare = 20;
					#endif
					#ifdef MACHINE_B
					my.goalSquare = 60;
					#endif
					mcNextState = MC_SCAN;
					mcState = MC_GET_M_THR;
				}
			break;
			}
			case MC_GET_M_THR:
			{
				waitDataUpdate();
				updateGrid();
				floodGrid(my.goalSquare);
				/*if(map[my.location] == 0)
				{
					mcState = mcNextState;
					break;
				}*/
				temp_sqr = nextNeighbour(my.location);
				temp_dir = nextDirection(my.location,temp_sqr);
				temp_diff = temp_dir - (my.heading&0x07);
				waitDataUpdate();
				if(commonSquare(temp_sqr))
				{
					break;
				}
				if((!inOBZ(my.location)) && inOBZ(temp_sqr))
				{
					if(!my.obzClear || !my.delivering)
						break;

				}
				if(inOBZ(my.location) && (!inOBZ(temp_sqr)))
				{
					my.obzEntrCnt+=2;
				}
				if(isDipoSquare(temp_sqr)&& my.delivering)
				{
					mcState = MC_DELIVER_FINISH;
					break;
				}
				if(prState==PR_STR_ACC||prState==PR_STR_DEC)
				{
					if(temp_diff)
						break;
					my.heading &= 0x07;
					finalPos += COUNTS_PER_CELL*256;
					if(prState==PR_STR_DEC)
						prState = PR_STR_ACC;
					while(relativeDistance>distance[ORTHO_SENS_DIST]*2);
				}
				else if(prState==PR_FINISHED)
				{
					if(temp_diff)
					{
						commandList[cmlInd++] = getTurnCmd(temp_diff);
						commandList[cmlInd++] = CMD_STOP;
						getNextMove();
						my.heading = temp_dir|NODIR;
						break;
					}
					else
					{
						if(!(grid[temp_sqr]&VISITED));
						{
							cubeSensorsOn();
							waitToTick();
							waitToTick();
							cubeSensorsOff();
							if(!commonSquare(temp_sqr))
							{
								grid[temp_sqr] |= VISITED;
								if(frontCube)
								{
									updateCube(temp_sqr);
									break;
								}
							}
						}
						my.heading &= 0x07;
						commandList[cmlInd++] = CMD_STRAIGHT | CMD_FORWARD;
						commandList[cmlInd++] = CMD_STOP;
						getNextMove();
					}
				}
				else
					break;
				while(prState!=PR_STR_ACC);
				while(relativeDistance<distance[ORTHO_SENS_DIST]*2);
				my.location = nextSquare(my.location,my.heading);
				grid[my.location] |= ONROUTE;
				my.heading |= NODIR;
				if(scanNeighbours()&&(my.delivering==FALSE))
				{
					mcState = MC_DELIVER;
					break;
				}
				if(map[my.location] == 0)
					mcState = mcNextState;
				break;
			}
			case MC_DELIVER:
			{
				temp_sqr = unDipoCube();
				if(temp_sqr)
				{
					waitDataUpdate();
					if(inOBZ(temp_sqr)&&!my.obzClear)
						break;
					temp_dir = nextDirection(my.location,temp_sqr);
					if(temp_dir==NODIR)
					{
						temp_sqr = nearestNeighbourOfCube();
						if(temp_sqr)
						{
							my.goalSquare = temp_sqr;
							mcNextState = MC_DELIVER;
							mcState = MC_GET_M_THR;
						}
						else
						{
							do{
								my.smInd++;
							}while(grid[scanMap[my.smInd]]&ONROUTE);
							my.goalSquare = scanMap[my.smInd];
							mcNextState = MC_SCAN;
							mcState = MC_GET_M_THR;
						}
						break;
					}
					else
					{
						grabCube(temp_dir);
						if(my.delivering)
						{
							temp = temp_sqr;
							my.goalSquare = my.location;
							temp_sqr = getDipoSquare();
							if(temp_sqr)
							{
								for(i=0; i<4; i++)
								{
									if((myCube[i]<81)&&myCube[i]==temp)
										temp = i;
								}
								
								myCube[/*cubeIndForMcDeliver*/temp] = temp_sqr;
								my.goalSquare = temp_sqr;
								mcNextState = MC_DELIVER;
								mcState = MC_GET_M_THR;
								break;
							}
						}
					}
					break;
				}
				do{
					my.smInd++;
				}while(grid[scanMap[my.smInd]]&ONROUTE);
				my.goalSquare = scanMap[my.smInd];
				mcNextState = MC_SCAN;
				mcState = MC_GET_M_THR;
				break;
			}
			case MC_DELIVER_FINISH:
			{
				deliverCube();
				if(unDipoCube())
				{
					mcState = MC_DELIVER;
					break;
				}
				do{
					my.smInd++;
				}while(grid[scanMap[my.smInd]]&ONROUTE);
				my.goalSquare = scanMap[my.smInd];
				mcNextState = MC_SCAN;
				mcState = MC_GET_M_THR;
			}
		}
	}	
	while(TRUE);
	return 0;
}
コード例 #4
0
ファイル: Search.cpp プロジェクト: niklasf/Cinnamon
int Search::quiescence(int alpha, int beta, const char promotionPiece, int N_PIECE, int depth) {
    if (!getRunning()) {
        return 0;
    }
    ASSERT(chessboard[KING_BLACK + side]);
    if (!(numMovesq++ & 1023)) {
        setRunning(checkTime());
    }

    int score = getScore(side, N_PIECE, alpha, beta, false);
    if (score >= beta) {
        return beta;
    }
    ///************* hash ****************
    char hashf = Hash::hashfALPHA;
    u64 zobristKeyR = chessboard[ZOBRISTKEY_IDX] ^_random::RANDSIDE[side];

    _TcheckHash checkHashStruct;

    if (checkHash<Hash::HASH_GREATER, smp>(true, alpha, beta, depth, zobristKeyR, checkHashStruct)) {
        return checkHashStruct.res;
    };
    if (checkHash<Hash::HASH_ALWAYS, smp>(true, alpha, beta, depth, zobristKeyR, checkHashStruct)) {
        return checkHashStruct.res;
    };

///********** end hash ***************
/**************Delta Pruning ****************/
    char fprune = 0;
    int fscore;
    if ((fscore = score + (promotionPiece == NO_PROMOTION ? VALUEQUEEN : 2 * VALUEQUEEN)) < alpha) {
        fprune = 1;
    }
/************ end Delta Pruning *************/
    if (score > alpha) {
        alpha = score;
    }

    incListId();

    u64 friends = getBitmap<side>();
    u64 enemies = getBitmap<side ^ 1>();
    if (generateCaptures<side>(enemies, friends)) {
        decListId();

        return _INFINITE - (mainDepth + depth);
    }
    if (!getListSize()) {
        --listId;
        return score;
    }
    _Tmove *move;
    _Tmove *best = nullptr;
    u64 oldKey = chessboard[ZOBRISTKEY_IDX];
    if (checkHashStruct.hashFlag[Hash::HASH_GREATER]) {
        sortHashMoves(listId, checkHashStruct.phasheType[Hash::HASH_GREATER]);
    } else if (checkHashStruct.hashFlag[Hash::HASH_ALWAYS]) {
        sortHashMoves(listId, checkHashStruct.phasheType[Hash::HASH_ALWAYS]);
    }
    while ((move = getNextMove(&gen_list[listId]))) {
        if (!makemove(move, false, true)) {
            takeback(move, oldKey, false);
            continue;
        }
/**************Delta Pruning ****************/
        if (fprune && ((move->type & 0x3) != PROMOTION_MOVE_MASK) && fscore + PIECES_VALUE[move->capturedPiece] <= alpha) {
            INC(nCutFp);
            takeback(move, oldKey, false);
            continue;
        }
/************ end Delta Pruning *************/
        int val = -quiescence<side ^ 1, smp>(-beta, -alpha, move->promotionPiece, N_PIECE - 1, depth - 1);
        score = max(score, val);
        takeback(move, oldKey, false);
        if (score > alpha) {
            if (score >= beta) {
                decListId();
                ASSERT(checkHashStruct.rootHash[Hash::HASH_GREATER]);
                ASSERT(checkHashStruct.rootHash[Hash::HASH_ALWAYS]);
                recordHash<smp>(getRunning(), checkHashStruct.rootHash, depth, Hash::hashfBETA, zobristKeyR, score, move);
                return beta;
            }
            best = move;
            alpha = score;
            hashf = Hash::hashfEXACT;
        }
    }
    ASSERT(checkHashStruct.rootHash[Hash::HASH_GREATER]);
    ASSERT(checkHashStruct.rootHash[Hash::HASH_ALWAYS]);
    recordHash<smp>(getRunning(), checkHashStruct.rootHash, depth, hashf, zobristKeyR, score, best);

    decListId();

    return score;
}