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

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

?? model.cpp

?? c+++ game uploading now
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/**
 @file
 Code for search routines, algortihms such as alpha-beta, iterative 
 deepening, MTD(f) and so on.
*/

#include <ctime>
#include <cstdlib>
#include "Model.h"
#include "Boards.h"
#include "MoveExecuter.h"
#include "MoveListGenerator.h"


using namespace Othello;

namespace Othello
{
    /** the board used during search */ 
    Board actualb;
    /** the current board's representation in a TT entry format */
    TTBoard actualbtt;
}

//DEBUG
unsigned int Othello::Count(squarevalue p)
{
    int ret=0;
    for(unsigned int i=p11; i<s89; i++)
        if(actualb.table[i]==p)
            ret++;
    return ret;
}

void Thinker::ResetGame()
{
    actualb.InitBoard();
    actualb.Syncronize();
    newBoard=actualb;
    gamevalue=0;
    bestMove=-1; //??
    _lastbestMove=-1; //??
    _ttable.FreeAll();
    _hheuristic.Reset();
    _stop=noStop;
    posSearched=0;
    ttHits=0;
    ttGHits=0;
    nrMoves=0;
    IdDepth=0;
    _thinking=false;
    timedout=false;
    _book.Reset(actualb);
    _avaible_time=_init_totaltime;
}

void Thinker::InitBoards()
{
    assert(sizeof(TTBoard)==8);
    actualb=newBoard;
    actualbtt.isblacksturn=actualb.isblacksturn;

    posSearched=0;
    ttHits=0;
    ttGHits=0;

    HistoryHeuristic::Instance().Reset();
    actualb.hash32=_ttable.Key32(actualb);
    actualbtt.SetLock32(_ttable.Lock32(actualb));
    actualb.Syncronize();

    _isdoublemove=false;
    _stop=noStop;
}

void Thinker::Stop()
{ 
    _stop=guiBreak;
}

Thinker::Thinker(HWND hwnd)
    :_hwnd(hwnd),
     _avaible_time(0),
     _init_totaltime(0),
     timedout(false),
     _timescheduler(_avaible_time, _init_totaltime, timedout)
{
    ResetGame();
}

Thinker::~Thinker()
{
    Kill();
}


void Thinker::Go()
{
    _event.GreenLight();
    _stop=noStop;
}

//!!!!!!!!!same o same!!!!!!!!!!!!!
void Thinker::FlushThread()
{
    _event.GreenLight();
}

void Thinker::Run()
{
    for(;;)
    {
        _thinking=false;
        _event.Wait();
        _thinking=true;
        if(_isDying)
            return;
        InitBoards();
        try
        {
            Think();
        }
        catch(STOP &stop)
        {
            //if this was a GUI request without further commands 
            //then block and wait until GUI makes a reset!
            if(stop.IsGuiBreak())
            {
                _event.RedLight();
            }
            else
                //otherwise (we had a timeout or a forced stop so send results)
                if(stop.IsForceMove() || stop.IsTimeOut())
                {
                    bestMove=_lastbestMove;
                    _timescheduler.AdjustElapsed();
                    DispatchResultsToGui();
                }
            continue;
        }
        DispatchResultsToGui();
    }
}

void Thinker::Force_Stop()
{
    _stop=forceMove;
}


/*MSC confuses std::max and std::min with his own macros
  so I'll the standard ones only on a less deviant compiler.*/
#if !defined _MSC_VER
#include <algorithm>
using std::max;
using std::min;
#endif



