亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? search.c

?? 一個嵌入式操作系統(microwindows)的源代碼
?? C
字號:
/*
 *	SEARCH.C
 *	Tom Kerrigan's Simple Chess Program (TSCP)
 *
 *	Copyright 1997 Tom Kerrigan
 */


#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "data.h"
#include "protos.h"


/* see the beginning of think() */
#include <setjmp.h>
jmp_buf env;
BOOL stop_search;


/* think() calls search() iteratively. Search statistics
   are printed depending on the value of output:
   0 = no output
   1 = normal output
   2 = xboard format output */

void think(int output)
{
	int i, j, x;

	/* some code that lets us longjmp back here and return
	   from think() when our time is up */
	stop_search = FALSE;
	setjmp(env);
	if (stop_search) {
		
		/* make sure to take back the line we were searching */
		while (ply)
			takeback();
		return;
	}

	start_time = get_ms();
	stop_time = start_time + max_time;

	ply = 0;
	nodes = 0;
	memset(pv, 0, sizeof(pv));
	memset(history, 0, sizeof(history));
	if (output == 1)
		printf("ply      nodes  score  pv\n");
	for (i = 1; i <= max_depth; ++i) {
		follow_pv = TRUE;
		x = search(-10000, 10000, i);
		if (output == 1)
			printf("%3d  %9d  %5d ", i, nodes, x);
		else if (output == 2)
			printf("%d %d %d %d",
					i, x, (get_ms() - start_time) / 10, nodes);
		if (output) {
			for (j = 0; j < pv_length[0]; ++j)
				printf(" %s", move_str(pv[0][j].b));
			printf("\n");
			fflush(stdout);
		}
		if (x > 9000 || x < -9000)
			break;
	}
}


/* search() does just that, in negamax fashion */

int search(int alpha, int beta, int depth)
{
	int i, j, x;
	BOOL c, f;

	/* we're as deep as we want to be; call quiesce() to get
	   a reasonable score and return it. */
	if (!depth)
		return quiesce(alpha,beta);
	++nodes;

	/* do some housekeeping every 1024 nodes */
	if ((nodes & 1023) == 0)
		checkup();

	pv_length[ply] = ply;

	/* if this isn't the root of the search tree (where we have
	   to pick a move and can't simply return 0) then check to
	   see if the position is a repeat. if so, we can assume that
	   this line is a draw and return 0. */
	if (ply && reps())
		return 0;

	/* are we too deep? */
	if (ply >= MAX_PLY - 1)
		return eval();
	if (hply >= HIST_STACK - 1)
		return eval();

	/* are we in check? if so, we want to search deeper */
	c = in_check(side);
	if (c)
		++depth;
	gen();
	if (follow_pv)  /* are we following the PV? */
		sort_pv();
	f = FALSE;

	/* loop through the moves */
	for (i = first_move[ply]; i < first_move[ply + 1]; ++i) {
		sort(i);
		if (!makemove(gen_dat[i].m.b))
			continue;
		f = TRUE;
		x = -search(-beta, -alpha, depth - 1);
		takeback();
		if (x > alpha) {

			/* this move caused a cutoff, so increase the history
			   value so it gets ordered high next time we can
			   search it */
			history[(int)gen_dat[i].m.b.from][(int)gen_dat[i].m.b.to] += depth;
			if (x >= beta)
				return beta;
			alpha = x;

			/* update the PV */
			pv[ply][ply] = gen_dat[i].m;
			for (j = ply + 1; j < pv_length[ply + 1]; ++j)
				pv[ply][j] = pv[ply + 1][j];
			pv_length[ply] = pv_length[ply + 1];
		}
	}

	/* no legal moves? then we're in checkmate or stalemate */
	if (!f) {
		if (c)
			return -10000 + ply;
		else
			return 0;
	}

	/* fifty move draw rule */
	if (fifty >= 100)
		return 0;
	return alpha;
}


/* quiesce() is a recursive minimax search function with
   alpha-beta cutoffs. In other words, negamax. It basically
   only searches capture sequences and allows the evaluation
   function to cut the search off (and set alpha). The idea
   is to find a position where there isn't a lot going on
   so the static evaluation function will work. */

int quiesce(int alpha,int beta)
{
	int i, j, x;

	++nodes;

	/* do some housekeeping every 1024 nodes */
	if ((nodes & 1023) == 0)
		checkup();

	pv_length[ply] = ply;

	/* are we too deep? */
	if (ply >= MAX_PLY - 1)
		return eval();
	if (hply >= HIST_STACK - 1)
		return eval();

	/* check with the evaluation function */
	x = eval();
	if (x >= beta)
		return beta;
	if (x > alpha)
		alpha = x;

	gen_caps();
	if (follow_pv)  /* are we following the PV? */
		sort_pv();

	/* loop through the moves */
	for (i = first_move[ply]; i < first_move[ply + 1]; ++i) {
		sort(i);
		if (!makemove(gen_dat[i].m.b))
			continue;
		x = -quiesce(-beta, -alpha);
		takeback();
		if (x > alpha) {
			if (x >= beta)
				return beta;
			alpha = x;

			/* update the PV */
			pv[ply][ply] = gen_dat[i].m;
			for (j = ply + 1; j < pv_length[ply + 1]; ++j)
				pv[ply][j] = pv[ply + 1][j];
			pv_length[ply] = pv_length[ply + 1];
		}
	}
	return alpha;
}


