当前位置: 首页>>代码示例>>C++>>正文


C++ MakeMove函数代码示例

本文整理汇总了C++中MakeMove函数的典型用法代码示例。如果您正苦于以下问题:C++ MakeMove函数的具体用法?C++ MakeMove怎么用?C++ MakeMove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MakeMove函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    char inbuf[256];
    char playerstring[1];
    int X,Y;

    turn = 0;
    fgets(inbuf, 256, stdin);
    if (sscanf(inbuf, "game %1s %d %d %d", playerstring, &depthlimit,
                &timelimit1, &timelimit2) != 4) error("Bad initial input");
    if (timelimit2 != 0) timelimit1 = timelimit2 / 64;
    if (timelimit1 == 0 && depthlimit == 0) depthlimit = 4;

    if (playerstring[0] == 'B') me = 1; else me = -1;
    NewGame();
    if (me == 1) MakeMove();
    while (fgets(inbuf, 256, stdin)!=NULL){
        if (strncmp(inbuf,"pass",4)!=0) {
            if (sscanf(inbuf, "%d %d", &X, &Y) != 2) return 0;
            Update(gamestate, -me, X, Y);
            if (debug) printboard(gamestate, -me, ++turn, X, Y);
        }
        MakeMove();
    }
    return 0;
}
开发者ID:jeremywrnr,项目名称:cxref.rb,代码行数:26,代码来源:windows.c

示例2: MakeMove

/* 370 */
instruction      *rUSEREGISTER( instruction *ins )
/************************************************/
{
    instruction         *new_ins;
    instruction         *ins2;
    name                *name1;

    name1 = ins->operands[0];
    if( CanUseOp1( ins, name1 ) ) {
        new_ins = MakeMove( name1, ins->result, ins->type_class );
        ins->result = name1;
        MoveSegRes( ins, new_ins );
        SuffixIns( ins, new_ins );
        new_ins = ins;
    } else {
        name1 = AllocTemp( ins->type_class );
        new_ins = MakeMove( ins->operands[0], name1, ins->type_class );
        CheckCC( ins, new_ins );
        ins->operands[0] = name1;
        MoveSegOp( ins, new_ins, 0 );
        PrefixIns( ins, new_ins );
        ins2 = MakeMove( name1, ins->result, ins->type_class );
        ins->result = name1;
        MoveSegRes( ins, ins2 );
        SuffixIns( ins, ins2 );
        MarkPossible( ins, name1, ResultPossible( ins ) );
        ins->u.gen_table = NULL;
        GiveRegister( NameConflict( ins, name1 ), true );
    }
    return( new_ins );
}
开发者ID:joncampbell123,项目名称:open-watcom-v2,代码行数:32,代码来源:split.c

示例3: AddIns

name    *StReturn( an retval, type_def *tipe, instruction **pins )
/****************************************************************/
{
    name        *retp;
    name        *ptr;
    name        *off;
    name        *seg;
    hw_reg_set  reg;

    if( CurrProc->state.attr & ROUTINE_ALLOCS_RETURN ) {
        retp = CurrProc->targ.return_points;
        AddIns( MakeUnary( OP_LA, retp, AllocRegName( CurrProc->state.return_reg ), WD ) );
        *pins = NULL;
    } else {
        if( _IsTargetModel( FLOATING_SS ) || _IsTargetModel( FLOATING_DS ) ) {
            ptr = AllocTemp( CP );
            off = OffsetPart( ptr );
            seg = SegmentPart( ptr );
            AddIns( MakeMove( AllocRegName( HW_SS ), seg, U2 ) );
        } else {
            ptr = AllocTemp( WD );
            off = ptr;
        }
        AddIns( MakeMove( CurrProc->targ.return_points, off, WD ) );
        retp = SAllocIndex( ptr, NULL, 0, TypeClass( retval->tipe ), tipe->length );
        reg = ReturnReg( WD, false );
        *pins = MakeMove( CurrProc->targ.return_points, AllocRegName( reg ), WD );
        CurrProc->state.return_reg = reg;
    }
    return( retp );
}
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:31,代码来源:x86call.c

示例4: PGNReadFromFile

