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


C++ Chess类代码示例

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


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

示例1: main

int main(int argc, char *argv[]) {
    if (argc > 1) {
        if (strcmp(argv[1], "0") == 0) {
            test_speed();
        } else if (strcmp(argv[1], "1") == 0) {
            test();
        } else if (strcmp(argv[1], "2") == 0) {
            test_perft_startpos(4);
            test_perft();
        } else if (strcmp(argv[1], "3") == 0) {
            test_bratko_kopec();
        } else if (strcmp(argv[1], "4") == 0) {
            test_mate_in_2();
            test_eval_depth_1();
            test_eval_depth_2();
        }
    } else {
        // Start here
        // Waiting for GUI
        char *ret;
        char input[1001];
        while (1) {
            ret = fgets(input, 1000, stdin);
            if (ret && strstr(input, "uci")) {
                break;
            }
        }
        Chess chess;
        Util::open_debug_file();
        chess.sort_alfarray = true;
        chess.start_game();
        chess.processCommands(input);
    }
}
开发者ID:zfazek,项目名称:FZChess,代码行数:34,代码来源:main.cpp

示例2: Board

Board* Board::ReplacePlayers(Player* player1, Player* player2)
{
    Board* board = new Board();
    Chess* piece;
    Player* player;
    
    for (int i = 0; i < pp9k::BoardSize; i++)
    {
        for (int j = 0; j < pp9k::BoardSize; j++)
        {
            piece = this->Chesses[i + j * pp9k::BoardSize];
            if (piece == NULL)
            {
                board->Chesses[i + j * pp9k::BoardSize] = NULL;
            }
            else
            {
                player = piece->GetPlayer()->GetSide() == White ? player1 : player2;
                board->Chesses[i + j * pp9k::BoardSize] = piece->ReplacePlayer(player);
            }
        }
    }
    
    board->Confirmed = this->Confirmed;
    board->Turn = this->Turn;
    
    return board;
}
开发者ID:Martin1994,项目名称:pp9k,代码行数:28,代码来源:Board.cpp

示例3: startClient

void SceneGame::startClient(Ref* sender)
{
	MenuItem* item = (MenuItem*)sender;
	item->setEnabled(false);

	Ref* obj = item->getUserObject();
	item = (MenuItem*)obj;
	item->setEnabled(false);


	_bRedSide = false;
	if (NetBattle::Connect("127.0.0.1"))
	{
	
		cocos2d::log("client Start Game");

		
		for (int i = 0; i < 32; i++)
		{
			Chess* s = _c->at(i);
			s->_row = 9 - s->_row;
			s->_col = 8 - s->_col;
			s->setPosition(s->fromPlate());
		}

		
		NetBattle::RecvStart();
		schedule(schedule_selector(SceneGame::CheckRecv));
	}
	else
	{
		cocos2d::log("Connect failure....");
	}
}
开发者ID:Gaddient,项目名称:Chess,代码行数:34,代码来源:SceneGame.cpp

示例4: restartInit

void SceneGame::restartInit()
{
	// init Chess
	for (int i = 0; i < 32; ++i)
	{
		_c->at(i)->initChess(i, true);
	}

	if (!_bRedSide)
	{
		
		for (int i = 0; i < 32; i++)
		{
			Chess* s = _c->at(i);
			s->_row = 9 - s->_row;
			s->_col = 8 - s->_col;
			s->setPosition(s->fromPlate());
		}

	
		NetBattle::RecvStart();
		schedule(schedule_selector(SceneGame::CheckRecv));
	}

	_selectSprite->setOpacity(0);
	_selectid = -1;
	_bRedTurn = true;
	_steps->clear();

}
开发者ID:Gaddient,项目名称:Chess,代码行数:30,代码来源:SceneGame.cpp

示例5: doRegret

void SceneGame::doRegret()
{
	
	if (_steps->size() == 0)
		return;

	
	Step* step = *_steps->rbegin();
	_steps->pop_back();

	Chess* s = _c->at(step->moveid);
	s->_row = step->rowFrom;
	s->_col = step->colFrom;
	s->setPosition(s->fromPlate());

	Chess* kill;
	if (step->killid != -1)
	{
		kill = _c->at(step->killid);
		kill->_dead = false;
		kill->setVisible(true);
	}

	_bRedTurn = !_bRedTurn;
	delete step;

	
	_selectid = -1;
	_selectSprite->setVisible(false);
}
开发者ID:Gaddient,项目名称:Chess,代码行数:30,代码来源:SceneGame.cpp

示例6: judgeVictory

//每当落子后,判断胜负
bool ChessBoard::judgeVictory(Chess& lastchess)
{
    int row = lastchess.getRow();
    int column = lastchess.getColumn();
    int type = lastchess.getChessType();

    //垂直方向
    if(fiveInDirection(row, column, type, VERTICAL))
    {
        return VICTORY;
    }
    //水平方向
    if(fiveInDirection(row, column, type, HORIZON))
    {
        return VICTORY;
    }
    //右斜方向
    if(fiveInDirection(row, column, type, RIGHT))
    {
        return VICTORY;
    }
    //左斜方向
    if(fiveInDirection(row, column, type, LEFT))
    {
        return VICTORY;
    }

    return CONTINUE;
}
开发者ID:babyfacebook,项目名称:FiveChess-1,代码行数:30,代码来源:chessboard.cpp