//TODO draw is not handled correctly
//alpha is redundant, this function is intended to be used
//exclusevly with null windows. What a mess!
int Thinker::AlphaBeta(int alpha, int beta, unsigned int depth)
{
    assert(actualb.AssertIsInSync());
    assert(actualb.hash32==_ttable.Key32(actualb));
    posSearched++;

    if(depth==0)
        return evaluator.Evaluate();

    bool leave=false;
    //DEBUG
    assert(depth<=MAXDEPTH);
    
    //current board value
    int g;

    //client peak
    if(_stop!=noStop)
        throw STOP(_stop);
     
    //try to retrive current board from transposition table
    TTBoard *prev=_ttable.Retrieve(); //TODO prev is not used properly
    
    if(prev==NULL)
        actualbtt.Clean();
    else
    {   
        //extract moveinfo
        actualbtt= *prev;

        ttHits++;
        assert((prev->GetDepth()!=0));
        
        //if we are in the same depth then extract game
        //values and use them ???????????
        //(prev->GetDepth()>=depth) seems more logical but if we will fail high using
        //deeper values then there is a chance that when doing the research this value 
        //will no longer be avaible. 
        if(prev->GetDepth()==depth)
        {
            //ttGHits++;
            if(prev->LowerBound() >= beta)
            {
                ttGHits++;
                return prev->LowerBound();
            }
            if(prev->UpperBound() <= alpha)
            {
                ttGHits++;
                return prev->UpperBound();
            }
        }
    }

#if defined _ENDGAME_TEST_
    if(actualb.CountEmpty()<9 && depth<=4 && IdDepth>4)
        return endgame.Solve(alpha, beta, posSearched);
#endif //_ENDGAME_TEST_

    bool hasBestMove=false;

    assert(depth!=0);
    //save alpha, beta (for TT stuff)
    int a=alpha;
    int b=beta;
    
    //generate moves
    MoveListGenerator moves(depth, prev!=NULL );
    if(moves.Empty())
    {   
        leave=true;
        g=evaluator.Evaluate();
    }
    else
    {
        UndoData udata;
        //MAX player (black)
        if(actualb.isblacksturn)
        {
            //at max player, the value of the node increases
            g=-infinity;
            while(g<beta)
            {
                if(!moves.AtEnd()) //!!! exec must have preccisely this scope!!!
                {
                    FullMoveExecuter exec(moves.X(), udata, moves.Dir());
                    //yap we are maximizing
                    int tmp=AlphaBeta(a, beta, depth-1);
                    //did we found a better move?, if yes then update bestmove info
                    if(g<tmp)
                    {
                        exec.MarkAsBestMove();
                        hasBestMove=true;
                        g=tmp;
                    }
                    //and tigthening bounds for the min player
                    a=max(a, g); //TODO can I place this line elsewhere?
                }
                else break;
                //if we allready have a cutoff then avoid further move genration
                if(g<beta)
                    moves.Step(); 
                else break; 
            }
        }
        //MIN player (white)
        else
        {
            //values for min player get smaller
            g=+infinity;
            while(g>alpha)
            {
                if(!moves.AtEnd()) //!!! exec must have preccisely this scope!!!
                {
                    FullMoveExecuter exec(moves.X(), udata, moves.Dir());
                    //this is what min does
                    int tmp=AlphaBeta(alpha, b, depth-1);
                    if(g>tmp)
                    {
                        exec.MarkAsBestMove();
                        hasBestMove=true;
                        g=tmp;
                    }   
                    //tigthen bound for max player
                    b=min(b, g);
                }
                else break;
                //if we allready have a cutoff then avoid further move genration
                if(g>alpha)
                    moves.Step();
                else break;
            }
        }
    } //we had some moves

    /*mark boounds*/
    //leaves always have "exact" value
    if(leave)
        actualbtt.SetExact(g, depth);
    //if failing high then we got a lower bound
    else if(g>=beta)
             actualbtt.SetLowerBound(g, depth);
         //we are failing low ==>> got an upper bound //NOTE beta-alpha==1 no chance for success 
         else 
             actualbtt.SetUpperBound(g, depth);

    //update history heuristic info and store results
    if(hasBestMove)
    {
        _hheuristic.GoodMove(actualbtt.BestMove(), actualb.isblacksturn, depth);
        _ttable.Store();
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合一区二区三区| 日韩和欧美一区二区三区| 97精品国产露脸对白| 亚洲天堂成人网| 91国产精品成人| 午夜精品久久久久久久久久| 在线成人免费观看| 久久er99热精品一区二区| 国产日韩欧美高清在线| av成人免费在线观看| 亚洲国产精品天堂| 26uuu精品一区二区| 成人av在线播放网站| 亚洲1区2区3区视频| 精品国产免费人成在线观看| 成人精品高清在线| 亚洲成人动漫精品| 久久夜色精品一区| 91免费版pro下载短视频| 丝袜亚洲另类欧美| 国产欧美一区二区三区沐欲| 日本电影欧美片| 久久激情五月激情| 椎名由奈av一区二区三区| 欧美福利视频一区| 春色校园综合激情亚洲| 丝袜美腿成人在线| 欧美激情一区二区三区蜜桃视频 | 午夜精品久久久久久久99樱桃| 日韩欧美三级在线| 91免费看片在线观看| 另类小说色综合网站| 亚洲欧美日韩一区二区三区在线观看| 91精品国产综合久久香蕉麻豆| 懂色av中文字幕一区二区三区 | 免费国产亚洲视频| 亚洲同性同志一二三专区| 日韩精品中文字幕在线不卡尤物| 不卡一区二区中文字幕| 蜜臀av在线播放一区二区三区| 国产精品国产精品国产专区不片| 欧美一区二区三区人| 91成人看片片| 成人av电影在线网| 狠狠色丁香久久婷婷综| 午夜精品一区二区三区免费视频| 国产精品二三区| 久久久不卡影院| 91精品国产色综合久久不卡电影 | 91在线观看污| 国精产品一区一区三区mba桃花 | 另类人妖一区二区av| 一区av在线播放| 亚洲欧洲精品一区二区精品久久久 | 久久激情五月激情| 天天av天天翘天天综合网色鬼国产| 国产精品超碰97尤物18| 国产女人18毛片水真多成人如厕| 日韩欧美另类在线| 日韩欧美一区二区不卡| 欧美日本国产一区| 91久久线看在观草草青青 | 91性感美女视频| 成人精品国产一区二区4080| 国产成人精品综合在线观看 | 日本va欧美va欧美va精品| 依依成人精品视频| 亚洲一区二三区| 亚洲女厕所小便bbb| 最新中文字幕一区二区三区 | 亚洲综合清纯丝袜自拍| 亚洲蜜臀av乱码久久精品| 中文字幕一区不卡| 国产精品久久久久久久久图文区| 亚洲国产精华液网站w| 国产精品系列在线| 中文字幕乱码日本亚洲一区二区| 国产免费观看久久| 亚洲欧洲色图综合| 一区二区三区四区蜜桃| 午夜精品国产更新| 美女精品一区二区| 国产精品一区二区视频| 99国产精品久久久久久久久久久 | 欧美探花视频资源| 欧美视频日韩视频| 91精品国产91久久综合桃花| 日韩欧美高清一区| 日本一区二区三区在线观看| 国产精品国产三级国产aⅴ无密码| 亚洲精选视频在线| 天堂成人国产精品一区| 国产一区不卡在线| 99久久精品免费观看| 欧美午夜电影网| 精品99一区二区| 亚洲欧洲成人精品av97| 亚洲午夜电影在线观看| 理论片日本一区| 国产99久久精品| 色婷婷久久综合| 日韩欧美综合一区| 国产精品欧美综合在线| 亚洲一区二区四区蜜桃| 日本欧美久久久久免费播放网| 国产精品一区在线观看你懂的| 91蜜桃视频在线| 日韩精品中文字幕一区| ㊣最新国产の精品bt伙计久久| 日韩在线播放一区二区| 不卡一区二区在线| 欧美一区二区视频在线观看2020| 国产精品入口麻豆原神| 亚洲国产欧美在线| 国产成人精品www牛牛影视| 精品视频免费看| 欧美韩日一区二区三区四区| 亚洲va韩国va欧美va| 成人久久久精品乱码一区二区三区| 在线免费不卡视频| 国产欧美中文在线| 爽好久久久欧美精品| 9i看片成人免费高清| 日韩欧美另类在线| 艳妇臀荡乳欲伦亚洲一区| 国产一区二区h| 9191成人精品久久| 亚洲免费看黄网站| 风间由美一区二区av101| 欧美另类一区二区三区| 日韩一区在线看| 国产一区二区三区久久悠悠色av | 秋霞午夜av一区二区三区| caoporen国产精品视频| 精品欧美乱码久久久久久| 一区二区三区免费在线观看| 成人国产精品免费| 久久免费午夜影院| 久久国产精品99久久久久久老狼 | 91久久精品日日躁夜夜躁欧美| 精品成人免费观看| 日本不卡视频在线| 精品视频免费看| 亚洲资源在线观看| 91麻豆国产福利在线观看| 中文字幕精品在线不卡| 国产一区二区三区免费在线观看 | 成人美女视频在线观看18| 欧美成人激情免费网| 日韩在线一二三区| 欧美日韩在线观看一区二区| 亚洲欧美电影院| 色综合亚洲欧洲| 亚洲精品乱码久久久久久 | 欧美日韩性生活| 一区二区三区日韩在线观看| 91在线免费视频观看| 1024精品合集| 色欧美日韩亚洲| 亚洲色图一区二区| 色婷婷av一区| 亚洲第一福利一区| 欧美日韩精品一区二区在线播放| 亚洲一区在线电影| 精品视频123区在线观看| 亚洲观看高清完整版在线观看| 在线免费视频一区二区| 亚洲小说欧美激情另类| 欧美人与性动xxxx| 免费看欧美美女黄的网站| 精品久久久久99| 国产黄色91视频| 国产精品卡一卡二卡三| 99视频一区二区| 亚洲一区二区三区影院| 欧美精品v日韩精品v韩国精品v| 视频一区在线视频| 精品国产伦一区二区三区观看方式| 久久91精品国产91久久小草 | 91小视频在线免费看| 艳妇臀荡乳欲伦亚洲一区| 在线不卡免费av| 国内精品国产三级国产a久久| 精品成a人在线观看| 99国产精品久久久久久久久久 | 亚洲国产综合在线| 日韩亚洲欧美高清| 国产精品一品视频| 亚洲桃色在线一区| 欧美日韩精品一区二区三区| 久久爱另类一区二区小说| 国产精品久久久久桃色tv| 在线观看亚洲专区| 爽好久久久欧美精品| 国产日韩av一区| 在线视频国内一区二区| 精品一区二区三区蜜桃| 国产精品污网站| 欧美日韩aaa| 丁香网亚洲国际|