/* reps() returns the number of times that the current
   position has been repeated. Thanks to John Stanback
   for this clever algorithm. */

int reps()
{
	int i;
	int b[64];
	int c = 0;  /* count of squares that are different from
				   the current position */
	int r = 0;  /* number of repetitions */

	/* is a repetition impossible? */
	if (fifty <= 3)
		return 0;

	memset(b, 0, sizeof(b));

	/* loop through the reversible moves */
	for (i = hply - 1; i >= hply - fifty - 1; --i) {
		if (++b[(int)hist_dat[i].m.b.from] == 0)
			--c;
		else
			++c;
		if (--b[(int)hist_dat[i].m.b.to] == 0)
			--c;
		else
			++c;
		if (c == 0)
			++r;
	}

	return r;
}


/* sort_pv() is called when the search function is following
   the PV (Principal Variation). It looks through the current
   ply's move list to see if the PV move is there. If so,
   it adds 10,000,000 to the move's score so it's played first
   by the search function. If not, follow_pv remains FALSE and
   search() stops calling sort_pv(). */

void sort_pv()
{
	int i;

	follow_pv = FALSE;
	for(i = first_move[ply]; i < first_move[ply + 1]; ++i)
		if (gen_dat[i].m.u == pv[0][ply].u) {
			follow_pv = TRUE;
			gen_dat[i].score += 10000000;
			return;
		}
}


/* sort() searches the current ply's move list from 'from'
   to the end to find the move with the highest score. Then it
   swaps that move and the 'from' move so the move with the
   highest score gets searched next, and hopefully produces
   a cutoff. */

void sort(int from)
{
	int i;
	int bs;  /* best score */
	int bi;  /* best i */
	gen_t g;

	bs = -1;
	bi = from;
	for (i = from; i < first_move[ply + 1]; ++i)
		if (gen_dat[i].score > bs) {
			bs = gen_dat[i].score;
			bi = i;
		}
	g = gen_dat[from];
	gen_dat[from] = gen_dat[bi];
	gen_dat[bi] = g;
}


/* checkup() is called once in a while during the search. */