示例7: Moves

bool Board::IsCheck(Color side)
{
    Moves* moves = new Moves();
    
    int j = 0;
    for (int i = 0; i < BoardSize * BoardSize; i++)
    {
        if (this->Chesses[i] != NULL && this->Chesses[i]->GetPlayer()->GetSide() == side)
            this->Chesses[i]->GetAvailableMoves(this, moves, true);
        for (; j < moves->GetLength(); j++)
        {
            Move* move = moves->GetMove(j);
            Chess* captured = move->GetChessCaptured();
            if (captured != NULL && captured->GetChessType() == King)
            {
                delete moves;
                
                return true;
            }
        }
    }
    delete moves;
    
    return false;
}
开发者ID:Martin1994,项目名称:pp9k,代码行数:25,代码来源:Board.cpp

示例8: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Chess w;
    w.show();

    return a.exec();
}
开发者ID:S0mas,项目名称:ChessNew,代码行数:8,代码来源:main.cpp

示例9: reset

void reset() {
	int remStep=step;
	Chess chess;
	for(int i = 1; i <= remStep; i++) {
		chess.DelMove();
	}

}
开发者ID:ChisBread,项目名称:wine,代码行数:8,代码来源:pbrain-wine.cpp

示例10: setOneChess

//指定一个棋子
void ChessBoard::setOneChess(Chess chess)
{
    int row = chess.getRow();
    int column = chess.getColumn();

    this->chessboardmat[row][column] = chess.getChessType();

    steps.push_back(chess);
}
开发者ID:babyfacebook,项目名称:FiveChess-1,代码行数:10,代码来源:chessboard.cpp

示例11: test_speed

void test_speed() {
    const char input[] = "position fen r2q1rk1/pP1p2pp/Q4n2/bbp1p3/Np6/1B3NBn/pPPP1PPP/R3K2R b KQ - 0 1";
    puts(input);
    Chess chess;
    chess.start_game();
    chess.table->setboard(input);
    chess.max_time = 0;
    chess.gui_depth = 2;
    chess.make_move();
}
开发者ID:zfazek,项目名称:FZChess,代码行数:10,代码来源:main.cpp

示例12: test_eval_depth_2

void test_eval_depth_2() {
    const char input[] = "position fen 4k2n/8/6p1/6P1/6p1/6P1/8/4K2N w - - 0 1 ";
    puts(input);
    Chess chess;
    chess.start_game();
    chess.table->setboard(input);
    chess.max_time = 0;
    chess.gui_depth = 5;
    chess.default_seldepth = 0;
    chess.make_move();
}
开发者ID:zfazek,项目名称:FZChess,代码行数:11,代码来源:main.cpp

示例13: main

int main()
{
    //Game g;
    //g.playOneGame(0);

    Chess c;
    c.foo();    
    //c.playOneGame(0);

    system("pause");
    return 0;
}
开发者ID:jcbrock,项目名称:MiscSmallTestProjects,代码行数:12,代码来源:main.cpp

示例14: areSquaresLegal

//------------------------------------------------------------------------------
bool RookPiece::areSquaresLegal(int src_row, int src_col,
                                int dest_row, int dest_col,
                                Piece* game_area[8][8], Chess& game_control)
{
  if(src_row == dest_row)
  {
    // be sure that all squares are empty
    int col_offset = (dest_col - src_col > 0) ? 1 : -1;

    for(int check_col = src_col + col_offset; check_col != dest_col;
        check_col += col_offset)
    {
      // check if the coordinates are valid
      if((check_col < 0 || check_col > 7))
      {
        return false;
      }

      if(game_area[src_row][check_col] != NULL)
      {
        game_control.setErrorCode(ERROR_PIECE_ON_WAY);
        return false;
      }
    }

    return true;
  }
  else if(dest_col == src_col)
  {
    int row_offset = (dest_row - src_row > 0) ? 1 : -1;

    for(int check_row = src_row + row_offset; check_row != dest_row;
        check_row += row_offset)
    {
      // check if the coordinates are valid
      if((check_row < 0 || check_row > 7))
      {
        return false;
      }

      if(game_area[check_row][src_col] != NULL)
      {
        game_control.setErrorCode(ERROR_PIECE_ON_WAY);
        return false;
      }
    }

    return true;
  }

  return false;
}
开发者ID:hakan0xFF,项目名称:chess,代码行数:53,代码来源:RookPiece.cpp

示例15: test_mate_in_2

void test_mate_in_2() {
    const char input[] =
        "position fen 2bqkbn1/2pppp2/np2N3/r3P1p1/p2N2B1/5Q2/PPPPKPP1/RNB2r2 w "
        "KQkq - 0 1";
    puts(input);
    Chess chess;
    chess.start_game();
    chess.table->setboard(input);
    chess.max_time = 0;
    chess.gui_depth = 5;
    chess.default_seldepth = 0;
    chess.make_move();
}
开发者ID:zfazek,项目名称:FZChess,代码行数:13,代码来源:main.cpp


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