void PGNReadFromFile (const char *file)
/****************************************************************************
 *
 *  To read a game from a PGN file.
 *
 ****************************************************************************/
{
   FILE *fp;
   char s[100], c, wmv[8], bmv[8];
   int moveno;
   leaf *p;

   fp = fopen (file, "r");
   if (fp == NULL)
   {
      printf ("Cannot open file %s\n", file);
      return;
   }

   /* Skip all the tags */
   do
   {
      if ((c = fgetc (fp)) == '[')
         fgets (s, 100, fp);
   } while (c == '[');
   ungetc (c, fp);

   InitVars ();
   while (!feof (fp))
   {
      c = fgetc(fp);
      if (c == '*') break;
      ungetc (c, fp);
      fscanf (fp, "%d. %7s %7s ", &moveno, wmv, bmv);
      p = ValidateMove (wmv);
      if (!p)
      {
	 printf ("Illegal move %d. %s\n", moveno, wmv);
	 break;
      }
      MakeMove (white, &p->move);
      strcpy (Game[GameCnt].SANmv, wmv);
      if (*bmv == '*' ) break;
      p = ValidateMove (bmv);
      if (!p)
      {
	 printf ("Illegal move %d. ... %s\n", moveno, bmv);
	 break;
      }
      MakeMove (black, &p->move);
      strcpy (Game[GameCnt].SANmv, bmv);
   }
   printf ("%d\n", GameCnt);
   fclose (fp);
   ShowBoard ();
   TTClear ();
   return;
}
开发者ID:troygnichols,项目名称:Chessoid,代码行数:58,代码来源:pgn.c

示例5: AutoMove

void
AutoMove(int From, int To, int Num)
{

	if(Num == 1) {
		MakeMove(From, To);
		return;
	}
	AutoMove(From, OTHER(From, To), Num-1);
	MakeMove(From, To);
	AutoMove(OTHER(From, To), To, Num-1);
}
开发者ID:GalaxyTab4,项目名称:workbench,代码行数:12,代码来源:hanoi.c

示例6: AutoMove

static void
AutoMove(int From, int To, int Num)
{
    if (Num == 1) {
	MakeMove(From, To);
	napms(500);
    } else {
	AutoMove(From, OTHER(From, To), Num - 1);
	MakeMove(From, To);
	napms(500);
	AutoMove(OTHER(From, To), To, Num - 1);
    }
}
开发者ID:chitranshi,项目名称:ncurses,代码行数:13,代码来源:hanoi.c

示例7: CheckOp