void checkup()
{
	/* is the engine's time up? if so, longjmp back to the
	   beginning of think() */
	if (get_ms() >= stop_time) {
		stop_search = TRUE;
		longjmp(env, 0);
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久久蜜臀图片| a级高清视频欧美日韩| 精品国产一二三区| 色综合天天综合狠狠| 国产一区二区成人久久免费影院| 99久久免费视频.com| 久久激情五月激情| 午夜视频在线观看一区二区| 国产精品蜜臀av| 久久精品视频一区二区| 久久一区二区三区四区| 欧美日韩精品专区| 欧美中文字幕亚洲一区二区va在线 | xf在线a精品一区二区视频网站| 国产综合色视频| 精品一区二区三区免费播放| 欧美aaa在线| 欧美国产欧美综合| 欧美日韩一区二区在线视频| 欧美午夜片在线看| 欧美性大战久久久久久久蜜臀| 蜜桃91丨九色丨蝌蚪91桃色| 日韩国产精品久久| 久热成人在线视频| 国产精品亚洲视频| 亚洲午夜一区二区三区| 偷窥国产亚洲免费视频| 激情五月播播久久久精品| 国产成人综合亚洲网站| 一区二区三区在线高清| 欧美成人女星排名| 欧美国产精品专区| 日韩欧美一卡二卡| 欧美日韩精品高清| 欧美一区二区日韩一区二区| 日韩美女在线视频| 国产精品天天摸av网| 午夜激情一区二区三区| 九色porny丨国产精品| 国产成人亚洲综合a∨婷婷| 波多野结衣视频一区| 欧美妇女性影城| 国产精品国产自产拍高清av王其| 欧美一级二级在线观看| 欧美老年两性高潮| 欧美第一区第二区| 久久久久国产精品人| 亚洲午夜久久久久久久久久久| 久久综合久久99| 天堂影院一区二区| 亚洲欧美一区二区三区国产精品 | 国产清纯美女被跳蛋高潮一区二区久久w| 欧美日韩一区在线观看| 久久久久久久久97黄色工厂| 丝袜脚交一区二区| 99国产精品国产精品久久| 精品国产自在久精品国产| 亚洲成a人片综合在线| 99视频一区二区| www久久久久| 午夜日韩在线电影| eeuss鲁片一区二区三区| 国产综合久久久久久久久久久久| 亚洲综合激情小说| 亚洲视频你懂的| 福利一区福利二区| 亚洲国产中文字幕| 亚洲国产精品v| 777亚洲妇女| 成人综合在线网站| 欧美96一区二区免费视频| 综合色中文字幕| 欧美羞羞免费网站| 麻豆一区二区在线| 亚洲午夜激情网页| 欧美zozozo| 欧洲视频一区二区| 亚洲视频电影在线| 国产欧美一区二区三区鸳鸯浴| 九九精品一区二区| 久久久欧美精品sm网站| 丁香五精品蜜臀久久久久99网站| 久久综合成人精品亚洲另类欧美| 亚洲色图一区二区三区| 欧美探花视频资源| 久久久久97国产精华液好用吗| 精品对白一区国产伦| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 亚洲国产wwwccc36天堂| 国产99久久久国产精品潘金| 精品国产一区二区亚洲人成毛片| 日韩综合小视频| 欧美xxxxxxxxx| 欧美精品在线观看播放| 色欧美乱欧美15图片| 国产成人在线色| 久久99国产乱子伦精品免费| 亚洲一二三专区| 亚洲欧美乱综合| 亚洲区小说区图片区qvod| 91蜜桃网址入口| 99精品视频一区| 日韩精品91亚洲二区在线观看| 91精品婷婷国产综合久久性色 | 日韩视频在线一区二区| 欧美日韩一二三| 欧美电影影音先锋| 欧美久久免费观看| 欧美日韩国产大片| 5月丁香婷婷综合| 欧美日韩另类一区| 国产精品一色哟哟哟| 亚洲h动漫在线| 欧美国产精品一区二区三区| 国产精品色哟哟网站| 欧美日韩亚洲综合| 日韩小视频在线观看专区| 一区二区三区四区不卡在线 | 欧美日韩精品三区| 亚洲欧美在线高清| 一区二区三区四区av| 国产激情精品久久久第一区二区 | 中文字幕制服丝袜一区二区三区| 粉嫩久久99精品久久久久久夜| 精品久久久久久久久久久院品网| 成人精品gif动图一区| 成人天堂资源www在线| 国产成人久久精品77777最新版本| **网站欧美大片在线观看| 欧美一级高清大全免费观看| 色狠狠综合天天综合综合| 日韩精品五月天| 欧美一区二区三区男人的天堂| 国产精品自拍在线| 成人精品小蝌蚪| 99综合电影在线视频| 91久久久免费一区二区| 99精品视频在线观看免费| 欧美日韩一区二区在线观看| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 国产女人aaa级久久久级 | 韩国av一区二区三区四区| 成人丝袜18视频在线观看| 欧美日韩一区三区四区| 久久久亚洲欧洲日产国码αv| 欧美不卡一区二区| 亚洲精品一二三区| 精品一区二区综合| 色综合久久66| 日韩欧美卡一卡二| 一区二区三区中文字幕| 精品在线免费视频| 欧美性videosxxxxx| 久久久久久久久蜜桃| 亚洲国产精品成人综合色在线婷婷| 国产女人水真多18毛片18精品视频| 中文字幕欧美日韩一区| 亚洲bt欧美bt精品777| 成人免费观看视频| 日韩一区二区三区在线视频| 亚洲精品一区二区三区精华液 | 911精品国产一区二区在线| 国产午夜亚洲精品午夜鲁丝片| 国产人成亚洲第一网站在线播放| 国产精品美女久久久久aⅴ国产馆| 国产精品麻豆欧美日韩ww| 六月丁香婷婷色狠狠久久| 91香蕉视频污| 亚洲国产精品黑人久久久| 一区二区三区不卡视频在线观看 | 亚洲日本va午夜在线电影| 老司机精品视频在线| 国产激情视频一区二区在线观看| 波多野结衣亚洲一区| 久久亚洲一区二区三区明星换脸| 亚洲国产成人私人影院tom| 久久狠狠亚洲综合| 69堂精品视频| 亚洲第一在线综合网站| 99re这里只有精品视频首页| 久久综合视频网| 日本欧美一区二区三区| 91福利区一区二区三区| 国产精品久久午夜| 国产美女精品一区二区三区| 日韩精品一区二区三区中文精品| 亚洲国产精品v| 粉嫩av一区二区三区| 日本一二三不卡| 国产精品99久久久久久久vr| 欧美xxx久久| 韩国欧美国产1区| 久久一区二区视频| 国产精品一级片在线观看| 欧美一区二区三区免费| 日本不卡123| 久久影院午夜片一区| 精品午夜久久福利影院| 欧美成人性战久久| 亚洲区小说区图片区qvod|