static  void    CheckOp( name **offsets, instruction *ins, name **pop ) {
/************************************************************************
    used by FixFarLocalRefs to change one far local reference to
    an index, using the appropriate multiple of 4K constant to get
    at the temporary. The constant values are adjusted after the
    prolog is generated.
*/

    name        *op;
    name        *base;
    name        *temp;
    unsigned_32 place;
    int         i;
    instruction *new_ins;

    op = *pop;
    if( op->n.class == N_INDEXED ) {
        temp = op->i.index;
        if( temp->n.class != N_TEMP ) return;
        if( !( temp->t.temp_flags & FAR_LOCAL ) ) return;
        new_ins = MakeMove( temp, AllocTemp( temp->n.name_class ), temp->n.name_class );
        *pop = ScaleIndex( new_ins->result, op->i.base,
                          op->i.constant, op->n.class, op->n.size,
                          op->i.scale, op->i.index_flags );
        PrefixIns( ins, new_ins );
        CheckOp( offsets, new_ins, &new_ins->operands[ 0 ] );
    }
    if( op->n.class != N_TEMP ) return;
    if( !( op->t.temp_flags & FAR_LOCAL ) ) return;
    base = DeAlias( op );
    place = base->t.location + ( op->v.offset - base->v.offset );
    i = place/_4K;
    if( offsets[ i ] == NULL ) {
        /*set the symbol field in the AddrConst to non-NULL for score-boarder*/
        new_ins = MakeMove( AllocAddrConst( (name *)&CurrProc, i,
                                            CONS_OFFSET, WD ),
                        AllocTemp( WD ), WD );
        offsets[ i ] = new_ins->result;
        PrefixIns( HeadBlock->ins.hd.next, new_ins );
    }
    temp = AllocTemp( WD ),
    new_ins = MakeMove( offsets[ i ], temp, WD );
    PrefixIns( ins, new_ins );
    new_ins = MakeBinary( OP_ADD, temp, AllocRegName( DisplayReg() ), temp, WD);
    PrefixIns( ins, new_ins );
    *pop = ScaleIndex( temp, op, place%_4K,
                        op->n.name_class, op->n.size, 0, X_FAKE_BASE );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:48,代码来源:s37temps.c

示例8: MakeStepListForWin

/**
 * MakeStepListForWin - 致胜招法生成器
 * @myInfo:		执棋方当前局面综合信息
 * @denInfo:	对方当前局面综合信息
 * @limit:		生成着法的数量限制
 * @return:		返回着法列表
 */
vector<Step> MakeStepListForWin(int side, unsigned int limit)
{
	SynInfo myInfo = GetBoardInfo(side, TOWIN | TOWILLWIN);
	LineInfo tempLine[2][4];//临时线信息备份
	Step tempStep;
	vector<Point>::iterator iterP, iterP2;
	vector<Step> stepList;//招法列表

	//如果存在致胜点,则直接返回第一个制胜点作为招法
	//否则选取第一个即将致胜点进行试下,并用其余试下后的第一个致胜点进行组步
	if (myInfo.winList.size() == 0)
	{
		tempStep.second = myInfo.willWinList[0];
		MakeMove(tempStep.second, tempLine, side, TOWIN);//因为必胜,故只对致胜点进行收集
		myInfo = GetBoardInfo(side, TOWIN);
		BackMove(tempStep.second, tempLine, side);
	}
	else
	{
		tempStep.second.x = tempStep.second.y = -1;
	}
	tempStep.first = myInfo.winList[0];
	tempStep.value = WINLOSE;
	stepList.push_back(tempStep);
	return stepList;
}
开发者ID:ifplusor,项目名称:sixgo,代码行数:33,代码来源:StepGenerator.cpp

示例9: NEEDS_SEGMENT_SPLIT

extern  instruction     *NeedIndex( instruction *ins ) {
/*******************************************************
    Mark conflicts for any name used in instruction as as segment as
    NEEDS_SEGMENT, or split out the segment if it is marked as
    NEEDS_SEGMENT_SPLIT (move the segment operand to a temp and use the
    temp as the segment override).  Also, if any index conflicts are
    marked as NEEDS_INDEX_SPLIT, split them out into a temp as well.
*/

    name                *temp;
    name                *index;
    conflict_node       *conf;
    name                *name;

    if( ins->num_operands > NumOperands( ins ) ) {
        name = ins->operands[ins->num_operands - 1];
        conf = NameConflict( ins, name );
        if( conf != NULL && _Isnt( conf, CST_NEEDS_SEGMENT_SPLIT ) ) {
            _SetTrue( conf, CST_NEEDS_SEGMENT );
            MarkSegment( ins, name );
        } else if( name->n.class != N_REGISTER ) {
            if( conf != NULL ) {
                _SetFalse( conf, CST_NEEDS_SEGMENT );
                _SetTrue( conf, CST_WAS_SEGMENT );
            }
            temp = AllocTemp( U2 );
            ins->operands[ins->num_operands - 1] = temp;
            PrefixIns( ins, MakeMove( name, temp, U2 ) );
            MarkSegment( ins, temp );
            _SetTrue( NameConflict( ins, temp ), CST_SEGMENT_SPLIT );
            ins = ins->head.prev;
        }
    }
开发者ID:bhanug,项目名称:open-watcom-v2,代码行数:33,代码来源:i86index.c

示例10: MakeMove

/*
因为没有传入side参数,因此只适合计算黑子的策略
*/
int NegaMaxEngine::NegaMax(int depth)
{
	int bestScore = -INFINITY;
	int side = (m_nSearchDepth - depth)%2;
	int childNodeCount, score;

	if(depth <= 0)
	{
		return m_pEval->Evaluate(CurPosition, side);
	}
	childNodeCount = m_pMG->CreatePossibleMove(CurPosition, depth , side);
	if(childNodeCount <= 0) return NOMORE_MOVE;
	for(int i=0; i<childNodeCount; ++i)
	{
		MakeMove(&m_pMG->m_MoveList[depth][i], side);
		score = -NegaMax(depth  -1);
		UnMakeMove(&m_pMG->m_MoveList[depth][i]);
		if(score > bestScore)
		{
			bestScore = score;
			if(depth == m_nSearchDepth)
			{
				m_cmBestMove = m_pMG->m_MoveList[depth][i];
			}
		}
	}
	return bestScore;
}
开发者ID:renshengqiang,项目名称:GameCenter,代码行数:31,代码来源:NegaMax.cpp

示例11: PerftTest

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);
}
开发者ID:peterwankman,项目名称:vice,代码行数:29,代码来源:perft.c

示例12: IsGameOver

int CAlphaBetaEngine::alphabeta(int depth, int alpha, int beta)
{
	int score;
	int Count,i;
	BYTE type;

	i = IsGameOver(CurPosition, depth);
	if (i != 0)
		return i;

	if (depth <= 0)	//叶子节点取估值
		return m_pEval->Eveluate(CurPosition, (m_nMaxDepth-depth)%2);
	
	Count = m_pMG->CreatePossibleMove(CurPosition, depth, (m_nMaxDepth-depth)%2);

	for (i=0;i<Count;i++) 
	{

		type = MakeMove(&m_pMG->m_MoveList[depth][i]);
		score = -alphabeta(depth - 1, -beta, -alpha);
		UnMakeMove(&m_pMG->m_MoveList[depth][i],type); 

		if (score > alpha)
		{
			alpha = score;
			if(depth == m_nMaxDepth)
				m_cmBestMove = m_pMG->m_MoveList[depth][i];
		}
        if (alpha >= beta) 
              break;

				
	}
	return alpha;
}
开发者ID:yangxuanxc,项目名称:AIHomework,代码行数:35,代码来源:AlphaBetaEngine.cpp

示例13: if

// During idle time make random moves if Random! has been selected
void SimpleGoPanel::Idle(wxIdleEvent& event)
{	if(!frame->playmenu->IsChecked(ID_RANDOM))
	{	if(!gnugopause && ((curmove%2==1 && frame->whitelevel>0) || (curmove%2==0 && frame->blacklevel>0)))
			frame->MakeGNUGoMove();
		return;
	}

	int x = 1+rand()%boardsize, y = 1+rand()%boardsize;
	char attempts[21][21], temp[21][21];
	memset(attempts, 0, BOARDMEMORYLEN);
	int count = 0;
	while(count<boardsize*boardsize)
	{	while(attempts[x][y]==1)
		{	x = 1+rand()%boardsize;
			y = 1+rand()%boardsize;
		}
		memcpy(temp, board, BOARDMEMORYLEN);
		if(ValidMove(temp, x, y, curmove%2+1))
		{	MakeMove(x, y);
			#ifdef __WXMSW__
			event.RequestMore();
			#endif
			return;
		}
		count++;
		attempts[x][y] = 1;
	}

	MakePass();
	#ifdef __WXMSW__
	event.RequestMore();
	#endif
}
开发者ID:curtisbright,项目名称:simplego,代码行数:34,代码来源:simplego-panel.cpp

示例14: SelfPlay

void SelfPlay()
{
	printf("\n\n--------------The Bot Will Now Play itself to Some Randomized Depth-------------\n\n");
	printf("Press Any Key To See The Next Move\n");
	BOARD *board=new BOARD;
	SetStart(board);
	getchar();
	while(1)
	{
		MOVE *list=new MOVE;
		GenMoves(board,list);
		if(list->Count==0)
		{
			printf("%c LOST THE GAME\n\n",PceSideChar[board->Side]);
			break;
		}
		int Depth=5+rand()%4;
		vector<int>BestMove=SearchPos(board,Depth);
		PrintBoard(board);
		MakeMove(board,BestMove);
		getchar();
		getchar();
	}
	StartGame();
}
开发者ID:justcode21,项目名称:CHECKERS-ENGINE,代码行数:25,代码来源:Playgame.cpp

示例15: DrawMove

static int DrawMove(BOARD *board, MOVE move)
{
  MakeMove(board, &move);
  int draw = AssessDraw(board, 0);
  Takeback(board, move);
  return draw != ERRORVALUE;
}
开发者ID:raimarHD,项目名称:lcec,代码行数:7,代码来源:search.c


注:本文中的MakeMove函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。